show_lldp_neighbors with long systemname test for SG350X-48P

This commit is contained in:
Petr Klima committed 2020-11-03 15:33:57 +01:00
1 parent 89c020d1d4
commit 0cb23fa5de
4 files changed
+66 -3

No files matched your search

+14 -3
View File
@@ -370,6 +370,10 @@ class S350Driver(NetworkDriver):
output = self._send_command('show lldp neighbors') output = self._send_command('show lldp neighbors')
header = True # cycle trought header header = True # cycle trought header
# keep previous context - multiline syname
local_port = ''
remote_port = ''
remote_name = ''
for line in output.splitlines(): for line in output.splitlines():
if header: if header:
# last line of header # last line of header
@@ -379,9 +383,16 @@ class S350Driver(NetworkDriver):
continue continue
line_elems = line.split() line_elems = line.split()
local_port = line_elems[0]
remote_port = line_elems[2] # long system name owerflow to the other line
remote_name = line_elems[3] if len(line_elems) == 1:
# complete remote name
remote_name = remote_name + line_elems[0]
# then reuse old values na rewrite previous entry
else:
local_port = line_elems[0]
remote_port = line_elems[2]
remote_name = line_elems[3]
neighbor = { neighbor = {
'hostname': remote_name, 'hostname': remote_name,
@@ -0,0 +1,15 @@
System capability legend:
B - Bridge; R - Router; W - Wlan Access Point; T - telephone;
D - DOCSIS Cable Device; H - Host; r - Repeater;
TP - Two Ports MAC Relay; S - S-VLAN; C - C-VLAN; O - Other
Port Device ID Port ID System Name Capabilities TTL
--------- ----------------- ----------------- ----------------- ------------ -----
gi1/0/1 74:ac:aa:ff:1a:5f 74:ac:aa:ff:1a:5f UBNT B, W 90
gi1/0/35 34:e6:aa:ff:53:a8 34:e6:aa:ff:53:a8 O 3119
te1/0/1 00:16:ff:aa:bb:00 Gi0/23 swzdsadas-vedc B 107
te1/0/3 00:8e:ff:aa:bb:e2 gi28 sw1dsafdsfsdf.ex B, R 95
ample.net
te1/0/4 sw2dsdfssddfd te1/0/4 sw2dsdfssddfd B, R 105
@@ -0,0 +1,22 @@
{
"gi1/0/1" : [ {
"hostname" : "UBNT",
"port" : "74:ac:aa:ff:1a:5f"
} ],
"gi1/0/35" : [ {
"hostname" : "O",
"port" : "34:e6:aa:ff:53:a8"
} ],
"te1/0/1" : [ {
"hostname" : "swzdsadas-vedc",
"port" : "Gi0/23"
} ],
"te1/0/3" : [ {
"hostname" : "sw1dsafdsfsdf.example.net",
"port" : "gi28"
} ],
"te1/0/4" : [ {
"hostname" : "sw2dsdfssddfd",
"port" : "te1/0/4"
} ]
}
@@ -0,0 +1,15 @@
System capability legend:
B - Bridge; R - Router; W - Wlan Access Point; T - telephone;
D - DOCSIS Cable Device; H - Host; r - Repeater;
TP - Two Ports MAC Relay; S - S-VLAN; C - C-VLAN; O - Other
Port Device ID Port ID System Name Capabilities TTL
--------- ----------------- ----------------- ----------------- ------------ -----
gi1/0/1 74:ac:aa:ff:1a:5f 74:ac:aa:ff:1a:5f UBNT B, W 90
gi1/0/35 34:e6:aa:ff:53:a8 34:e6:aa:ff:53:a8 O 3119
te1/0/1 00:16:ff:aa:bb:00 Gi0/23 swzdsadas-vedc B 107
te1/0/3 00:8e:ff:aa:bb:e2 gi28 sw1dsafdsfsdf.ex B, R 95
ample.net
te1/0/4 sw2dsdfssddfd te1/0/4 sw2dsdfssddfd B, R 105