From 17be10cd6a503a4e1a0dff14bd0f3d8a601e4e44 Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Tue, 3 Nov 2020 15:52:39 +0100 Subject: [PATCH] get_lldp_neighbors_detail test for SG350X-48P --- napalm_s350/s350.py | 9 ++-- .../show_lldp_neighbors_gi1_0_1.txt | 51 +++++++++++++++++++ .../SG350X-48P-K9/expected_result.json | 16 ++++++ .../SG350X-48P-K9/show_lldp_neighbors.txt | 4 +- .../show_lldp_neighbors_gi1_0_1.txt | 51 +++++++++++++++++++ 5 files changed, 124 insertions(+), 7 deletions(-) create mode 100644 test/unit/mocked_data/SG350X-48P-K9/show_lldp_neighbors_gi1_0_1.txt create mode 100644 test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/expected_result.json create mode 100644 test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/show_lldp_neighbors_gi1_0_1.txt diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index 84b8015..a7fcbce 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -428,7 +428,7 @@ class S350Driver(NetworkDriver): remote_system_name, remote_system_description, \ remote_system_capab, remote_system_enable_capab = (u'N/A',) * 7 - output = self._send_command('show lldp neighbor {}'.format(local_port)) + output = self._send_command('show lldp neighbors {}'.format(local_port)) for line in output.splitlines(): if line.startswith('Port ID'): @@ -459,6 +459,7 @@ class S350Driver(NetworkDriver): else: caps.append(cap[0]) + print(caps) entry = { 'parent_interface': u'N/A', 'remote_port': remote_port_id, @@ -466,11 +467,11 @@ class S350Driver(NetworkDriver): 'remote_chassis_id': remote_chassis_id, 'remote_system_name': remote_system_name, 'remote_system_description': remote_system_description, - 'remote_system_capab': u', '.join(caps), - 'remote_system_enable_capab': u', '.join(caps), + 'remote_system_capab': caps, + 'remote_system_enable_capab': caps, } - details[local_port] = entry + details[local_port] = [ entry, ] return details diff --git a/test/unit/mocked_data/SG350X-48P-K9/show_lldp_neighbors_gi1_0_1.txt b/test/unit/mocked_data/SG350X-48P-K9/show_lldp_neighbors_gi1_0_1.txt new file mode 100644 index 0000000..10f3f25 --- /dev/null +++ b/test/unit/mocked_data/SG350X-48P-K9/show_lldp_neighbors_gi1_0_1.txt @@ -0,0 +1,51 @@ + +Device ID: 11:ac:00:66:ff:aa +Port ID: 11:ac:00:66:ff:aa +Capabilities: Bridge, Wlan-Access-Point +System Name: SBC +System description: ABC-SC-BM, 1.2.34.11111 +Port description: br0 +Management Address: 192.168.1.121 +Management Address: fe80::76ac:b9ff:fe66:ffaa +Time To Live: 90 + + +802.3 MAC/PHY Configuration/Status +Auto-negotiation support: Not supported +Auto-negotiation status: Disabled +Auto-negotiation Advertised Capabilities: +Operational MAU type: Unknown + +802.3 Link Aggregation +Aggregation capability: Capable of being aggregated +Aggregation status: Currently not in aggregation + + +802.3 EEE: + + Remote Tx: 17 uSec + Remote Rx: 17 uSec + Remote Tx Echo: 17 uSec + Remote Rx Echo: 17 uSec + + +802.1 PVID: None +802.1 PPVID: +802.1 VLAN: +802.1 Protocol: + + +LLDP-MED capabilities: Capabilities, Network Policy, Location, POE-PSE, POE-PD, Inventory +LLDP-MED Device Type: Network Connectivity + +Hardware revision: +Firmware revision: +Software revision: 1.2.345 +Serial number: +Manufacturer name: +Model name: +Asset ID: + + + + diff --git a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/expected_result.json new file mode 100644 index 0000000..34803a1 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/expected_result.json @@ -0,0 +1,16 @@ +{ "gi1/0/1" : [ { + "parent_interface" : "N/A", + "remote_chassis_id" : "11:ac:00:66:ff:aa", + "remote_port" : "11:ac:00:66:ff:aa", + "remote_port_description" : "br0", + "remote_system_capab" : [ + "B", + "W" + ], + "remote_system_description" : "ABC-SC-BM, 1.2.34.11111", + "remote_system_enable_capab" : [ + "B", + "W" + ], + "remote_system_name" : "SBC" + } ] } diff --git a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/show_lldp_neighbors.txt b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/show_lldp_neighbors.txt index fb27e93..9089c0b 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/show_lldp_neighbors.txt +++ b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/show_lldp_neighbors.txt @@ -6,7 +6,5 @@ TP - Two Ports MAC Relay; S - S-VLAN; C - C-VLAN; O - Other Port Device ID Port ID System Name Capabilities TTL --------- ----------------- ----------------- ----------------- ------------ ----- -gi1/0/37 b0:b8:67:c2:32:aa b0:b8:67:c2:32:aa AM W 110 -te1/0/3 00:8e:73:24:5d:e2 gi28 sw1 B, R 116 -te1/0/4 sw2 te1/0/4 sw2 B, R 100 +gi1/0/1 74:ac:aa:ff:1a:5f 74:ac:aa:ff:1a:5f UBNT B, W 90 diff --git a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/show_lldp_neighbors_gi1_0_1.txt b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/show_lldp_neighbors_gi1_0_1.txt new file mode 100644 index 0000000..10f3f25 --- /dev/null +++ b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG350X-48P-K9/show_lldp_neighbors_gi1_0_1.txt @@ -0,0 +1,51 @@ + +Device ID: 11:ac:00:66:ff:aa +Port ID: 11:ac:00:66:ff:aa +Capabilities: Bridge, Wlan-Access-Point +System Name: SBC +System description: ABC-SC-BM, 1.2.34.11111 +Port description: br0 +Management Address: 192.168.1.121 +Management Address: fe80::76ac:b9ff:fe66:ffaa +Time To Live: 90 + + +802.3 MAC/PHY Configuration/Status +Auto-negotiation support: Not supported +Auto-negotiation status: Disabled +Auto-negotiation Advertised Capabilities: +Operational MAU type: Unknown + +802.3 Link Aggregation +Aggregation capability: Capable of being aggregated +Aggregation status: Currently not in aggregation + + +802.3 EEE: + + Remote Tx: 17 uSec + Remote Rx: 17 uSec + Remote Tx Echo: 17 uSec + Remote Rx Echo: 17 uSec + + +802.1 PVID: None +802.1 PPVID: +802.1 VLAN: +802.1 Protocol: + + +LLDP-MED capabilities: Capabilities, Network Policy, Location, POE-PSE, POE-PD, Inventory +LLDP-MED Device Type: Network Connectivity + +Hardware revision: +Firmware revision: +Software revision: 1.2.345 +Serial number: +Manufacturer name: +Model name: +Asset ID: + + + +