-
Notifications
You must be signed in to change notification settings - Fork 420
Fix: Support mbps/kbps/gbps in show ip mroute summary parser #971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Taarini
merged 3 commits into
CiscoTestAutomation:main
from
bigevilbeard:fix-mroute-mbps-support
Nov 14, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
changelog/undistributed/changelog_show_mcast_bitrate_units_20251114150500.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]+) +' | ||
| 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() | ||
|
|
@@ -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<source>\S+) +(?P<packets>[0-9]+) +(?P<bytes>[0-9]+) +(?P<aps>[0-9]+) +(?P<pps>[0-9]+) +' | ||
|
Comment on lines
1247
to
1248
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
|
@@ -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 | ||
82 changes: 82 additions & 0 deletions
82
src/genie/libs/parser/nxos/tests/ShowIpMrouteSummary/cli/equal/golden_output3_expected.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/genie/libs/parser/nxos/tests/ShowIpMrouteSummary/cli/equal/golden_output3_output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
82 changes: 82 additions & 0 deletions
82
src/genie/libs/parser/nxos/tests/ShowIpv6MrouteSummary/cli/equal/golden_output3_expected.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/genie/libs/parser/nxos/tests/ShowIpv6MrouteSummary/cli/equal/golden_output3_output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sir, adding now.