fix(driver): leave unsupported getters to NAPALM's stubs
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 17s
driver / types (pull_request) Successful in 1m0s
driver / test (3.13) (pull_request) Successful in 4m13s
driver / test (3.12) (pull_request) Successful in 4m15s
driver / lowest (pull_request) Successful in 3m42s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Successful in 5m38s
driver / publish (pull_request) Skipped

get_config() overrode NAPALM's stub with `return {}` and took no
arguments, so get_config(retrieve="running") raised TypeError, which a
caller reports as a failed configuration backup on every poll. The
other getters a speaker has nothing for (environment, optics, routing,
ARP, MAC table, LLDP, NTP, SNMP, BGP, probes, users, network instances,
firewall policies) had the same shape: an empty answer reads as
"implemented, nothing there", and get_route_to() required an argument
NAPALM defaults.

All of them are gone; NAPALM's stubs raise NotImplementedError.

Closes #13
This commit is contained in:
Christian Manivong committed 2026-11-12 18:54:07 +01:00
1 parent a86fb6cc3e
commit 56e0560eb2
4 files changed
+55 -84

No files matched your search

+7
View File
@@ -19,6 +19,13 @@ All notable changes to this driver. The format follows
on 3.12, so 3.10 and 3.11 are no longer tested (NAPALM/driver-standard#6).
- The floor on napalm is 5.1: older releases import `pkg_resources`, which a Python
3.12 venv no longer has.
- **Breaking:** the NAPALM getters a speaker has nothing for are no longer overridden:
`get_config()`, `get_environment()`, `get_optics()`, the routing, ARP, MAC table, LLDP,
NTP, SNMP, BGP, probe, user, network-instance and firewall-policy getters raise
NAPALM's `NotImplementedError` instead of answering `{}` or `[]`. An empty answer read
as "implemented, nothing there", and `get_config()` and `get_route_to()` did not even
take NAPALM's arguments: `get_config(retrieve="running")` raised `TypeError`, which a
caller reported as a failed configuration backup on every poll (#13).
### Fixed
- `play()`, `pause()`, `stop()`, `next_track()`, `previous_track()`, `set_volume()`
+5 -2
View File
@@ -47,8 +47,11 @@ speaker's connection, whatever its medium.
## Not supported
Configuration management (`load_replace_candidate` and `load_merge_candidate` raise
`NotImplementedError`), the CLI, and every routing, LLDP, ARP, NTP, SNMP, BGP, user
and environment getter: they return empty results.
`NotImplementedError`), configuration export (`get_config`), the CLI, and every
routing, LLDP, ARP, MAC table, NTP, SNMP, BGP, optics, probe, user, network-instance,
firewall-policy and environment getter. The driver leaves those getters to NAPALM,
whose stubs raise `NotImplementedError`: a speaker has no such data, and an empty
answer would read as "read, nothing there".
## Installation
-80
View File
@@ -167,42 +167,6 @@ class SonosDriver(MediaDriver):
}
return {_INTERFACE: {"ipv4": ipv4_entry, "ipv6": {}}}
def get_arp_table(self, vrf: str = "") -> list[dict[str, Any]]:
"""Return the ARP table (not supported on Sonos)."""
return []
def get_lldp_neighbors(self) -> dict[str, Any]:
"""Return LLDP neighbors (not supported on Sonos)."""
return {}
def get_lldp_neighbors_detail(self, interface: str = "") -> dict[str, Any]:
"""Return detailed LLDP neighbors (not supported on Sonos)."""
return {}
def get_config(self) -> dict[str, Any]:
"""Return the device config (not supported on Sonos)."""
return {}
def get_environment(self) -> dict[str, Any]:
"""Return environment/power info (not supported on Sonos)."""
return {}
def get_optics(self) -> dict[str, Any]:
"""Return optics info (not supported on Sonos)."""
return {}
def get_ntp_peers(self) -> dict[str, str | None]:
"""Return NTP peers (not supported on Sonos)."""
return {}
def get_ntp_servers(self) -> dict[str, str | None]:
"""Return NTP servers (not supported on Sonos)."""
return {}
def get_ntp_stats(self) -> list[dict[str, Any]]:
"""Return NTP stats (not supported on Sonos)."""
return []
def ping(
self,
destination: str,
@@ -233,50 +197,6 @@ class SonosDriver(MediaDriver):
"error": "Not supported on Sonos",
}
def get_route_to(self, destination: str) -> list[dict[str, Any]]:
"""Return routing table (not supported on Sonos)."""
return []
def get_snmp_information(self) -> dict[str, Any]:
"""Return SNMP info (not supported on Sonos)."""
return {}
def get_users(self) -> dict[str, Any]:
"""Return user accounts (not supported on Sonos)."""
return {}
def get_network_instances(self, name: str = "") -> dict[str, Any]:
"""Return network instances / VRFs (not supported on Sonos)."""
return {}
def get_bgp_config(self, group: str = "") -> dict[str, Any]:
"""Return BGP config (not supported on Sonos)."""
return {}
def get_bgp_neighbors(self) -> dict[str, Any]:
"""Return BGP neighbors (not supported on Sonos)."""
return {}
def get_bgp_neighbors_detail(self, neighbor_address: str = "") -> dict[str, Any]:
"""Return detailed BGP neighbor info (not supported on Sonos)."""
return {}
def get_probes_config(self) -> dict[str, Any]:
"""Return probe config (not supported on Sonos)."""
return {}
def get_probes_results(self) -> dict[str, Any]:
"""Return probe results (not supported on Sonos)."""
return {}
def get_mac_address_table(self) -> list[dict[str, Any]]:
"""Return MAC address table (not supported on Sonos)."""
return []
def get_firewall_policies(self) -> dict[str, Any]:
"""Return firewall policies (not supported on Sonos)."""
return {}
def cli(self, commands: list[str]) -> list[dict[str, Any]]:
"""Run CLI commands (not supported on Sonos)."""
return []
+43 -2
View File
@@ -4,6 +4,7 @@ import pytest
import requests
import soco
import soco.groups
from napalm.base import NetworkDriver
from napalm.base.exceptions import (
CommandErrorException,
ConnectionClosedException,
@@ -334,8 +335,48 @@ def test_the_driver_module_has_its_docstring():
assert module.__doc__ and "Sonos" in module.__doc__
def test_get_arp_table_takes_napalms_vrf_argument():
assert SonosDriver("192.168.1.100").get_arp_table(vrf="") == []
#: NAPALM getters a speaker has nothing for. Each stays NAPALM's own stub, which raises
#: NotImplementedError: an override answering {} or [] reads as "implemented, nothing
#: there" to a caller that asks whether the driver has its own getter (#13).
_NOT_SUPPORTED_GETTERS = [
"get_arp_table",
"get_bgp_config",
"get_bgp_neighbors",
"get_bgp_neighbors_detail",
"get_config",
"get_environment",
"get_firewall_policies",
"get_lldp_neighbors",
"get_lldp_neighbors_detail",
"get_mac_address_table",
"get_network_instances",
"get_ntp_peers",
"get_ntp_servers",
"get_ntp_stats",
"get_optics",
"get_probes_config",
"get_probes_results",
"get_route_to",
"get_snmp_information",
"get_users",
]
@pytest.mark.parametrize("getter", _NOT_SUPPORTED_GETTERS)
def test_an_unsupported_getter_is_napalms_stub(getter):
assert getattr(SonosDriver, getter) is getattr(NetworkDriver, getter)
def test_get_config_with_napalms_arguments_says_not_implemented():
"""`get_config(retrieve="running")` raised TypeError, read as a failed backup (#13)."""
with pytest.raises(NotImplementedError):
SonosDriver("192.0.2.20").get_config(retrieve="running")
def test_get_route_to_with_napalms_defaults_says_not_implemented():
"""The override required `destination`; NAPALM's getter defaults it (#13)."""
with pytest.raises(NotImplementedError):
SonosDriver("192.0.2.20").get_route_to()
@pytest.mark.parametrize(