Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--------------------------------------------------------------------------------
New
--------------------------------------------------------------------------------
* NXOS
* Modified ShowIpMrouteSummary:
* Updated regex pattern p8 to capture bitrate_unit with optional k/m/g/t prefixes.
* Added conversion logic to normalize bitrate values to bps format.
* Modified ShowIpv6MrouteSummary:
* Updated regex pattern p8 to capture bitrate_unit with optional k/m/g/t prefixes.
* Added conversion logic to normalize bitrate values to bps format.
38 changes: 34 additions & 4 deletions src/genie/libs/parser/nxos/show_mcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def cli(self, vrf="default", output=None):
#100.100.100.5 1743 88893 51 0 27.200 bps 1
#(*,G) 0 0 0 0 0.000 bps 2
p8 = re.compile(r'^\s*(?P<source>\S+) +(?P<packets>[0-9]+) +(?P<bytes>[0-9]+) +(?P<aps>[0-9]+) +(?P<pps>[0-9]+) +'
Comment on lines 1094 to 1095
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new example with an example of what's being matched

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sir, adding now.

r'(?P<bitrate>[0-9.]+) +bps +(?P<oifs>[0-9]+)$')
r'(?P<bitrate>[0-9.]+) +(?P<bitrate_unit>[kmgt]?bps) +(?P<oifs>[0-9]+)$')

for line in out.splitlines():
line = line.strip()
Expand Down Expand Up @@ -1139,8 +1139,23 @@ def cli(self, vrf="default", output=None):
continue
m = p8.match(line)
if m:
# Capture the values
bitrate_value = float(m.groupdict()['bitrate'])
bitrate_unit = m.groupdict()['bitrate_unit']

# Convert to bps
conversion_factors = {
'bps': 1,
'kbps': 1000,
'mbps': 1000000,
'gbps': 1000000000,
'tbps': 1000000000000
}

bitrate_in_bps = bitrate_value * conversion_factors.get(bitrate_unit, 1)

src_dict = group_dict.setdefault('source',{}).setdefault(m.groupdict()['source'],{})
src_dict.update({'packets': int(m.groupdict()['packets']),'bytes': int(m.groupdict()['bytes']),'aps': int(m.groupdict()['aps']),'pps': int(m.groupdict()['pps']),'bitrate': float(m.groupdict()['bitrate']),'bitrate_unit':'bps','oifs': int(m.groupdict()['oifs'])})
src_dict.update({'packets': int(m.groupdict()['packets']),'bytes': int(m.groupdict()['bytes']),'aps': int(m.groupdict()['aps']),'pps': int(m.groupdict()['pps']),'bitrate': bitrate_in_bps,'bitrate_unit':'bps','oifs': int(m.groupdict()['oifs'])})
continue
return mroute_dict

Expand Down Expand Up @@ -1231,7 +1246,7 @@ def cli(self, vrf="default", output=None):
#2001:180:1:57::1181 968 49478 51 0 0.000 bps 1
#(*,G) 0 0 0 0 0.000 bps 2
p8 = re.compile(r'^\s*(?P<source>\S+) +(?P<packets>[0-9]+) +(?P<bytes>[0-9]+) +(?P<aps>[0-9]+) +(?P<pps>[0-9]+) +'
Comment on lines 1247 to 1248
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well

r'(?P<bitrate>[0-9.]+) +bps +(?P<oifs>[0-9]+)$')
r'(?P<bitrate>[0-9.]+) +(?P<bitrate_unit>[kmgt]?bps) +(?P<oifs>[0-9]+)$')

for line in out.splitlines():
line = line.strip()
Expand Down Expand Up @@ -1276,7 +1291,22 @@ def cli(self, vrf="default", output=None):
continue
m = p8.match(line)
if m:
# Capture the values
bitrate_value = float(m.groupdict()['bitrate'])
bitrate_unit = m.groupdict()['bitrate_unit']

# Convert to bps
conversion_factors = {
'bps': 1,
'kbps': 1000,
'mbps': 1000000,
'gbps': 1000000000,
'tbps': 1000000000000
}

bitrate_in_bps = bitrate_value * conversion_factors.get(bitrate_unit, 1)

