adjust get_interfaces function for compatibility with sgx00 series
include and begin are not available on sgx00 devices
This commit is contained in:
1 parent
7a1f027cdb
commit
5a2d22302a
1 file changed
+25
-24
+25
-24
@@ -277,11 +277,11 @@ class S350Driver(NetworkDriver):
|
||||
"""
|
||||
interfaces = {}
|
||||
|
||||
show_status_output = self._send_command('show interfaces status | include (Up|Down)')
|
||||
show_status_output = self._send_command('show interfaces status')
|
||||
show_description_output = self._send_command('show interfaces description')
|
||||
# Since the MAC address for all the local ports are equal, get the address
|
||||
# from the first port and use it everywhere.
|
||||
show_system_output = self._send_command('show lldp local GigabitEthernet1 | begin Device\ ID')
|
||||
show_system_output = self._send_command('show lldp local GigabitEthernet1')
|
||||
|
||||
try:
|
||||
mac = show_system_output.splitlines()[0].split(':', maxsplit=1)[1].strip()
|
||||
@@ -289,33 +289,34 @@ class S350Driver(NetworkDriver):
|
||||
mac = '0'
|
||||
|
||||
for status_line in show_status_output.splitlines():
|
||||
interface, _, _, speed, _, _, link_state, _, _ = status_line.split()
|
||||
if 'Up' in status_line or 'Down' in status_line:
|
||||
interface, _, _, speed, _, _, link_state, _, _ = status_line.split()
|
||||
|
||||
if speed == '--':
|
||||
is_enabled = False
|
||||
speed = 0
|
||||
else:
|
||||
is_enabled = True
|
||||
speed = int(speed)
|
||||
if speed == '--':
|
||||
is_enabled = False
|
||||
speed = 0
|
||||
else:
|
||||
is_enabled = True
|
||||
speed = int(speed)
|
||||
|
||||
is_up = (link_state == 'Up')
|
||||
is_up = (link_state == 'Up')
|
||||
|
||||
for descr_line in show_description_output.splitlines():
|
||||
description = 0
|
||||
if descr_line.startswith(interface):
|
||||
description = ' '.join(descr_line.split()[1:])
|
||||
break
|
||||
for descr_line in show_description_output.splitlines():
|
||||
description = 0
|
||||
if descr_line.startswith(interface):
|
||||
description = ' '.join(descr_line.split()[1:])
|
||||
break
|
||||
|
||||
entry = {
|
||||
'is_up': is_up,
|
||||
'is_enabled': is_enabled,
|
||||
'speed': speed,
|
||||
'last_flapped': -1,
|
||||
'description': description,
|
||||
'mac_address': napalm.base.helpers.mac(mac)
|
||||
}
|
||||
entry = {
|
||||
'is_up': is_up,
|
||||
'is_enabled': is_enabled,
|
||||
'speed': speed,
|
||||
'last_flapped': -1,
|
||||
'description': description,
|
||||
'mac_address': napalm.base.helpers.mac(mac)
|
||||
}
|
||||
|
||||
interfaces[interface] = entry
|
||||
interfaces[interface] = entry
|
||||
|
||||
return interfaces
|
||||
|
||||
|
||||
Reference in new issue
Block a user