Skip to content

Commit

Permalink
Standardize VRF Regex for IOSXE show_vrf.py
Browse files Browse the repository at this point in the history
Currently ShowVrf doesn't match all valid special characters in VRF
names, and uses different regexes for different commands throughout
show_vrf.py. This change standardizes the regexes to all be the same
and matches the special characters.
  • Loading branch information
Matt Childers committed Dec 9, 2023
1 parent 8ba274d commit 188a94a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--------------------------------------------------------------------------------
Fix
--------------------------------------------------------------------------------
* IOSXE
* Modified ShowVrf:
* Standardized VRF Matching to include special characters beyond dash and dot
8 changes: 4 additions & 4 deletions src/genie/libs/parser/iosxe/show_vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def cli(self, vrf='', output=None):
# test 10.116.83.34:100 ipv4,ipv6 Lo100
# ce1 <being deleted> ipv4,ipv6 Et1/0
# * ce1 2:2 ipv4,ipv6
p1 = re.compile(r'^(((?P<being_deleted>\*))\s+)?(?P<vrf>[\w\d\-\.]+)\s+(?P<rd>\<not +set\>|<being deleted>|[\.\d\:]+)(?:\s+(?P<protocols>[(?:ipv\d)\,]+))?(?:\s+(?P<intf>[\S\s]+))?$')
p1 = re.compile(r'^(((?P<being_deleted>\*))\s+)?(?P<vrf>[\S]+)\s+(?P<rd>\<not +set\>|<being deleted>|[\.\d\:]+)(?:\s+(?P<protocols>[(?:ipv\d)\,]+))?(?:\s+(?P<intf>[\S\s]+))?$')

# Lo300
# Gi2.390
Expand Down Expand Up @@ -282,7 +282,7 @@ def cli(self, output=None):
r'current +count +(?P<count>\d+)$')

# VRF label distribution protocol: not configured
p10 = re.compile(r'^VRF +label +distribution +protocol: +(?P<vrf_label>[\w\s\-]+)$')
p10 = re.compile(r'^VRF +label +distribution +protocol: +(?P<vrf_label>[\S]+)$')

# VRF label allocation mode: per-prefix
p11 = re.compile(r'^VRF +label +allocation +mode: +(?P<mode>[\w\s\-]+)'
Expand Down Expand Up @@ -591,7 +591,7 @@ def cli(self, vrf='',output=None):
output = self.device.execute(self.cli_command.format(vrf=vrf))

res_dict = {}
p1 = re.compile(r'^(?P<vrf>[\w\d]+)+\s+(?P<default_rd>[\d\:\d]+)+\s+(?P<protocols>[\w\,\w]+)\s+\s\s(?P<interface>[\w\d]+)*$')
p1 = re.compile(r'^(?P<vrf>[\S]+)+\s+(?P<default_rd>[\d\:\d]+)+\s+(?P<protocols>[\w\,\w]+)\s+\s\s(?P<interface>[\w\d]+)*$')
for line in output.splitlines():
line = line.strip()
# vrf21 21:1 ipv4,ipv6 Vl21'''
Expand Down Expand Up @@ -648,7 +648,7 @@ def cli(self, protocol, ip, option, mask, output=None):
output = self.device.execute(self.cli_command.format(protocol=protocol, option=option, ip=ip,mask=mask))

# VRF Default
p1 = re.compile(r'^VRF\s+(?P<vrf_name>[\w\s\-]+)$')
p1 = re.compile(r'^VRF\s+(?P<vrf_name>[\S]+)$')

# ------------------ show ip route vrf Default 11.1.6.1 255.255.255.0 ------------------
# ------------------ show ip cef vrf vrf1000 11.1.6.1 255.255.255.0 internal ------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
expected_output = {
"vrf": {
"t!#$%()*+@^:t/<>,.~`'\";t": {
"protocols": ["ipv4", "ipv6"],
"route_distinguisher": "1:1"
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Name Default RD Protocols Interfaces
t!#$%()*+@^:t/<>,.~`'";t 1:1 ipv4,ipv6

0 comments on commit 188a94a

Please sign in to comment.