Skip to content

Commit 188a94a

Browse files
author
Matt Childers
committed
Standardize VRF Regex for IOSXE show_vrf.py
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.
1 parent 8ba274d commit 188a94a

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--------------------------------------------------------------------------------
2+
Fix
3+
--------------------------------------------------------------------------------
4+
* IOSXE
5+
* Modified ShowVrf:
6+
* Standardized VRF Matching to include special characters beyond dash and dot

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def cli(self, vrf='', output=None):
6565
# test 10.116.83.34:100 ipv4,ipv6 Lo100
6666
# ce1 <being deleted> ipv4,ipv6 Et1/0
6767
# * ce1 2:2 ipv4,ipv6
68-
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]+))?$')
68+
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]+))?$')
6969

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

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

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

593593
res_dict = {}
594-
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]+)*$')
594+
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]+)*$')
595595
for line in output.splitlines():
596596
line = line.strip()
597597
# vrf21 21:1 ipv4,ipv6 Vl21'''
@@ -648,7 +648,7 @@ def cli(self, protocol, ip, option, mask, output=None):
648648
output = self.device.execute(self.cli_command.format(protocol=protocol, option=option, ip=ip,mask=mask))
649649

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

653653
# ------------------ show ip route vrf Default 11.1.6.1 255.255.255.0 ------------------
654654
# ------------------ show ip cef vrf vrf1000 11.1.6.1 255.255.255.0 internal ------------------
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
expected_output = {
2+
"vrf": {
3+
"t!#$%()*+@^:t/<>,.~`'\";t": {
4+
"protocols": ["ipv4", "ipv6"],
5+
"route_distinguisher": "1:1"
6+
},
7+
}
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Name Default RD Protocols Interfaces
2+
t!#$%()*+@^:t/<>,.~`'";t 1:1 ipv4,ipv6

0 commit comments

Comments
 (0)