feat(access-point): a radio's runtime state beside its configuration (NetOrk/netork#31)

RadioStatusDict carries up, pending and setup_failed, each optional: a
driver that cannot read the state leaves them out. A radio can be enabled
and not run, as on 2026-07-16, when a rejected value kept every radio of
a fleet in a restart loop the configuration never showed.

The access point shapes move to access_point_models.py for the file size
ratchet; models re-exports each where it was.
This commit is contained in:
christianmanivong committed 2026-11-28 03:02:13 +01:00
1 parent 419d3ee0e0
commit e4fde2283a
5 files changed
+166 -97

No files matched your search

+115
View File
@@ -0,0 +1,115 @@
"""The shapes an access point's getters return (models.py's Access Point part).
Apart from ``models.py`` for its size; ``models`` re-exports each, so
``napalm_device_types.models.RadioStatusDict`` stays where callers import it.
"""
from typing import NotRequired
from typing_extensions import TypedDict
class WirelessClientDict(TypedDict):
mac: str
ssid: str
radio: str
signal: int
noise: int
tx_rate: float
rx_rate: float
uptime: int
# Optional fields populated by DHCP cross-reference (e.g. from firewall)
ip: NotRequired[str]
hostname: NotRequired[str]
lease_end: NotRequired[int] # Unix timestamp when DHCP lease expires
class SSIDDict(TypedDict):
enabled: bool
radio: str
bssid: str
encryption: str
hidden: bool
clients: int
class RadioStatusDict(TypedDict):
"""One radio: ``enabled`` is the configuration, the rest what the radio does.
The runtime state is left out where the driver cannot read it, never guessed
(NetOrk/netork#31): ``up`` whether the radio runs, ``pending`` whether the
device is still bringing it up or down, ``setup_failed`` whether the device
gave up bringing it up after its retries.
"""
enabled: bool
band: str
channel: int
channel_width: int
tx_power: int
frequency: float
up: NotRequired[bool]
pending: NotRequired[bool]
setup_failed: NotRequired[bool]
class ChannelScanEntryDict(TypedDict):
"""One neighboring AP entry as returned by get_channel_scan()."""
bssid: str
ssid: str
frequency: int # centre frequency in MHz, e.g. 2437
channel: int # channel number, e.g. 6
signal_dbm: int # RSSI in dBm, e.g. -72
channel_width: int # MHz: 20 / 40 / 80 / 160; 0 if unknown
band: str # "2.4GHz" | "5GHz" | "6GHz"
class WirelessConfigDict(TypedDict):
country_code: str
regulatory_domain: str
beacon_interval: int
dtim_period: int
rts_threshold: int
fragmentation_threshold: int
short_preamble: bool
wmm_enabled: bool
class FastTransitionConfigDict(TypedDict):
enabled: bool
ssid: str
mobility_domain: str
reassociation_deadline: int
r0_key_lifetime: int
r1_key_holder: str
pmk_r1_push: bool
over_ds: bool
class MeshPeerDict(TypedDict):
mac: str
radio: str
signal: int
tx_rate: float
rx_rate: float
uptime: int
hop_count: int
class MeshConfigDict(TypedDict):
enabled: bool
radio: str
mesh_id: str
path_metric: str
gate_announcements: bool
is_gate: bool
encryption: str
class SSIDBridgeDict(TypedDict):
ssid: str
bridge: str
vlan_id: int
tagged: bool
client_isolation: bool
+13 -96
View File
@@ -8,7 +8,19 @@ from typing import Literal, NotRequired, get_args
from typing_extensions import TypedDict
# The SNMP health profile shapes live in snmp_health_profile.py; re-exported here, where they were.
# The SNMP health profile shapes live in snmp_health_profile.py, those of the access
# point getters in access_point_models.py; re-exported here, where they were.
from napalm_device_types.access_point_models import ChannelScanEntryDict as ChannelScanEntryDict
from napalm_device_types.access_point_models import (
FastTransitionConfigDict as FastTransitionConfigDict,
)
from napalm_device_types.access_point_models import MeshConfigDict as MeshConfigDict
from napalm_device_types.access_point_models import MeshPeerDict as MeshPeerDict
from napalm_device_types.access_point_models import RadioStatusDict as RadioStatusDict
from napalm_device_types.access_point_models import SSIDBridgeDict as SSIDBridgeDict
from napalm_device_types.access_point_models import SSIDDict as SSIDDict
from napalm_device_types.access_point_models import WirelessClientDict as WirelessClientDict
from napalm_device_types.access_point_models import WirelessConfigDict as WirelessConfigDict
from napalm_device_types.snmp_health_profile import SnmpHealthProfile as SnmpHealthProfile
from napalm_device_types.snmp_health_profile import SnmpInterfacesSpec as SnmpInterfacesSpec
from napalm_device_types.snmp_health_profile import SnmpMemorySpec as SnmpMemorySpec
@@ -130,101 +142,6 @@ class HostStatusDict(TypedDict):
# ---------------------------------------------------------------------------
class WirelessClientDict(TypedDict):
mac: str
ssid: str
radio: str
signal: int
noise: int
tx_rate: float
rx_rate: float
uptime: int
# Optional fields populated by DHCP cross-reference (e.g. from firewall)
ip: NotRequired[str]
hostname: NotRequired[str]
lease_end: NotRequired[int] # Unix timestamp when DHCP lease expires
class SSIDDict(TypedDict):
enabled: bool
radio: str
bssid: str
encryption: str
hidden: bool
clients: int
class RadioStatusDict(TypedDict):
enabled: bool
band: str
channel: int
channel_width: int
tx_power: int
frequency: float
class ChannelScanEntryDict(TypedDict):
"""One neighboring AP entry as returned by get_channel_scan()."""
bssid: str
ssid: str
frequency: int # centre frequency in MHz, e.g. 2437
channel: int # channel number, e.g. 6
signal_dbm: int # RSSI in dBm, e.g. -72
channel_width: int # MHz: 20 / 40 / 80 / 160; 0 if unknown
band: str # "2.4GHz" | "5GHz" | "6GHz"
class WirelessConfigDict(TypedDict):
country_code: str
regulatory_domain: str
beacon_interval: int
dtim_period: int
rts_threshold: int
fragmentation_threshold: int
short_preamble: bool
wmm_enabled: bool
class FastTransitionConfigDict(TypedDict):
enabled: bool
ssid: str
mobility_domain: str
reassociation_deadline: int
r0_key_lifetime: int
r1_key_holder: str
pmk_r1_push: bool
over_ds: bool
class MeshPeerDict(TypedDict):
mac: str
radio: str
signal: int
tx_rate: float
rx_rate: float
uptime: int
hop_count: int
class MeshConfigDict(TypedDict):
enabled: bool
radio: str
mesh_id: str
path_metric: str
gate_announcements: bool
is_gate: bool
encryption: str
class SSIDBridgeDict(TypedDict):
ssid: str
bridge: str
vlan_id: int
tagged: bool
client_isolation: bool
class Dot1XConfigDict(TypedDict):
"""802.1X / WPA-Enterprise config for an access-point SSID."""