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

add a few less used canonical mappings #1177

Merged
merged 3 commits into from
Apr 16, 2020
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: 10 additions & 0 deletions napalm/base/canonical_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"EO": "EOBC",
"Ethernet": "Ethernet",
"Eth": "Ethernet",
"eth": "Ethernet",
"Et": "Ethernet",
"et": "Ethernet",
"FastEthernet": "FastEthernet",
"FastEth": "FastEthernet",
"FastE": "FastEthernet",
Expand All @@ -32,6 +34,8 @@
"GigE": "GigabitEthernet",
"Gig": "GigabitEthernet",
"GE": "GigabitEthernet",
"Ge": "GigabitEthernet",
"ge": "GigabitEthernet",
"Gi": "GigabitEthernet",
"HundredGigabitEthernet": "HundredGigabitEthernet",
"HundredGigEthernet": "HundredGigabitEthernet",
Expand All @@ -40,10 +44,12 @@
"HundredGig": "HundredGigabitEthernet",
"Hu": "HundredGigabitEthernet",
"Loopback": "Loopback",
"loopback": "Loopback",
"Lo": "Loopback",
"lo": "Loopback",
"Management": "Management",
"Mgmt": "Management",
"mgmt": "Management",
"Ma": "Management",
"Management_short": "Ma",
"MFR": "MFR",
Expand All @@ -55,6 +61,8 @@
"PortChannel": "Port-channel",
"Port-channel": "Port-channel",
"Port-Channel": "Port-channel",
"port-channel": "Port-channel",
"po": "Port-channel",
"Po": "Port-channel",
"POS": "POS",
"PO": "POS",
Expand Down Expand Up @@ -82,6 +90,7 @@
"VLAN": "VLAN",
"V": "VLAN",
"Vl": "VLAN",
"Wlan-GigabitEthernet": "Wlan-GigabitEthernet",
}

reverse_mapping = {
Expand All @@ -107,4 +116,5 @@
"Virtual-Access": "Vi",
"Virtual-Template": "Vt",
"VLAN": "Vl",
"Wlan-GigabitEthernet": "Wl-Gi",
}
8 changes: 6 additions & 2 deletions napalm/nxos/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,13 @@ def _parse_vlan_ports(self, vlan_s):
find = re.findall(find_regexp, vls.strip())
if find:
for i in range(int(find[0][1]), int(find[0][2]) + 1):
vlans.append(find[0][0] + str(i))
vlans.append(
napalm.base.helpers.canonical_interface_name(
find[0][0] + str(i)
)
)
else:
vlans.append(vls.strip())
vlans.append(napalm.base.helpers.canonical_interface_name(vls.strip()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, just wanted to mention that on IOS at least there's an optional argument canonical_int defaulting to False currently - is this something we'd want on NX-OS as well? My preference would probably be to always use the canonical map, but maybe there are some reasons on the existence of canonical_int arg I'm not aware of. CC @ktbyers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see this anywhere else in the nxos/nxos_ssh code. I can add it if desired.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's open that as a separate issue (so this PR doesn't get bogged down). I would guess for backwards compatibility, but it doesn't look like it was fully/consistently implemented.

I would vote always use canonical interface and just get rid of the argument to toggle that off (especially given that it looks like it is currently inconsistently implemented).

return vlans


Expand Down
2 changes: 1 addition & 1 deletion napalm/nxos_ssh/nxos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def parse_intf_section(interface):
else:
# More standard is up, next line admin state is lines
match = re.search(re_intf_name_state, interface)
intf_name = match.group("intf_name")
intf_name = helpers.canonical_interface_name(match.group("intf_name"))
intf_state = match.group("intf_state").strip()
is_up = True if intf_state == "up" else False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"port": "Ethernet1/1"
}
],
"mgmt0": [
"Management0": [
{
"hostname": "PERIMETER.cisco.com",
"port": "Fa1/0/9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"remote_system_name": "n9k2.ntc.com"
}
],
"mgmt0": [
"Management0": [
{
"remote_port_description": "FastEthernet1/0/9",
"remote_port": "Fa1/0/9",
Expand Down
28 changes: 14 additions & 14 deletions test/nxos/mocked_data/test_get_vlans/6000/expected_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"230": {
"name": "database",
"interfaces": [
"port-channel1",
"port-channel2",
"port-channel10",
"port-channel11",
"port-channel12",
"port-channel13",
"port-channel99",
"Port-channel1",
"Port-channel2",
"Port-channel10",
"Port-channel11",
"Port-channel12",
"Port-channel13",
"Port-channel99",
"Ethernet1/3",
"Ethernet1/6",
"Ethernet1/7",
Expand Down Expand Up @@ -43,13 +43,13 @@
"231": {
"name": "APPLICATION",
"interfaces": [
"port-channel1",
"port-channel2",
"port-channel10",
"port-channel11",
"port-channel12",
"port-channel13",
"port-channel99",
"Port-channel1",
"Port-channel2",
"Port-channel10",
"Port-channel11",
"Port-channel12",
"Port-channel13",
"Port-channel99",
"Ethernet1/3",
"Ethernet1/6",
"Ethernet1/7",
Expand Down
Loading