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

Fix issue about N9K with vxlan #676

Merged
merged 7 commits into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 6 additions & 0 deletions napalm/base/canonical_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
base_interfaces = {
"ATM": "ATM",
"AT": "ATM",
"B": "Bdi",
"Bd": "Bdi",
"Bdi": "Bdi",
"EOBC": "EOBC",
"EO": "EOBC",
"Ethernet": "Ethernet",
Expand Down Expand Up @@ -50,6 +53,9 @@
"MFR": "MFR",
"Multilink": "Multilink",
"Mu": "Multilink",
"n": "nve",
"nv": "nve",
"nve": "nve",
"PortChannel": "Port-channel",
"Port-channel": "Port-channel",
"Port-Channel": "Port-channel",
Expand Down
48 changes: 31 additions & 17 deletions napalm/nxos_ssh/nxos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ def parse_intf_section(interface):
re_is_enabled_1 = r"^admin state is (?P<is_enabled>\S+)$"
re_is_enabled_2 = r"^admin state is (?P<is_enabled>\S+), "
re_is_enabled_3 = r"^.* is down.*Administratively down.*$"
re_mac = r"^\s+Hardware.*address:\s+(?P<mac_address>\S+) "
re_speed = r"^\s+MTU .*, BW (?P<speed>\S+) (?P<speed_unit>\S+), "
re_description = r"^\s+Description:\s+(?P<description>.*)$"
re_mac = r"^\s+Hardware:\s+(?P<hardware>.*), address:\s+(?P<mac_address>\S+) "
re_speed = r"\s+MTU .*, BW (?P<speed>\S+) (?P<speed_unit>\S+), "
re_description_1 = r"^\s+Description:\s+(?P<description>.*) (?:MTU|Internet)"
re_description_2 = r"^\s+Description:\s+(?P<description>.*)$"
re_hardware = r"^.* Hardware: (?P<hardware>\S+)$"

# Check for 'protocol is ' lines
match = re.search(re_protocol, interface, flags=re.M)
Expand Down Expand Up @@ -124,7 +126,7 @@ def parse_intf_section(interface):
match = re.search(x_pattern, interface, flags=re.M)
if match:
is_enabled = match.group('is_enabled').strip()
is_enabled = True if is_enabled == 'up' else False
is_enabled = True if re.search("up", is_enabled) else False
break
else:
msg = "Error parsing intf, 'admin state' never detected:\n\n{}".format(interface)
Expand All @@ -145,19 +147,30 @@ def parse_intf_section(interface):
else:
mac_address = ""

match = re.search(re_speed, interface, flags=re.M)
speed = int(match.group('speed'))
speed_unit = match.group('speed_unit')
# This was alway in Kbit (in the data I saw)
if speed_unit != "Kbit":
msg = "Unexpected speed unit in show interfaces parsing:\n\n{}".format(interface)
raise ValueError(msg)
speed = int(round(speed / 1000.0))
match = re.search(re_hardware, interface, flags=re.M)
speed_exist = True
if match:
if match.group('hardware') == "NVE":
speed_exist = False

if speed_exist:
match = re.search(re_speed, interface, flags=re.M)
speed = int(match.group('speed'))
speed_unit = match.group('speed_unit')
# This was alway in Kbit (in the data I saw)
if speed_unit != "Kbit":
msg = "Unexpected speed unit in show interfaces parsing:\n\n{}".format(interface)
raise ValueError(msg)
speed = int(round(speed / 1000.0))
else:
speed = -1

description = ''
match = re.search(re_description, interface, flags=re.M)
if match:
description = match.group('description')
for x_pattern in [re_description_1, re_description_2]:
match = re.search(x_pattern, interface, flags=re.M)
if match:
description = match.group('description')
break

return {
intf_name: {
Expand Down Expand Up @@ -750,7 +763,8 @@ def get_facts(self):
interface_list = []
show_int_status = show_int_status.strip()
# Remove the header information
show_int_status = re.split(r'^---------+', show_int_status, flags=re.M)[-1]
show_int_status = re.sub(r'(?:^---------+$|^Port .*$|^ .*$)', '',
show_int_status, flags=re.M)
for line in show_int_status.splitlines():
if not line:
continue
Expand Down Expand Up @@ -1269,7 +1283,7 @@ def process_mac_fields(vlan, mac, mac_type, interface):
output = re.split(r'^----.*', output, flags=re.M)[1:]
output = "\n".join(output).strip()
# Strip any leading characters
output = re.sub(r"^[\*\+GO]", "", output, flags=re.M)
output = re.sub(r"^[\*\+GOCE]", "", output, flags=re.M)
output = re.sub(r"^\(R\)", "", output, flags=re.M)
output = re.sub(r"^\(T\)", "", output, flags=re.M)
output = re.sub(r"^\(F\)", "", output, flags=re.M)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uptime": 255891,
"vendor": "Cisco",
"hostname": "SWITCHNAME",
"fqdn": "SWITCHNAME.dcn.fr.tld.com",
"os_version": "7.0(3)I7(2)",
"serial_number": "FDO21270U84",
"model": "Nexus9000 93180YC-EX chassis",
"interface_list": ["mgmt0", "Ethernet1/1", "Ethernet1/2", "Ethernet1/3", "Ethernet1/4", "Ethernet1/5", "Ethernet1/6", "Ethernet1/7", "Ethernet1/8", "Ethernet1/9", "Ethernet1/10", "Ethernet1/11", "Ethernet1/12", "Ethernet1/13", "Ethernet1/14", "Ethernet1/15", "Ethernet1/16", "Ethernet1/17", "Ethernet1/18", "Ethernet1/19", "Ethernet1/20", "Ethernet1/21", "Ethernet1/22", "Ethernet1/23", "Ethernet1/24", "Ethernet1/25", "Ethernet1/26", "Ethernet1/27", "Ethernet1/28", "Ethernet1/29", "Ethernet1/30", "Ethernet1/31", "Ethernet1/32", "Ethernet1/33", "Ethernet1/34", "Ethernet1/35", "Ethernet1/36", "Ethernet1/37", "Ethernet1/38", "Ethernet1/39", "Ethernet1/40", "Ethernet1/41", "Ethernet1/42", "Ethernet1/43", "Ethernet1/44", "Ethernet1/45", "Ethernet1/46", "Ethernet1/47", "Ethernet1/48", "Ethernet1/49", "Ethernet1/50", "Ethernet1/51", "Ethernet1/52", "Ethernet1/53", "Ethernet1/54", "Port-channel1", "Port-channel10", "Port-channel13", "Port-channel14", "Port-channel15", "Port-channel16", "Port-channel17", "Port-channel18", "Port-channel19", "Port-channel20", "Port-channel21", "Port-channel22", "Port-channel23", "Port-channel24", "Port-channel25", "Port-channel26", "Port-channel29", "Port-channel30", "Port-channel33", "Port-channel34", "Port-channel37", "Port-channel92", "Port-channel93", "Port-channel94", "Port-channel95", "Port-channel96", "Port-channel97", "Port-channel99", "Loopback0", "Loopback1", "Vlan1", "Vlan333", "Vlan600", "Vlan650", "nve1"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SWITCHNAME.dcn.fr.tld.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DNS lookup disabled
Vrf Name: default Default domain is dcn.fr.tld.com
Name/address lookup uses domain service
Name servers are 255.255.255.255


Host Address
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

--------------------------------------------------------------------------------
Port Name Status Vlan Duplex Speed Type
--------------------------------------------------------------------------------
mgmt0 connected routed full 1000 --

--------------------------------------------------------------------------------
Port Name Status Vlan Duplex Speed Type
--------------------------------------------------------------------------------
Eth1/1 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/2 *** LIBRE *** connected trunk full 1000 1000base-T
Eth1/3 *** LIBRE *** connected trunk full 1000 1000base-T
Eth1/4 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/5 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/6 *** LIBRE *** connected trunk full 1000 1000base-T
Eth1/7 *** LIBRE *** connected trunk full 1000 1000base-T
Eth1/8 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/9 *** LIBRE *** connected trunk full 10G 10Gbase-SR
Eth1/10 *** LIBRE *** connected trunk full 10G 10Gbase-SR
Eth1/11 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/12 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/13 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/14 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/15 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/16 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/17 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/18 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/19 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/20 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/21 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/22 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/23 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/24 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/25 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/26 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/27 *** LIBRE *** disabled 10 auto auto SFP-H10GB-CU5M
Eth1/28 *** LIBRE *** disabled 10 auto auto SFP-H10GB-CU5M
Eth1/29 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/30 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/31 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/32 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/33 *** LIBRE *** connected trunk full 10G SFP-H10GB-CU5M
Eth1/34 *** LIBRE *** connected trunk full 10G 10Gbase-SR
Eth1/35 *** LIBRE *** connected 1 full 10G 10Gbase-SR
Eth1/36 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/37 *** LIBRE *** disabled trunk auto auto 10Gbase-SR
Eth1/38 *** LIBRE *** disabled trunk auto auto 10Gbase-SR
Eth1/39 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/40 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/41 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/42 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/43 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/44 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/45 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/46 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/47 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/48 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/49 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/50 *** LIBRE *** xcvrAbsen routed auto auto --
Eth1/51 *** LIBRE *** connected routed full 100G QSFP-100G-SR4-S
Eth1/52 *** LIBRE *** connected routed full 100G QSFP-100G-SR4-S
Eth1/53 *** LIBRE *** connected trunk full 100G QSFP-100G-CR4
Eth1/54 *** LIBRE *** connected trunk full 100G QSFP-100G-CR4
Po1 *** LIBRE *** connected trunk full 100G --
Po10 *** LIBRE *** connected trunk full 10G --
Po13 *** LIBRE *** connected trunk full 10G --
Po14 *** LIBRE *** connected trunk full 10G --
Po15 *** LIBRE *** connected trunk full 10G --
Po16 *** LIBRE *** connected trunk full 10G --
Po17 *** LIBRE *** connected trunk full 10G --
Po18 *** LIBRE *** connected trunk full 10G --
Po19 *** LIBRE *** connected trunk full 10G --
Po20 *** LIBRE *** connected trunk full 10G --
Po21 *** LIBRE *** connected trunk full 10G --
Po22 *** LIBRE *** connected trunk full 10G --
Po23 *** LIBRE *** connected trunk full 10G --
Po24 *** LIBRE *** connected trunk full 10G --
Po25 *** LIBRE *** connected trunk full 10G --
Po26 *** LIBRE *** connected trunk full 10G --
Po29 *** LIBRE *** connected trunk full 10G --
Po30 *** LIBRE *** connected trunk full 10G --
Po33 *** LIBRE *** connected trunk full 10G --
Po34 *** LIBRE *** connected trunk full 10G --
Po37 *** LIBRE *** disabled trunk auto auto --
Po92 *** LIBRE *** connected trunk full 1000 --
Po93 *** LIBRE *** connected trunk full 1000 --
Po94 *** LIBRE *** connected trunk full 10G --
Po95 *** LIBRE *** connected trunk full 10G --
Po96 *** LIBRE *** connected trunk full 1000 --
Po97 *** LIBRE *** connected trunk full 1000 --
Po99 *** LIBRE *** connected trunk full 10G --
Lo0 *** LIBRE *** connected routed auto auto --
Lo1 *** LIBRE *** connected routed auto auto --
Vlan1 -- down routed auto auto --
Vlan333 *** BTB_OSPF *** connected routed auto auto --
Vlan600 *** L3VNI-PROD *** connected routed auto auto --
Vlan650 *** L3VNI-NPROD ** connected routed auto auto --
nve1 -- connected -- auto auto --
46 changes: 46 additions & 0 deletions test/nxos_ssh/mocked_data/test_get_facts/N93180/show_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac
Copyright (C) 2002-2017, Cisco and/or its affiliates.
All rights reserved.
The copyrights to certain works contained in this software are
owned by other third parties and used and distributed under their own
licenses, such as open source. This software is provided "as is," and unless
otherwise stated, there is no warranty, express or implied, including but not
limited to warranties of merchantability and fitness for a particular purpose.
Certain components of this software are licensed under
the GNU General Public License (GPL) version 2.0 or
GNU General Public License (GPL) version 3.0 or the GNU
Lesser General Public License (LGPL) Version 2.1 or
Lesser General Public License (LGPL) Version 2.0.
A copy of each such license is available at
http://www.opensource.org/licenses/gpl-2.0.php and
http://opensource.org/licenses/gpl-3.0.html and
http://www.opensource.org/licenses/lgpl-2.1.php and
http://www.gnu.org/licenses/old-licenses/library.txt.

Software
BIOS: version 07.61
NXOS: version 7.0(3)I7(2)
BIOS compile time: 04/06/2017
NXOS image file is: bootflash:///nxos.7.0.3.I7.2.bin
NXOS compile time: 11/22/2017 13:00:00 [11/22/2017 22:55:29]


Hardware
cisco Nexus9000 93180YC-EX chassis
Intel(R) Xeon(R) CPU @ 1.80GHz with 24633476 kB of memory.
Processor Board ID FDO21270U84

Device name: SWITCHNAME
bootflash: 53298520 kB
Kernel uptime is 2 day(s), 23 hour(s), 4 minute(s), 51 second(s)

Last reset
Reason: Unknown
System version: 7.0(3)I7(2)
Service:

plugin
Core Plugin, Ethernet Plugin

Active Package(s):
Loading