src_dict = group_dict.setdefault('source',{}).setdefault(m.groupdict()['source'],{})
src_dict.update({'packets': int(m.groupdict()['packets']),'bytes': int(m.groupdict()['bytes']),'aps': int(m.groupdict()['aps']),'pps': int(m.groupdict()['pps']),'bitrate': float(m.groupdict()['bitrate']),'bitrate_unit':'bps','oifs': int(m.groupdict()['oifs'])})
src_dict.update({'packets': int(m.groupdict()['packets']),'bytes': int(m.groupdict()['bytes']),'aps': int(m.groupdict()['aps']),'pps': int(m.groupdict()['pps']),'bitrate': bitrate_in_bps,'bitrate_unit':'bps','oifs': int(m.groupdict()['oifs'])})
continue
return mroute_dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
expected_output = {
'vrf': {
'default': {
'address_family': {
'ipv4': {
'count_multicast_starg': 2,
'count_multicast_sg': 4,
'count_multicast_starg_prefix': 0,
'count_multicast_total': 6,
'group_count': 2,
'avg_source_per_group': 2.0,
'groups': {
'225.0.0.1/32': {
'source_count': 2,
'source': {
'(*,G)': {
'packets': 0,
'bytes': 0,
'aps': 0,
'pps': 0,
'bitrate': 0.0,
'bitrate_unit': 'bps',
'oifs': 2
},
'100.100.100.5': {
'packets': 1704,
'bytes': 86904,
'aps': 51,
'pps': 0,
'bitrate': 1500000.0,
'bitrate_unit': 'bps',
'oifs': 2
},
'100.100.100.6': {
'packets': 1700,
'bytes': 86700,
'aps': 51,
'pps': 0,
'bitrate': 500000.0,
'bitrate_unit': 'bps',
'oifs': 1
}
}
},
'225.0.0.2/32': {
'source_count': 2,
'source': {
'(*,G)': {
'packets': 0,
'bytes': 0,
'aps': 0,
'pps': 0,
'bitrate': 0.0,
'bitrate_unit': 'bps',
'oifs': 2
},
'100.100.100.7': {
'packets': 1743,
'bytes': 88893,
'aps': 51,
'pps': 0,
'bitrate': 2000000000.0,
'bitrate_unit': 'bps',
'oifs': 1
},
'100.100.100.8': {
'packets': 1891,
'bytes': 100806,
'aps': 53,
'pps': 0,
'bitrate': 1000000000000.0,
'bitrate_unit': 'bps',
'oifs': 2
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
IP Multicast Routing Table for VRF "default"
Route Statistics unavailable - only liveness detected

Total number of routes: 6
Total number of (*,G) routes: 2
Total number of (S,G) routes: 4
Total number of (*,G-prefix) routes: 0
Group count: 2, rough average sources per group: 2.0

Group: 225.0.0.1/32, Source count: 2
Source packets bytes aps pps bit-rate oifs
(*,G) 0 0 0 0 0.000 bps 2
100.100.100.5 1704 86904 51 0 1.500 mbps 2
100.100.100.6 1700 86700 51 0 500.000 kbps 1

Group: 225.0.0.2/32, Source count: 2
Source packets bytes aps pps bit-rate oifs
(*,G) 0 0 0 0 0.000 bps 2
100.100.100.7 1743 88893 51 0 2.000 gbps 1
100.100.100.8 1891 100806 53 0 1.000 tbps 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
expected_output = {
'vrf': {
'default': {
'address_family': {
'ipv6': {
'count_multicast_starg': 2,
'count_multicast_sg': 4,
'count_multicast_starg_prefix': 0,
'count_multicast_total': 6,
'group_count': 2,
'avg_source_per_group': 2.0,
'groups': {
'ff32::/32': {
'source_count': 2,
'source': {
'(*,G)': {
'packets': 0,
'bytes': 0,
'aps': 0,
'pps': 0,
'bitrate': 0.0,
'bitrate_unit': 'bps',
'oifs': 2
},
'2001:180:1:57::1181': {
'packets': 968,
'bytes': 49478,
'aps': 51,
'pps': 0,
'bitrate': 1500000.0,
'bitrate_unit': 'bps',
'oifs': 1
},
'2001:180:1:57::1182': {
'packets': 970,
'bytes': 49580,
'aps': 51,
'pps': 0,
'bitrate': 750000.0,
'bitrate_unit': 'bps',
'oifs': 1
}
}
},
'ff33:0:0:1197::1/128': {
'source_count': 2,
'source': {
'(*,G)': {
'packets': 0,
'bytes': 0,
'aps': 0,
'pps': 0,
'bitrate': 0.0,
'bitrate_unit': 'bps',
'oifs': 2
},
'2001:180:1:57::1183': {
'packets': 1000,
'bytes': 51000,
'aps': 52,
'pps': 0,
'bitrate': 3000000000.0,
'bitrate_unit': 'bps',
'oifs': 1
},
'2001:180:1:57::1184': {
'packets': 1100,
'bytes': 56100,
'aps': 53,
'pps': 0,
'bitrate': 2000000000000.0,
'bitrate_unit': 'bps',
'oifs': 2
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
IPv6 Multicast Routing Table for VRF "default"
Route Statistics unavailable - only liveness detected

Total number of routes: 6
Total number of (*,G) routes: 2
Total number of (S,G) routes: 4
Total number of (*,G-prefix) routes: 0
Group count: 2, rough average sources per group: 2.0

Group: ff32::/32, Source count: 2
Source packets bytes aps pps bit-rate oifs
(*,G) 0 0 0 0 0.000 bps 2
2001:180:1:57::1181 968 49478 51 0 1.500 mbps 1
2001:180:1:57::1182 970 49580 51 0 750.000 kbps 1

Group: ff33:0:0:1197::1/128, Source count: 2
Source packets bytes aps pps bit-rate oifs
(*,G) 0 0 0 0 0.000 bps 2
2001:180:1:57::1183 1000 51000 52 0 3.000 gbps 1
2001:180:1:57::1184 1100 56100 53 0 2.000 tbps 2