diff --git a/changelog/undistributed/changelog_show_mcast_bitrate_units_20251114150500.rst b/changelog/undistributed/changelog_show_mcast_bitrate_units_20251114150500.rst new file mode 100644 index 0000000000..a9900af0d5 --- /dev/null +++ b/changelog/undistributed/changelog_show_mcast_bitrate_units_20251114150500.rst @@ -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. diff --git a/src/genie/libs/parser/nxos/show_mcast.py b/src/genie/libs/parser/nxos/show_mcast.py index 9b7655c8fc..a9dd389ee9 100644 --- a/src/genie/libs/parser/nxos/show_mcast.py +++ b/src/genie/libs/parser/nxos/show_mcast.py @@ -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\S+) +(?P[0-9]+) +(?P[0-9]+) +(?P[0-9]+) +(?P[0-9]+) +' - r'(?P[0-9.]+) +bps +(?P[0-9]+)$') + r'(?P[0-9.]+) +(?P[kmgt]?bps) +(?P[0-9]+)$') for line in out.splitlines(): line = line.strip() @@ -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 @@ -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\S+) +(?P[0-9]+) +(?P[0-9]+) +(?P[0-9]+) +(?P[0-9]+) +' - r'(?P[0-9.]+) +bps +(?P[0-9]+)$') + r'(?P[0-9.]+) +(?P[kmgt]?bps) +(?P[0-9]+)$') for line in out.splitlines(): line = line.strip() @@ -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 diff --git a/src/genie/libs/parser/nxos/tests/ShowIpMrouteSummary/cli/equal/golden_output3_expected.py b/src/genie/libs/parser/nxos/tests/ShowIpMrouteSummary/cli/equal/golden_output3_expected.py new file mode 100644 index 0000000000..9ab6f1f790 --- /dev/null +++ b/src/genie/libs/parser/nxos/tests/ShowIpMrouteSummary/cli/equal/golden_output3_expected.py @@ -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 + } + } + } + } + } + } + } + } +} diff --git a/src/genie/libs/parser/nxos/tests/ShowIpMrouteSummary/cli/equal/golden_output3_output.txt b/src/genie/libs/parser/nxos/tests/ShowIpMrouteSummary/cli/equal/golden_output3_output.txt new file mode 100644 index 0000000000..8b47ac3138 --- /dev/null +++ b/src/genie/libs/parser/nxos/tests/ShowIpMrouteSummary/cli/equal/golden_output3_output.txt @@ -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 diff --git a/src/genie/libs/parser/nxos/tests/ShowIpv6MrouteSummary/cli/equal/golden_output3_expected.py b/src/genie/libs/parser/nxos/tests/ShowIpv6MrouteSummary/cli/equal/golden_output3_expected.py new file mode 100644 index 0000000000..85336b3eab --- /dev/null +++ b/src/genie/libs/parser/nxos/tests/ShowIpv6MrouteSummary/cli/equal/golden_output3_expected.py @@ -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 + } + } + } + } + } + } + } + } +} diff --git a/src/genie/libs/parser/nxos/tests/ShowIpv6MrouteSummary/cli/equal/golden_output3_output.txt b/src/genie/libs/parser/nxos/tests/ShowIpv6MrouteSummary/cli/equal/golden_output3_output.txt new file mode 100644 index 0000000000..731799b43e --- /dev/null +++ b/src/genie/libs/parser/nxos/tests/ShowIpv6MrouteSummary/cli/equal/golden_output3_output.txt @@ -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