Merge branch 'develop' of github.com:napalm-automation-community/napalm-s350 into develop

This commit is contained in:
Petr Klima committed 2021-03-08 14:48:14 +01:00
commit 7ca5b3c5b4
2 files changed
+31 -9

No files matched your search

+3 -1
View File
@@ -23,6 +23,8 @@ pip3 install napalm_s350
Default information (the same as `call get_facts`)
```bash
napalm --user USER --password PASSWORD --vendor s350 HOSTNAME
napalm --user USER --password PASSWORD --vendor s350 HOSTNAME --optional_args "force_no_enable=True"
```
Get interfaces
@@ -48,7 +50,7 @@ be supported.
| function | SG300 | SG500 | SG350 | SG550 | stack SG500 | stack SG550 |
| :--- | :---: | :---: | :---: | :---: | :---: | :---: |
| **Send commands** |
| cli | | | | | | |
| cli | x | x | x | x | x | x |
| **Config manipulation** |
|get_config | x | x | x | x | | |
|get_config (filtered) | x | x | x | x | | |
+28 -8
View File
@@ -89,17 +89,20 @@ class S350Driver(NetworkDriver):
self.port = optional_args.get("port", 22)
self.device = None
self.force_no_enable = optional_args.get("force_no_enable", False)
def open(self):
"""Open a connection to the device."""
self.device = ConnectHandler(
device_type="cisco_s300",
host=self.hostname,
username=self.username,
password=self.password,
**self.netmiko_optional_args,
**self.netmiko_optional_args
)
self.device.enable()
if not self.force_no_enable:
self.device.enable()
def _discover_file_system(self):
try:
@@ -149,7 +152,12 @@ class S350Driver(NetworkDriver):
hours, minutes, seconds = timespec.split(":")
uptime_sec = (int(days) * 86400) + (int(hours) * 3600) + (int(minutes) * 60) + int(seconds)
uptime_sec = (
(int(days) * 86400)
+ (int(hours) * 3600)
+ (int(minutes) * 60)
+ int(seconds)
)
return uptime_sec
def get_arp_table(self, vrf=""):
@@ -234,7 +242,9 @@ class S350Driver(NetworkDriver):
# Do not output sensitive information
# use Cisco IOS filters
configs = napalm.base.helpers.sanitize_configs(configs, C.CISCO_SANITIZE_FILTERS)
configs = napalm.base.helpers.sanitize_configs(
configs, C.CISCO_SANITIZE_FILTERS
)
# defina my own filters
s350_filters = {
@@ -446,8 +456,14 @@ class S350Driver(NetworkDriver):
# 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()
show_system_output = self._send_command(
"show lldp local " + interface
)
mac = (
show_system_output.splitlines()[0]
.split(":", maxsplit=1)[1]
.strip()
)
if speed == "--":
is_enabled = False
@@ -515,7 +531,9 @@ class S350Driver(NetworkDriver):
interface = canonical_interface_name(interface, s350_base_interfaces)
interfaces[interface] = {family: {str(ip.ip): {"prefix_length": ip.prefixlen}}}
interfaces[interface] = {
family: {str(ip.ip): {"prefix_length": ip.prefixlen}}
}
return interfaces
@@ -625,7 +643,9 @@ class S350Driver(NetworkDriver):
if interface:
if interface == local_port:
entry = self._get_lldp_neighbors_detail_parse(local_port)
local_port = canonical_interface_name(local_port, s350_base_interfaces)
local_port = canonical_interface_name(
local_port, s350_base_interfaces
)
details[local_port] = [
entry,
]