get_interfaces unit test for SG350X-48P

This commit is contained in:
Petr Klima committed 2020-11-03 11:18:55 +00:00
1 parent 858636bf73
commit dc7f82cc15
4 files changed
+22 -45

No files matched your search

+19 -8
View File
@@ -282,19 +282,28 @@ class S350Driver(NetworkDriver):
show_status_output = self._send_command('show interfaces status') show_status_output = self._send_command('show interfaces status')
show_description_output = self._send_command('show interfaces description') 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')
try: # by documentation SG350
mac = show_system_output.splitlines()[0].split(':', maxsplit=1)[1].strip() show_jumbo_frame = self._send_command('show ports jumbo-frame')
except: match = re.search(r'Jumbo frames are enabled', show_jumbo_frame, re.M)
mac = '0' if match:
mtu = 9000
else:
mtu = 1518
mac = '0'
for status_line in show_status_output.splitlines(): for status_line in show_status_output.splitlines():
if 'Up' in status_line or 'Down' in status_line: if 'Up' in status_line or 'Down' in status_line:
interface, _, _, speed, _, _, link_state, _, _ = status_line.split() interface, _, _, speed, _, _, link_state, _, _ = status_line.split()
# Since the MAC address for all the local ports are equal, get the address
# from the first port and use it everywhere.
if mac == '0':
show_system_output = self._send_command('show lldp local ' + interface )
mac = show_system_output.splitlines()[0].split(':', maxsplit=1)[1].strip()
if speed == '--': if speed == '--':
is_enabled = False is_enabled = False
speed = 0 speed = 0
@@ -310,11 +319,13 @@ class S350Driver(NetworkDriver):
description = ' '.join(descr_line.split()[1:]) description = ' '.join(descr_line.split()[1:])
break break
# last_flapped can not be get - setting to default
entry = { entry = {
'is_up': is_up, 'is_up': is_up,
'is_enabled': is_enabled, 'is_enabled': is_enabled,
'speed': speed, 'speed': speed,
'last_flapped': -1, 'mtu': mtu,
'last_flapped': -1.0,
'description': description, 'description': description,
'mac_address': napalm.base.helpers.mac(mac) 'mac_address': napalm.base.helpers.mac(mac)
} }
@@ -0,0 +1,3 @@
Jumbo frames are enabled
Jumbo frames will be enabled after reset
@@ -1,37 +0,0 @@
Device ID: 04:eb:40:e3:91:7f
Port ID: 04:eb:40:e3:91:80
Capabilities: Bridge
System Name: sw1
Management address: 198.51.100..3
Management address: fe80::eb::ff:fee3::7f%vlan1
802.3 Power Via Mdi:
MDI Power support Port Class: PSE
PSE MDI Power Support: Supported
PSE MDI Power State: Enabled
PSE power pair control ability: Not supported
PSE Power Pair: Spare
PSE Power class: 2
Power Type: Type 2 PSE
Power Source: Primary Power Source
Power Priority: low
PSE Allocated Power Value: 3.9
4-Pair POE supported: Yes
Spare Pair Detection/Classification required: No
PD Spare Pair Desired State: Disabled
802.3 EEE:
Local Tx: 17 uSec
Local Rx: 17 uSec
Local Tx Echo: 17 uSec
Local Rx Echo: 17 uSec
802.1 PVID: 1
802.1 PPVID:
802.1 VLAN:
802.1 Protocol: