Skip to content

Commit

Permalink
#1025 Work around NXAPI double quoting (#1048)
Browse files Browse the repository at this point in the history
* #1025 Work around NXAPI double quoting

The NXAPI on the Nexus 9000 platform seems to be double-quoting the name of inventory items.

Amend the check for the inventory item name to take this into account.

* the output of the N9000 has extra quotes:

show inventory | json
{"TABLE_inv": {"ROW_inv": [{"name": "\"Chassis\"",
"desc": "\"Nexus9000 C92160YC-X chassis\"",.......
  • Loading branch information
Ichabond authored and mirceaulinic committed Sep 18, 2019
1 parent 74cce13 commit 668c4ee
Show file tree
Hide file tree
Showing 8 changed files with 13,108 additions and 3 deletions.
2 changes: 1 addition & 1 deletion napalm/nxos/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def get_facts(self):
facts["serial_number"] = None

for row in show_inventory_table:
if row["name"] == "Chassis":
if row["name"] == '"Chassis"' or row["name"] == "Chassis":
facts["serial_number"] = row.get("serialnum", "")
break

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 @@ -591,7 +591,7 @@ def get_facts(self):
show_inventory_table = [show_inventory_table]

for row in show_inventory_table:
if row["name"] == "Chassis":
if row["name"] == '"Chassis"' or row["name"] == "Chassis":
serial_number = row.get("serialnum", "")
break

Expand Down
157 changes: 157 additions & 0 deletions test/nxos/mocked_data/test_get_facts/N9000/expected_result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"uptime": 4066631,
"vendor": "Cisco",
"hostname": "nxos-spine1",
"fqdn": "nxos-spine1.domain.com",
"os_version": "7.3(1)D1(1) [build 7.3(1)D1(0.10)]",
"serial_number": "TM6017D760B",
"model": "NX-OSv Chassis",
"interface_list": [
"mgmt0",
"Ethernet2/1",
"Ethernet2/2",
"Ethernet2/3",
"Ethernet2/4",
"Ethernet2/5",
"Ethernet2/6",
"Ethernet2/7",
"Ethernet2/8",
"Ethernet2/9",
"Ethernet2/10",
"Ethernet2/11",
"Ethernet2/12",
"Ethernet2/13",
"Ethernet2/14",
"Ethernet2/15",
"Ethernet2/16",
"Ethernet2/17",
"Ethernet2/18",
"Ethernet2/19",
"Ethernet2/20",
"Ethernet2/21",
"Ethernet2/22",
"Ethernet2/23",
"Ethernet2/24",
"Ethernet2/25",
"Ethernet2/26",
"Ethernet2/27",
"Ethernet2/28",
"Ethernet2/29",
"Ethernet2/30",
"Ethernet2/31",
"Ethernet2/32",
"Ethernet2/33",
"Ethernet2/34",
"Ethernet2/35",
"Ethernet2/36",
"Ethernet2/37",
"Ethernet2/38",
"Ethernet2/39",
"Ethernet2/40",
"Ethernet2/41",
"Ethernet2/42",
"Ethernet2/43",
"Ethernet2/44",
"Ethernet2/45",
"Ethernet2/46",
"Ethernet2/47",
"Ethernet2/48",
"Ethernet3/1",
"Ethernet3/2",
"Ethernet3/3",
"Ethernet3/4",
"Ethernet3/5",
"Ethernet3/6",
"Ethernet3/7",
"Ethernet3/8",
"Ethernet3/9",
"Ethernet3/10",
"Ethernet3/11",
"Ethernet3/12",
"Ethernet3/13",
"Ethernet3/14",
"Ethernet3/15",
"Ethernet3/16",
"Ethernet3/17",
"Ethernet3/18",
"Ethernet3/19",
"Ethernet3/20",
"Ethernet3/21",
"Ethernet3/22",
"Ethernet3/23",
"Ethernet3/24",
"Ethernet3/25",
"Ethernet3/26",
"Ethernet3/27",
"Ethernet3/28",
"Ethernet3/29",
"Ethernet3/30",
"Ethernet3/31",
"Ethernet3/32",
"Ethernet3/33",
"Ethernet3/34",
"Ethernet3/35",
"Ethernet3/36",
"Ethernet3/37",
"Ethernet3/38",
"Ethernet3/39",
"Ethernet3/40",
"Ethernet3/41",
"Ethernet3/42",
"Ethernet3/43",
"Ethernet3/44",
"Ethernet3/45",
"Ethernet3/46",
"Ethernet3/47",
"Ethernet3/48",
"Ethernet4/1",
"Ethernet4/2",
"Ethernet4/3",
"Ethernet4/4",
"Ethernet4/5",
"Ethernet4/6",
"Ethernet4/7",
"Ethernet4/8",
"Ethernet4/9",
"Ethernet4/10",
"Ethernet4/11",
"Ethernet4/12",
"Ethernet4/13",
"Ethernet4/14",
"Ethernet4/15",
"Ethernet4/16",
"Ethernet4/17",
"Ethernet4/18",
"Ethernet4/19",
"Ethernet4/20",
"Ethernet4/21",
"Ethernet4/22",
"Ethernet4/23",
"Ethernet4/24",
"Ethernet4/25",
"Ethernet4/26",
"Ethernet4/27",
"Ethernet4/28",
"Ethernet4/29",
"Ethernet4/30",
"Ethernet4/31",
"Ethernet4/32",
"Ethernet4/33",
"Ethernet4/34",
"Ethernet4/35",
"Ethernet4/36",
"Ethernet4/37",
"Ethernet4/38",
"Ethernet4/39",
"Ethernet4/40",
"Ethernet4/41",
"Ethernet4/42",
"Ethernet4/43",
"Ethernet4/44",
"Ethernet4/45",
"Ethernet4/46",
"Ethernet4/47",
"Ethernet4/48",
"Vlan1"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"hostname": "nxos-spine1.domain.com"}

0 comments on commit 668c4ee

Please sign in to comment.