Merge branch 'develop' of https://github.com/napalm-automation-community/napalm-s350 into develop
This commit is contained in:
commit
b1bf846e30
1 file changed
+23
-6
+23
-6
@@ -141,14 +141,19 @@ class S350Driver(NetworkDriver):
|
|||||||
"""
|
"""
|
||||||
arp_table = []
|
arp_table = []
|
||||||
|
|
||||||
output = self._send_command('show arp | include (static|dynamic)')
|
output = self._send_command('show arp')
|
||||||
|
|
||||||
for line in output.splitlines():
|
for line in output.splitlines():
|
||||||
# A VLAN may not be set for the entry
|
# A VLAN may not be set for the entry
|
||||||
|
if 'vlan' not in line:
|
||||||
|
continue
|
||||||
if len(line.split()) == 4:
|
if len(line.split()) == 4:
|
||||||
interface, ip, mac, _ = line.split()
|
interface, ip, mac, _ = line.split()
|
||||||
elif len(line.split()) == 5:
|
elif len(line.split()) == 5:
|
||||||
_, interface, mac, _ = line.split()
|
if1, if2, ip, mac, _ = line.split()
|
||||||
|
interface = "{} {}".format(if1, if2)
|
||||||
|
elif len(line.split()) == 6:
|
||||||
|
_, _, interface, ip, mac, _ = line.split()
|
||||||
else:
|
else:
|
||||||
raise ValueError('Unexpected output: {}'.format(line.split()))
|
raise ValueError('Unexpected output: {}'.format(line.split()))
|
||||||
|
|
||||||
@@ -198,11 +203,19 @@ class S350Driver(NetworkDriver):
|
|||||||
show_int_st = self._send_command('show interface status')
|
show_int_st = self._send_command('show interface status')
|
||||||
|
|
||||||
# os_version
|
# os_version
|
||||||
|
# detect os ver > 2
|
||||||
|
if 'Active-image' in show_ver:
|
||||||
for line in show_ver.splitlines():
|
for line in show_ver.splitlines():
|
||||||
# First version line is the active version
|
# First version line is the active version
|
||||||
if 'Version' in line:
|
if 'Version' in line:
|
||||||
_, os_version = line.split('Version: ')
|
_, os_version = line.split('Version: ')
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
for line in show_ver.splitlines():
|
||||||
|
if 'SW version' in line:
|
||||||
|
_, ver = line.split(' ')
|
||||||
|
os_version, _ = ver.split(' (')
|
||||||
|
break
|
||||||
|
|
||||||
# hostname, uptime
|
# hostname, uptime
|
||||||
for line in show_sys.splitlines():
|
for line in show_sys.splitlines():
|
||||||
@@ -264,11 +277,11 @@ class S350Driver(NetworkDriver):
|
|||||||
"""
|
"""
|
||||||
interfaces = {}
|
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')
|
show_description_output = self._send_command('show interfaces description')
|
||||||
# Since the MAC address for all the local ports are equal, get the address
|
# Since the MAC address for all the local ports are equal, get the address
|
||||||
# from the first port and use it everywhere.
|
# 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:
|
try:
|
||||||
mac = show_system_output.splitlines()[0].split(':', maxsplit=1)[1].strip()
|
mac = show_system_output.splitlines()[0].split(':', maxsplit=1)[1].strip()
|
||||||
@@ -276,6 +289,7 @@ class S350Driver(NetworkDriver):
|
|||||||
mac = '0'
|
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:
|
||||||
interface, _, _, speed, _, _, link_state, _, _ = status_line.split()
|
interface, _, _, speed, _, _, link_state, _, _ = status_line.split()
|
||||||
|
|
||||||
if speed == '--':
|
if speed == '--':
|
||||||
@@ -310,10 +324,13 @@ class S350Driver(NetworkDriver):
|
|||||||
def get_interfaces_ip(self):
|
def get_interfaces_ip(self):
|
||||||
"""Returns all configured interface IP addresses."""
|
"""Returns all configured interface IP addresses."""
|
||||||
interfaces = {}
|
interfaces = {}
|
||||||
show_ip_int = self._send_command('show ip int | include (UP|DOWN)')
|
valid_interfaces = []
|
||||||
|
show_ip_int = self._send_command('show ip int')
|
||||||
|
|
||||||
# Limit to valid interfaces (i.e. ignore vlan 1)
|
# Limit to valid interfaces (i.e. ignore vlan 1)
|
||||||
valid_interfaces = [i for i in show_ip_int.splitlines() if i.split()[-1] == 'Valid']
|
for line in show_ip_int.splitlines():
|
||||||
|
if ('UP' in line or 'DOWN' in line) and line.split()[-1] == 'Valid':
|
||||||
|
valid_interfaces.append(line)
|
||||||
|
|
||||||
for interface in valid_interfaces:
|
for interface in valid_interfaces:
|
||||||
network, name = interface.split()[:2]
|
network, name = interface.split()[:2]
|
||||||
|
|||||||
Reference in new issue
Block a user