Skip to content
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

IOS-XE Make get_vlans name whitespace aware , see #1789 #2010

Merged
merged 6 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 7 additions & 3 deletions napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,11 @@ def get_vlans(self):
return self._get_vlan_all_ports(output)

def _get_vlan_all_ports(self, output):
find_regexp = re.compile(r"^(\d+)\s+(\S+)\s+\S+(\s+[A-Z][a-z].*)?$")
find_regexp = re.compile(
r"^(\d+)\s+" # vlan id
r"(.*?(?=active|act\/[isl]{1}shut|act\/unsup))" # vlan name
r"\w+(?:\/\w+)?\S+(\s+[A-Z][a-z].*)?$" # ports
)
continuation_regexp = re.compile(r"^\s+([A-Z][a-z].*)$")
output = output.splitlines()
vlans = {}
Expand All @@ -3736,7 +3740,7 @@ def _get_vlan_all_ports(self, output):
if vlan_m:
was_vlan_or_cont = True
vlan_id = vlan_m.group(1)
vlan_name = vlan_m.group(2)
vlan_name = vlan_m.group(2).strip()
interfaces = vlan_m.group(3) or ""
vlans[vlan_id] = {"name": vlan_name, "interfaces": []}

Expand All @@ -3763,7 +3767,7 @@ def _get_vlan_all_ports(self, output):
def _get_vlan_from_id(self):
command = "show vlan brief"
output = self._send_command(command)
vlan_regexp = r"^(\d+)\s+(\S+)\s+\S+.*$"
vlan_regexp = r"^(\d+)\W+(.*?(?=active|act\/[isl]{1}shut|act\/unsup))"
find_vlan = re.findall(vlan_regexp, output, re.MULTILINE)
vlans = {}
for vlan_id, vlan_name in find_vlan:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@
]
},
"795": {
"name": "Vlan795",
"name": "Vlan 795",
"interfaces": [
"Port-channel1",
"Port-channel5",
Expand Down Expand Up @@ -1194,5 +1194,10 @@
"1275": {
"name": "Vlan1275",
"interfaces": []
},
"1276": {
"name": "A1 - VIDEO",
"interfaces": ["Port-channel1"]
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ VLAN Name Status Ports
790 Vlan790 active Po1, Po5, Po6, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
792 Vlan792 active Po1, Po2, Po5, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
794 Vlan794 active Po1, Po5, Po6, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
795 Vlan795 active Po1, Po5, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
795 Vlan 795 active Po1, Po5, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
1002 Vlan1002 act/unsup Po1, Po5, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
1003 Vlan1003 act/unsup Po1, Po5, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
1004 Vlan1004 act/unsup Po1, Po5, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
1005 Vlan1005 act/unsup Po1, Po5, Po21, Po22, Po23, Po24, Po25, Po26, Po27, Po28, Po30
1275 Vlan1275 active
1276 A1 - VIDEO active Po1

VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
Expand Down Expand Up @@ -141,6 +142,7 @@ VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0
1275 enet 101275 1500 - - - - - 0 0
1276 enet 101275 1500 - - - - - 0 0

Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------
Loading