Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to napalm 4.1 tests #90

Merged
merged 5 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 10 additions & 41 deletions napalm_s350/s350.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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}}}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
]
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 3 additions & 5 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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}
]
Original file line number Diff line number Diff line change
@@ -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}
]
Original file line number Diff line number Diff line change
@@ -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}
]
Original file line number Diff line number Diff line change
@@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
]
Original file line number Diff line number Diff line change
@@ -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}
]
Original file line number Diff line number Diff line change
@@ -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}
]
Original file line number Diff line number Diff line change
@@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading