Merge remote-tracking branch 'origin/main' into fix/lldp-keyvalue
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 20s
driver / types (pull_request) Successful in 1m8s
driver / test (3.13) (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m3s
CI / driver (pull_request) Successful in 2m21s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 20s
driver / types (pull_request) Successful in 1m8s
driver / test (3.13) (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m3s
CI / driver (pull_request) Successful in 2m21s
driver / publish (pull_request) Skipped
# Conflicts: # CHANGELOG.md # tests/quality_baseline.json
This commit is contained in:
commit
c7317925ed
8 files changed
+614
-40
No files matched your search
+18
-22
@@ -78,9 +78,9 @@ from netmiko.exceptions import NetmikoAuthenticationException, NetmikoTimeoutExc
|
||||
from napalm_linux._dpkg import DPKG_QUERY_COMMAND, parse_dpkg_query
|
||||
from napalm_linux._hostname import HostnameMixin
|
||||
from napalm_linux._local_accounts import LinuxLocalAccountsMixin
|
||||
from napalm_linux._ping import parse_ping
|
||||
from napalm_linux._routes import IP_ROUTE_COMMANDS, parse_ip_route
|
||||
from napalm_linux._shell import expect_for, prepare_shell
|
||||
from napalm_linux._ping import parse_ping, ping_command
|
||||
from napalm_linux._routes import IP_ROUTE_COMMANDS, IpRoute, parse_ip_route, with_length
|
||||
from napalm_linux._shell import expect_for, prepare_shell, sudo_without_password
|
||||
from napalm_linux._sudo_history import LinuxSudoHistoryMixin
|
||||
|
||||
logger = logging.getLogger("napalm_linux")
|
||||
@@ -519,14 +519,14 @@ class LinuxDriver(
|
||||
return self._run_privileged(command, timeout)
|
||||
|
||||
def _run_privileged(self, command: str, timeout: float = 100) -> str:
|
||||
"""Run *command* as root: directly for a root login, through ``_sudo``
|
||||
with a sudo password, and through ``sudo -n`` without one -- which fails at
|
||||
once where a password prompt would hang the session until the timeout."""
|
||||
"""Run all of *command* as root: directly for a root login, through ``_sudo``
|
||||
with a sudo password, and through ``sudo -n sh -c`` without one -- which fails
|
||||
at once where a password prompt would hang the session until the timeout."""
|
||||
if self._is_root():
|
||||
return self._send(command, read_timeout=timeout)
|
||||
if self._sudo_password:
|
||||
return self._sudo(command, read_timeout=timeout) # never typed into the shell
|
||||
return self._send(f"sudo -n {command}", read_timeout=timeout)
|
||||
return self._send(sudo_without_password(command), read_timeout=timeout)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Command channel (napalm-device-types CommandChannelMixin)
|
||||
@@ -913,7 +913,7 @@ class LinuxDriver(
|
||||
def _make_entry(
|
||||
proto: str, nexthop: str, iface: str, metric: int, network: str
|
||||
) -> dict[str, Any]:
|
||||
family = "ipv6" if (":" in network or (nexthop and ":" in nexthop)) else "ipv4"
|
||||
family = "ipv6" if ":" in network else "ipv4" # not the next hop's (#65)
|
||||
return {
|
||||
"protocol": proto,
|
||||
"family": family,
|
||||
@@ -928,19 +928,19 @@ class LinuxDriver(
|
||||
"protocol_attributes": {},
|
||||
}
|
||||
|
||||
def _add(network: str, proto: str, nexthop: str, iface: str, metric: int) -> None:
|
||||
if destination and network != destination:
|
||||
def _add(route: IpRoute) -> None:
|
||||
if destination and route.network != destination:
|
||||
return
|
||||
mapped = proto_map.get(proto, proto)
|
||||
mapped = proto_map.get(route.proto, route.proto)
|
||||
if protocol and mapped != protocol.lower():
|
||||
return
|
||||
routes.setdefault(network, []).append(
|
||||
_make_entry(mapped, nexthop, iface, metric, network)
|
||||
)
|
||||
entry = _make_entry(mapped, route.nexthop, route.iface, route.metric, route.network)
|
||||
entry["protocol_attributes"] = route.attributes
|
||||
routes.setdefault(route.network, []).append(entry)
|
||||
|
||||
for family, command in IP_ROUTE_COMMANDS.items():
|
||||
for route in parse_ip_route(self._send(command), family):
|
||||
_add(*route)
|
||||
_add(route)
|
||||
|
||||
# FRR/Zebra enrichment via vtysh — properly attributes OSPF/BGP/RIP protocols.
|
||||
# FRR installs routes into the kernel as "proto zebra"; vtysh gives the real source.
|
||||
@@ -969,12 +969,10 @@ class LinuxDriver(
|
||||
if not vm:
|
||||
continue
|
||||
code = vm.group(1)
|
||||
prefix = vm.group(2)
|
||||
prefix = with_length(vm.group(2))
|
||||
metric = int(vm.group(4))
|
||||
nexthop = vm.group(5) or ""
|
||||
iface = (vm.group(6) or "").rstrip(",")
|
||||
if "/" not in prefix:
|
||||
prefix += "/32"
|
||||
mapped_proto = _frr_code.get(code, code.lower())
|
||||
if prefix in routes:
|
||||
for entry in routes[prefix]:
|
||||
@@ -1066,10 +1064,8 @@ class LinuxDriver(
|
||||
count: int = 5,
|
||||
vrf: str = "",
|
||||
) -> dict[str, Any]:
|
||||
"""Execute ping from the remote host."""
|
||||
src_opt = f"-I {source}" if source else ""
|
||||
cmd = f"ping -c {count} -W {timeout} -s {size} -t {ttl} {src_opt} {destination} 2>&1"
|
||||
return parse_ping(self._send(cmd))
|
||||
"""Ping from the remote host; ValueError for a bad number or a name starting with -."""
|
||||
return parse_ping(self._send(ping_command(destination, source, ttl, timeout, size, count)))
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# KernelFactsMixin – the transport for get_kernel_facts
|
||||
|
||||
Reference in new issue
Block a user