From 9d6c4ea88b6aa39a8fc7374baa897445b064dfbf Mon Sep 17 00:00:00 2001 From: Petr Klima Date: Fri, 29 Mar 2024 17:17:20 +0100 Subject: [PATCH 1/6] Lift version to 0.4.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 66ede45..04c0f6b 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-s350", - version="0.4.0", + version="0.4.1", packages=find_packages(exclude=("test*",)), author="Jasper Lievisse Adriaanse, Petr Klíma, Daniel Bacher", author_email="j@jasper.la, qaxi@seznam.cz, mail@phill93.de", From e320121d2717606facdfb584299577d3ea59dbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Fri, 29 Mar 2024 17:23:46 +0100 Subject: [PATCH 2/6] Adapt to napalm 4.1 tests (#90) * use netmiko_args * Add changes for 4.1.0 (#89) * Update requirements.txt * Typpo in requirements * _send_command has only two parameters * Adapt to stricter Unit tests --------- Co-authored-by: Anton Gridnev * Remove s350_base_interfaces custom map - it is allready in napalm base * Adapt Unit tests to canonical_interface_name() --------- Co-authored-by: Dave Co-authored-by: Anton Gridnev --- napalm_s350/s350.py | 51 ++++--------------- requirements-dev.txt | 8 ++- requirements.txt | 6 +-- .../SG300-10/expected_result.json | 2 +- .../SG350X-48P-K9/expected_result.json | 20 ++++---- .../SG500-28-K9/expected_result.json | 4 +- .../SG550X-24MP-K9/expected_result.json | 20 ++++---- .../SG300-10/expected_result.json | 2 +- .../SG350X-48P-K9/expected_result.json | 20 ++++---- .../SG500-28-K9/expected_result.json | 4 +- .../SG550X-24MP-K9/expected_result.json | 20 ++++---- .../expected_result.json | 8 +-- .../expected_result.json | 8 +-- .../SG350X-48P-K9/expected_result.json | 8 +-- .../SG550X-24MP-K9/expected_result.json | 8 +-- .../SG350X-48P-K9/expected_result.json | 8 +-- .../SG550X-24MP-K9/expected_result.json | 8 +-- .../CBS350-24P-4G/expected_result.json | 4 +- .../SG300-10/expected_result.json | 2 +- .../SG350X-48P-K9/expected_result.json | 4 +- .../SG500-28-K9/expected_result.json | 2 +- .../SG550X-24MP-K9/expected_result.json | 2 +- .../expected_result.json | 6 +-- .../SG350X-48P-K9/expected_result.json | 6 +-- .../SG550X-24MP-K9/expected_result.json | 4 +- .../SG550X-24MP-K9/expected_result.json | 2 +- ...ldp_neighbors_TenGigabitEthernet1_0_4.txt} | 0 27 files changed, 102 insertions(+), 135 deletions(-) rename test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/{show_lldp_neighbors_TengigabitEthernet1_0_4.txt => show_lldp_neighbors_TenGigabitEthernet1_0_4.txt} (100%) diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index eb3a9b8..9da78d9 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -33,18 +33,11 @@ ConnectionClosedException, ) from napalm.base.helpers import canonical_interface_name +from napalm.base.netmiko_helpers import netmiko_args import napalm.base.constants as C import napalm.base.canonical_map -# make may own base_interfaces for s350 -s350_base_interfaces = { - **napalm.base.canonical_map.base_interfaces, - "fa": "FastEthernet", - "gi": "GigabitEthernet", - "te": "TengigabitEthernet", -} - from typing import List @@ -65,31 +58,7 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None) self._dest_file_system = optional_args.get("dest_file_system", None) # Netmiko possible arguments - netmiko_argument_map = { - "port": None, - "secret": "", - "verbose": False, - "keepalive": 30, - "global_delay_factor": 1, - "use_keys": False, - "key_file": None, - "ssh_strict": False, - "system_host_keys": False, - "alt_host_keys": False, - "alt_key_file": "", - "ssh_config_file": None, - "allow_agent": False, - "session_log": None, - "read_timeout_override": None, - } - - # Allow for passing additional Netmiko arguments - self.netmiko_optional_args = {} - for k, v in netmiko_argument_map.items(): - try: - self.netmiko_optional_args[k] = optional_args[k] - except KeyError: - pass + self.netmiko_optional_args = netmiko_args(optional_args) self.platform = "s350" self.port = optional_args.get("port", 22) @@ -175,7 +144,7 @@ def get_arp_table(self, vrf=""): else: raise ValueError("Unexpected output: {}".format(line.split())) - interface = canonical_interface_name(interface, s350_base_interfaces) + interface = canonical_interface_name(interface) entry = { "interface": interface, @@ -294,7 +263,7 @@ def get_facts(self): if not line: continue interface = line.split()[0] - interface = canonical_interface_name(interface, s350_base_interfaces) + interface = canonical_interface_name(interface) interfaces.append(str(interface)) @@ -474,7 +443,7 @@ def get_interfaces(self): "mac_address": napalm.base.helpers.mac(mac), } - interface = canonical_interface_name(interface, s350_base_interfaces) + interface = canonical_interface_name(interface) interfaces[interface] = entry @@ -512,7 +481,7 @@ def get_interfaces_ip(self): ip = netaddr.IPNetwork(cidr) family = "ipv{0}".format(ip.version) - interface = canonical_interface_name(interface, s350_base_interfaces) + interface = canonical_interface_name(interface) interfaces[interface] = {family: {str(ip.ip): {"prefix_length": ip.prefixlen}}} @@ -570,7 +539,7 @@ def get_lldp_neighbors(self): remote_port = line_elems[2] remote_name = line_elems[3] - local_port = canonical_interface_name(local_port, s350_base_interfaces) + local_port = canonical_interface_name(local_port) neighbor = { "hostname": remote_name, @@ -624,14 +593,14 @@ def get_lldp_neighbors_detail(self, interface=""): 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) details[local_port] = [ entry, ] else: 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) details[local_port] = [ entry, ] @@ -666,7 +635,7 @@ def _get_lldp_neighbors_detail_parse(self, local_port): elif line.startswith("Capabilities"): caps = self._get_lldp_neighbors_detail_capabilities_parse(line) - remote_port_id = canonical_interface_name(remote_port_id, s350_base_interfaces) + remote_port_id = canonical_interface_name(remote_port_id) entry = { "parent_interface": "N/A", diff --git a/requirements-dev.txt b/requirements-dev.txt index a8b9916..bf3ef10 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,16 +1,14 @@ -napalm<=4.0.0 -netmiko<=4.0.0 -black<=24.3.0 # CVE-2024-21503 +napalm>=4.0.0 +netmiko>=4.0.0 +black>=24.3.0 # CVE-2024-21503 coveralls ddt flake8-import-order -# pytest==6.2.5 pytest pytest-cov pytest-json pytest-pythonpath pylama -# pyflakes==2.4.0 #prevent problems pyflakes mock tox diff --git a/requirements.txt b/requirements.txt index be9a920..7510853 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -napalm<=4.0.0 -netmiko<=4.0.0 -netaddr<=1.2.1 +napalm>=4.0.0 +netmiko>=4.0.0 +netaddr>=1.2.1 diff --git a/test/unit/mocked_data/test_get_arp_table/SG300-10/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG300-10/expected_result.json index 3bd353c..75c5e8b 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG300-10/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG300-10/expected_result.json @@ -1,3 +1,3 @@ [ - {"interface": "vlan 1", "mac": "9C:EB:E8:AA:BB:CC", "ip": "192.168.1.1", "age": 0.0} + {"interface": "VLAN1", "mac": "9C:EB:E8:AA:BB:CC", "ip": "192.168.1.1", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json index 05c1b7e..a5fbe8d 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG350X-48P-K9/expected_result.json @@ -1,12 +1,12 @@ [ - {"interface": "TengigabitEthernet1/0/1", "mac": "00:00:0C:07:AC:01", "ip": "19.51.0.1", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "E4:C7:22:FE:E0:43", "ip": "19.51.0.2", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:15:AA", "ip": "19.51.0.5", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:14:6F", "ip": "19.51.0.3", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:BD:C0", "ip": "19.51.0.1", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, - {"interface": "vlan 852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, - {"interface": "vlan 852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:00:0C:07:AC:01", "ip": "19.51.0.1", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "E4:C7:22:FE:E0:43", "ip": "19.51.0.2", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:15:AA", "ip": "19.51.0.5", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:14:6F", "ip": "19.51.0.3", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "5C:8A:38:2E:BD:C0", "ip": "19.51.0.1", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, + {"interface": "VLAN852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, + {"interface": "VLAN852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table/SG500-28-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG500-28-K9/expected_result.json index 62f8007..5452c31 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG500-28-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG500-28-K9/expected_result.json @@ -1,4 +1,4 @@ [ - {"interface": "vlan 202", "mac": "00:15:17:27:9C:4D", "ip": "10.0.3.1", "age": 0.0}, - {"interface": "vlan 202", "mac": "00:50:56:90:23:E8", "ip": "10.0.3.4", "age": 0.0} + {"interface": "VLAN202", "mac": "00:15:17:27:9C:4D", "ip": "10.0.3.1", "age": 0.0}, + {"interface": "VLAN202", "mac": "00:50:56:90:23:E8", "ip": "10.0.3.4", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json index b03f87b..76f97fc 100644 --- a/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table/SG550X-24MP-K9/expected_result.json @@ -1,61 +1,61 @@ [ { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.1", "mac" : "AB:00:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.2", "mac" : "AB:C7:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.65", "mac" : "AB:EA:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.73", "mac" : "AB:EA:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.40", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.44", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "vlan 1", + "interface" : "VLAN1", "ip" : "192.168.0.4", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.49", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.2", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "vlan 1", + "interface" : "VLAN1", "ip" : "192.168.0.142", "mac" : "AB:50:EF:12:34:56" } diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG300-10/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG300-10/expected_result.json index 3bd353c..75c5e8b 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG300-10/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG300-10/expected_result.json @@ -1,3 +1,3 @@ [ - {"interface": "vlan 1", "mac": "9C:EB:E8:AA:BB:CC", "ip": "192.168.1.1", "age": 0.0} + {"interface": "VLAN1", "mac": "9C:EB:E8:AA:BB:CC", "ip": "192.168.1.1", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json index 05c1b7e..a5fbe8d 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG350X-48P-K9/expected_result.json @@ -1,12 +1,12 @@ [ - {"interface": "TengigabitEthernet1/0/1", "mac": "00:00:0C:07:AC:01", "ip": "19.51.0.1", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "E4:C7:22:FE:E0:43", "ip": "19.51.0.2", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:15:AA", "ip": "19.51.0.5", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:14:6F", "ip": "19.51.0.3", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:BD:C0", "ip": "19.51.0.1", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, - {"interface": "TengigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, - {"interface": "vlan 852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, - {"interface": "vlan 852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:00:0C:07:AC:01", "ip": "19.51.0.1", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "E4:C7:22:FE:E0:43", "ip": "19.51.0.2", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:15:AA", "ip": "19.51.0.5", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "BC:EA:FA:B4:14:6F", "ip": "19.51.0.3", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "5C:8A:38:2E:BD:C0", "ip": "19.51.0.1", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "5C:8A:38:2E:FD:E0", "ip": "19.51.0.8", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:50:56:93:19:B7", "ip": "19.51.1.4", "age": 0.0}, + {"interface": "TenGigabitEthernet1/0/1", "mac": "00:50:56:92:2F:CB", "ip": "19.51.1.5", "age": 0.0}, + {"interface": "VLAN852", "mac": "00:50:56:9E:51:F3", "ip": "19.51.1.2", "age": 0.0}, + {"interface": "VLAN852", "mac": "A4:4C:C8:7D:37:03", "ip": "19.51.14.5", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG500-28-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG500-28-K9/expected_result.json index 62f8007..5452c31 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG500-28-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG500-28-K9/expected_result.json @@ -1,4 +1,4 @@ [ - {"interface": "vlan 202", "mac": "00:15:17:27:9C:4D", "ip": "10.0.3.1", "age": 0.0}, - {"interface": "vlan 202", "mac": "00:50:56:90:23:E8", "ip": "10.0.3.4", "age": 0.0} + {"interface": "VLAN202", "mac": "00:15:17:27:9C:4D", "ip": "10.0.3.1", "age": 0.0}, + {"interface": "VLAN202", "mac": "00:50:56:90:23:E8", "ip": "10.0.3.4", "age": 0.0} ] diff --git a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json index b03f87b..76f97fc 100644 --- a/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_arp_table_with_vrf/SG550X-24MP-K9/expected_result.json @@ -1,61 +1,61 @@ [ { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.1", "mac" : "AB:00:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.2", "mac" : "AB:C7:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.65", "mac" : "AB:EA:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.73", "mac" : "AB:EA:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.40", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.44", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "vlan 1", + "interface" : "VLAN1", "ip" : "192.168.0.4", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.49", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "TengigabitEthernet1/0/4", + "interface" : "TenGigabitEthernet1/0/4", "ip" : "192.168.0.2", "mac" : "AB:50:EF:12:34:56" }, { "age" : 0.0, - "interface" : "vlan 1", + "interface" : "VLAN1", "ip" : "192.168.0.142", "mac" : "AB:50:EF:12:34:56" } diff --git a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-domainname/expected_result.json b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-domainname/expected_result.json index df56c88..f6a3660 100644 --- a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-domainname/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-domainname/expected_result.json @@ -50,10 +50,10 @@ "GigabitEthernet1/0/46", "GigabitEthernet1/0/47", "GigabitEthernet1/0/48", - "TengigabitEthernet1/0/1", - "TengigabitEthernet1/0/2", - "TengigabitEthernet1/0/3", - "TengigabitEthernet1/0/4", + "TenGigabitEthernet1/0/1", + "TenGigabitEthernet1/0/2", + "TenGigabitEthernet1/0/3", + "TenGigabitEthernet1/0/4", "Port-channel1", "Port-channel2", "Port-channel3", diff --git a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-twisted_inventory/expected_result.json b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-twisted_inventory/expected_result.json index 53726c6..51bafb5 100644 --- a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-twisted_inventory/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9-twisted_inventory/expected_result.json @@ -50,10 +50,10 @@ "GigabitEthernet1/0/46", "GigabitEthernet1/0/47", "GigabitEthernet1/0/48", - "TengigabitEthernet1/0/1", - "TengigabitEthernet1/0/2", - "TengigabitEthernet1/0/3", - "TengigabitEthernet1/0/4", + "TenGigabitEthernet1/0/1", + "TenGigabitEthernet1/0/2", + "TenGigabitEthernet1/0/3", + "TenGigabitEthernet1/0/4", "Port-channel1", "Port-channel2", "Port-channel3", diff --git a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9/expected_result.json index 53726c6..51bafb5 100644 --- a/test/unit/mocked_data/test_get_facts/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/SG350X-48P-K9/expected_result.json @@ -50,10 +50,10 @@ "GigabitEthernet1/0/46", "GigabitEthernet1/0/47", "GigabitEthernet1/0/48", - "TengigabitEthernet1/0/1", - "TengigabitEthernet1/0/2", - "TengigabitEthernet1/0/3", - "TengigabitEthernet1/0/4", + "TenGigabitEthernet1/0/1", + "TenGigabitEthernet1/0/2", + "TenGigabitEthernet1/0/3", + "TenGigabitEthernet1/0/4", "Port-channel1", "Port-channel2", "Port-channel3", diff --git a/test/unit/mocked_data/test_get_facts/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_facts/SG550X-24MP-K9/expected_result.json index 0708e8f..fb354cf 100644 --- a/test/unit/mocked_data/test_get_facts/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_facts/SG550X-24MP-K9/expected_result.json @@ -26,10 +26,10 @@ "GigabitEthernet1/0/22", "GigabitEthernet1/0/23", "GigabitEthernet1/0/24", - "TengigabitEthernet1/0/1", - "TengigabitEthernet1/0/2", - "TengigabitEthernet1/0/3", - "TengigabitEthernet1/0/4", + "TenGigabitEthernet1/0/1", + "TenGigabitEthernet1/0/2", + "TenGigabitEthernet1/0/3", + "TenGigabitEthernet1/0/4", "Port-channel1", "Port-channel2", "Port-channel3", diff --git a/test/unit/mocked_data/test_get_interfaces/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces/SG350X-48P-K9/expected_result.json index 6cf7fc2..6cea30b 100644 --- a/test/unit/mocked_data/test_get_interfaces/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces/SG350X-48P-K9/expected_result.json @@ -431,7 +431,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/1" : { + "TenGigabitEthernet1/0/1" : { "description" : "T1", "is_enabled" : true, "is_up" : true, @@ -440,7 +440,7 @@ "mtu" : 9000, "speed" : 1000 }, - "TengigabitEthernet1/0/2" : { + "TenGigabitEthernet1/0/2" : { "description" : "", "is_enabled" : false, "is_up" : false, @@ -449,7 +449,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/3" : { + "TenGigabitEthernet1/0/3" : { "description" : "T2", "is_enabled" : true, "is_up" : true, @@ -458,7 +458,7 @@ "mtu" : 9000, "speed" : 1000 }, - "TengigabitEthernet1/0/4" : { + "TenGigabitEthernet1/0/4" : { "description" : "T3", "is_enabled" : true, "is_up" : true, diff --git a/test/unit/mocked_data/test_get_interfaces/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces/SG550X-24MP-K9/expected_result.json index 7a45b1e..9b2183c 100644 --- a/test/unit/mocked_data/test_get_interfaces/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces/SG550X-24MP-K9/expected_result.json @@ -215,7 +215,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/1" : { + "TenGigabitEthernet1/0/1" : { "description" : "SW switch-c", "is_enabled" : true, "is_up" : true, @@ -224,7 +224,7 @@ "mtu" : 9000, "speed" : 1000 }, - "TengigabitEthernet1/0/2" : { + "TenGigabitEthernet1/0/2" : { "description" : "", "is_enabled" : false, "is_up" : false, @@ -233,7 +233,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/3" : { + "TenGigabitEthernet1/0/3" : { "description" : "", "is_enabled" : false, "is_up" : false, @@ -242,7 +242,7 @@ "mtu" : 9000, "speed" : 0 }, - "TengigabitEthernet1/0/4" : { + "TenGigabitEthernet1/0/4" : { "description" : "SW switch-c", "is_enabled" : true, "is_up" : true, diff --git a/test/unit/mocked_data/test_get_interfaces_ip/CBS350-24P-4G/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/CBS350-24P-4G/expected_result.json index b23d0ea..313b531 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/CBS350-24P-4G/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/CBS350-24P-4G/expected_result.json @@ -1,4 +1,4 @@ { - "vlan 10" : { "ipv4" : { "10.1.2.2" : { "prefix_length" : 24 } } }, - "vlan 80" : { "ipv4" : { "10.0.0.150" : { "prefix_length" : 24 } } } + "VLAN10" : { "ipv4" : { "10.1.2.2" : { "prefix_length" : 24 } } }, + "VLAN80" : { "ipv4" : { "10.0.0.150" : { "prefix_length" : 24 } } } } diff --git a/test/unit/mocked_data/test_get_interfaces_ip/SG300-10/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/SG300-10/expected_result.json index 143a01d..a6f4009 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/SG300-10/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/SG300-10/expected_result.json @@ -1 +1 @@ -{ "vlan 1" : { "ipv4" : { "192.168.1.254" : { "prefix_length" : 24 } } } } +{ "VLAN1" : { "ipv4" : { "192.168.1.254" : { "prefix_length" : 24 } } } } diff --git a/test/unit/mocked_data/test_get_interfaces_ip/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/SG350X-48P-K9/expected_result.json index 49ac0f8..acedffa 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/SG350X-48P-K9/expected_result.json @@ -1,4 +1,4 @@ { - "vlan 1" : { "ipv4" : { "198.51.100.2" : { "prefix_length" : 24 } } }, - "vlan 852" : { "ipv4" : { "198.51.100.1" : { "prefix_length" : 16 } } } + "VLAN1" : { "ipv4" : { "198.51.100.2" : { "prefix_length" : 24 } } }, + "VLAN852" : { "ipv4" : { "198.51.100.1" : { "prefix_length" : 16 } } } } diff --git a/test/unit/mocked_data/test_get_interfaces_ip/SG500-28-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/SG500-28-K9/expected_result.json index 0d90d50..2e58fc6 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/SG500-28-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/SG500-28-K9/expected_result.json @@ -1 +1 @@ -{"vlan 202": {"ipv4": {"10.0.3.5": {"prefix_length": 8}}}} +{"VLAN202": {"ipv4": {"10.0.3.5": {"prefix_length": 8}}}} diff --git a/test/unit/mocked_data/test_get_interfaces_ip/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/SG550X-24MP-K9/expected_result.json index 2365906..6087495 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/SG550X-24MP-K9/expected_result.json @@ -1 +1 @@ -{"vlan 1": {"ipv4": {"192.168.0.37": {"prefix_length": 17}}}} +{"VLAN1": {"ipv4": {"192.168.0.37": {"prefix_length": 17}}}} diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9-long_systemname/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9-long_systemname/expected_result.json index 5c5e42f..dfd4570 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9-long_systemname/expected_result.json +++ b/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9-long_systemname/expected_result.json @@ -7,15 +7,15 @@ "hostname" : "", "port" : "34:e6:aa:ff:53:a8" } ], - "TengigabitEthernet1/0/1" : [ { + "TenGigabitEthernet1/0/1" : [ { "hostname" : "swzdsadas-vedc", "port" : "Gi0/23" } ], - "TengigabitEthernet1/0/3" : [ { + "TenGigabitEthernet1/0/3" : [ { "hostname" : "sw1dsafdsfsdf.example.net", "port" : "gi28" } ], - "TengigabitEthernet1/0/4" : [ { + "TenGigabitEthernet1/0/4" : [ { "hostname" : "sw2dsdfssddfd", "port" : "te1/0/4" } ] diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9/expected_result.json index 9ada696..e2e7a51 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_lldp_neighbors/SG350X-48P-K9/expected_result.json @@ -7,15 +7,15 @@ "hostname" : "", "port" : "34:e6:aa:ff:53:a8" } ], - "TengigabitEthernet1/0/1" : [ { + "TenGigabitEthernet1/0/1" : [ { "hostname" : "swzdsadas-vedc", "port" : "Gi0/23" } ], - "TengigabitEthernet1/0/3" : [ { + "TenGigabitEthernet1/0/3" : [ { "hostname" : "sw1dsafdsfsdfsdd", "port" : "gi28" } ], - "TengigabitEthernet1/0/4" : [ { + "TenGigabitEthernet1/0/4" : [ { "hostname" : "sw2dsdfssddfd", "port" : "te1/0/4" } ] diff --git a/test/unit/mocked_data/test_get_lldp_neighbors/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors/SG550X-24MP-K9/expected_result.json index 49eeff4..6ff024c 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_lldp_neighbors/SG550X-24MP-K9/expected_result.json @@ -15,11 +15,11 @@ "hostname" : "ab:48:ef:12:34:56", "port" : "ab:48:ef:12:34:56" } ], - "TengigabitEthernet1/0/1" : [ { + "TenGigabitEthernet1/0/1" : [ { "hostname" : "switch-c", "port" : "gi1/0/1" } ], - "TengigabitEthernet1/0/4" : [ { + "TenGigabitEthernet1/0/4" : [ { "hostname" : "switch-c.cb.madeta.cz", "port" : "Gi1/0/26" } ] diff --git a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/expected_result.json b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/expected_result.json index b93c77f..d747de0 100644 --- a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/expected_result.json +++ b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/expected_result.json @@ -1,4 +1,4 @@ -{ "TengigabitEthernet1/0/4" : [ { +{ "TenGigabitEthernet1/0/4" : [ { "parent_interface" : "N/A", "remote_chassis_id" : "ab:a5:ef:12:34:56", "remote_port" : "GigabitEthernet1/0/26", diff --git a/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/show_lldp_neighbors_TengigabitEthernet1_0_4.txt b/test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/show_lldp_neighbors_TenGigabitEthernet1_0_4.txt similarity index 100% rename from test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/show_lldp_neighbors_TengigabitEthernet1_0_4.txt rename to test/unit/mocked_data/test_get_lldp_neighbors_detail/SG550X-24MP-K9/show_lldp_neighbors_TenGigabitEthernet1_0_4.txt From 1efdaaf26b7fd19312c217c5d8784ddbb39aa247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Fri, 5 Apr 2024 08:00:16 +0200 Subject: [PATCH 3/6] move version to 0.4.1.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 04c0f6b..e6b0ba0 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-s350", - version="0.4.1", + version="0.4.1.1", packages=find_packages(exclude=("test*",)), author="Jasper Lievisse Adriaanse, Petr Klíma, Daniel Bacher", author_email="j@jasper.la, qaxi@seznam.cz, mail@phill93.de", From d76fa4cd46aa3a87b659553da7c9bce5c7c91924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Mon, 22 Apr 2024 16:08:58 +0200 Subject: [PATCH 4/6] Make it napalm 5 compliant (#92) * use netmiko_args * Add changes for 4.1.0 (#89) * Update requirements.txt * Typpo in requirements * _send_command has only two parameters * Adapt to stricter Unit tests --------- Co-authored-by: Anton Gridnev * Remove s350_base_interfaces custom map - it is allready in napalm base * Adapt Unit tests to canonical_interface_name() * Add format parameter to get_config() * Add badges --------- Co-authored-by: Dave Co-authored-by: Anton Gridnev --- README.md | 7 ++++--- napalm_s350/s350.py | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 760050b..446614b 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,12 @@ NAPALM driver for Cisco SMB switches (SF3xx, SF5xx, SG3xx, SG5xx, CBS35x). ## Status -Master: ![Build](https://github.com/napalm-automation-community/napalm-s350/workflows/Test%20before%20push/badge.svg?branch=master&event=push) -Develop: ![Build](https://github.com/napalm-automation-community/napalm-s350/workflows/Test%20before%20push/badge.svg?branch=develop&event=push) +Master: [![Thorough Test](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/ThoroughTest.yml/badge.svg?branch=master)](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/ThoroughTest.yml) -PyPi: [![Upload](https://github.com/napalm-automation-community/napalm-s350/workflows/Upload%20Python%20Package%20to%20PyPi.org/badge.svg)](https://github.com/napalm-automation-community/napalm-s350/actions?query=workflow%3A%22Upload+Python+Package+to+PyPi.org%22) +Develop: [![Thorough Test](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/ThoroughTest.yml/badge.svg?branch=develop)](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/ThoroughTest.yml) + +PyPi.org: [![Publish To PyPi.org](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/PublishToPIP.yml/badge.svg?branch=master)](https://github.com/napalm-automation-community/napalm-s350/actions/workflows/PublishToPIP.yml) ## Requirements diff --git a/napalm_s350/s350.py b/napalm_s350/s350.py index 9da78d9..59d9f3b 100644 --- a/napalm_s350/s350.py +++ b/napalm_s350/s350.py @@ -157,7 +157,13 @@ def get_arp_table(self, vrf=""): return arp_table - def get_config(self, retrieve="all", full=False, sanitized=False): + def get_config( + self, + retrieve="all", + full=False, + sanitized=False, + format: str = "text", + ): """ get_config for S350. Since this firmware doesn't support a candidate configuration we leave it empty. From 8e732622619c3ef27031c43fc77015d0e93cb7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Mon, 22 Apr 2024 16:09:50 +0200 Subject: [PATCH 5/6] move version to 5.0.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e6b0ba0..1a40ce8 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-s350", - version="0.4.1.1", + version="0.5.0.0", packages=find_packages(exclude=("test*",)), author="Jasper Lievisse Adriaanse, Petr Klíma, Daniel Bacher", author_email="j@jasper.la, qaxi@seznam.cz, mail@phill93.de", From e43b99aae9c45aecaf078235c17a9af43be2d4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kl=C3=ADma?= Date: Mon, 22 Apr 2024 16:11:43 +0200 Subject: [PATCH 6/6] move to version 0.5.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1a40ce8..36f676c 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="napalm-s350", - version="0.5.0.0", + version="0.5.0", packages=find_packages(exclude=("test*",)), author="Jasper Lievisse Adriaanse, Petr Klíma, Daniel Bacher", author_email="j@jasper.la, qaxi@seznam.cz, mail@phill93.de",