fix(driver): load_replace_candidate is None, not a stub that raises (NetOrk/netork#2503) #17
No files matched your search
@@ -7,6 +7,10 @@ All notable changes to this driver. The format follows
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
- `load_replace_candidate` is `None` instead of a method that raises
|
||||
`NotImplementedError`, so a caller that asks whether the driver can replace a
|
||||
configuration gets no. netOrk offered a config restore for these devices that
|
||||
could only fail (NetOrk/netork#2503).
|
||||
- **Breaking:** `get_playback_state()` and `get_zone_info()` return the shapes of
|
||||
napalm-device-types' media contract. `get_playback_state()` is
|
||||
`{"state": "playing"|"paused"|"stopped"|"transitioning", "source": "radio"|…}`
|
||||
|
||||
@@ -46,8 +46,8 @@ speaker's connection, whatever its medium.
|
||||
|
||||
## Not supported
|
||||
|
||||
Configuration management (`load_replace_candidate` and `load_merge_candidate` raise
|
||||
`NotImplementedError`), configuration export (`get_config`), the CLI (`cli`, NAPALM's
|
||||
Configuration management (`load_replace_candidate` is `None`, `load_merge_candidate`
|
||||
raises `NotImplementedError`), configuration export (`get_config`), the CLI (`cli`, NAPALM's
|
||||
stub), the interface addresses (`get_interfaces_ip`: the speaker reports no prefix
|
||||
length, and SoCo has no reading for one), 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,
|
||||
|
||||
@@ -191,9 +191,9 @@ class SonosDriver(MediaDriver):
|
||||
"""Discard the candidate config (no-op on Sonos)."""
|
||||
pass
|
||||
|
||||
def load_replace_candidate(self, filename: str = "", config: str = "") -> None:
|
||||
"""Load a replacement config (not supported on Sonos)."""
|
||||
raise NotImplementedError("Sonos does not support config replacement")
|
||||
#: No config replace: switched off rather than a stub that raises, so asking
|
||||
#: whether the driver has one says no (NetOrk/netork#2503).
|
||||
load_replace_candidate = None # type: ignore[assignment]
|
||||
|
||||
def load_merge_candidate(self, filename: str = "", config: str = "") -> None:
|
||||
"""Load a merge candidate (not supported on Sonos)."""
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
"""The driver cannot replace a device's configuration, and says so by not having the method.
|
||||
|
||||
A ``load_replace_candidate`` that only raises looks like a replace to anyone who asks
|
||||
whether the driver has one: netOrk offered a config restore for these devices that
|
||||
could only fail (NetOrk/netork#2503). ``None`` is how a driver switches off a method
|
||||
it would otherwise inherit, the convention of napalm-device-types and netOrk's
|
||||
capability checks.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from napalm_sonos import SonosDriver
|
||||
|
||||
|
||||
def test_the_driver_has_no_config_replace():
|
||||
assert SonosDriver.load_replace_candidate is None
|
||||
assert not callable(getattr(SonosDriver, "load_replace_candidate", None))
|
||||
Reference in new issue
Block a user