Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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