Skip to content

Commit bad8497

Browse files
authored
Merge pull request #966 from jlmcgraw/20251029_iosxe_show_interfaces_accounting
Fixes related to whitespace for parsing "show interfaces accounting"
2 parents 933ac99 + ed66aed commit bad8497

File tree

4 files changed

+536
-3
lines changed

4 files changed

+536
-3
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
----------------------
2+
Fix
3+
----------------------
4+
* iosxe
5+
* Modified class ShowInterfacesAccounting
6+
* Modified regex pattern to support interface descriptions with multiple spaces
7+
* Only right-strip whitespace from lines and modify regex for lines containing counters to add explicit leading
8+
whitespace

src/genie/libs/parser/iosxe/show_interface.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3828,10 +3828,11 @@ def cli(self, interface=None, output=None):
38283828
# initial regexp pattern
38293829
# GigabitEthernet0/0/0/0
38303830
# GigabitEthernet11 OOB Net
3831+
# TenGigabitEthernet0/0/0 rvartr101 e1/9 rack 107-37 N2C-BE VRF
38313832
# (need to exclude below line)
38323833
# -------------------------------------------------------------------------------------------------------------------------
38333834
p1 = re.compile(
3834-
r'^(?!-)(?P<interface>[a-zA-Z\-\d\/\.]+)(?P<description>( (\S)+)*)$'
3835+
r'^(?!-)(?P<interface>[a-zA-Z\-\d/.]+)(\s+(?P<description>[\S\s]+?))?$'
38353836
)
38363837

38373838
# Tunnel0 Pim Register Tunnel (Encap) for RP 10.186.1.1
@@ -3843,7 +3844,7 @@ def cli(self, interface=None, output=None):
38433844
# DEC MOP 2 154 2 154
38443845
# Other 15 900 861 370708 0 0 0 0
38453846
p2 = re.compile(
3846-
r'^(?P<protocol>\S+(\s\S+)?)\s+(?P<pkts_in>\d+)\s+(?P<chars_in>\d+)\s+(?P<pkts_out>\d+)\s+(?P<chars_out>\d+)(\s+(?P<rxbs>\d+)\s+(?P<rxps>\d+)\s+(?P<txbs>\d+)\s+(?P<txps>\d+))?'
3847+
r'^\s+(?P<protocol>\S+(\s\S+)?)\s+(?P<pkts_in>\d+)\s+(?P<chars_in>\d+)\s+(?P<pkts_out>\d+)\s+(?P<chars_out>\d+)(\s+(?P<rxbs>\d+)\s+(?P<rxps>\d+)\s+(?P<txbs>\d+)\s+(?P<txps>\d+))?'
38473848
)
38483849

38493850
# No traffic sent or received on this interface.
@@ -3852,7 +3853,7 @@ def cli(self, interface=None, output=None):
38523853

38533854
for line in out.splitlines():
38543855
if line:
3855-
line = line.strip()
3856+
line = line.rstrip()
38563857
else:
38573858
continue
38583859

0 commit comments

Comments
 (0)