feat(access-point): SSID settings, radio channels, VLAN names, the AP configuration and DHCP leases through declared methods (NetOrk/netork#695)
push_ssid_config, set_radio_channels and set_vlan_name run as checked uci steps (#35): a refused step raises naming itself and reverts what was staged. set_radio_channels replaces the undeclared push_radio_channel. apply_ap_config takes napalm-device-types' ApConfigDict and the parts the caller found different and writes them as one detached script: the builder netOrk had in _uci_builders.py, moved here. It answers which parts it wrote and which it could not, whether the AP restarts, and the script with every passphrase masked. A passphrase part now writes the key. get_dhcp_leases reads dnsmasq's lease file. Needs napalm-device-types 4.54.0; CI pre-installs it from its branch until it is on PyPI.
This commit is contained in:
1 parent
dd3e3f1543
commit
634bc9c793
18 files changed
+2108
-40
No files matched your search
@@ -27,8 +27,6 @@ _WIRELESS = "wireless"
|
||||
_SHOW_WIRELESS = "uci -q show wireless"
|
||||
#: Re-applies the config; enough for a MAC filter.
|
||||
_WIFI_RELOAD = "wifi reload"
|
||||
#: A full down/up of every radio; a channel needs it (see ``push_radio_channel``).
|
||||
_WIFI_RESTART = "wifi"
|
||||
_ACL_OPTIONS = ("macfilter", "maclist")
|
||||
#: The modes ``push_mac_acl`` takes, and the ``macfilter`` each writes ("off" writes none).
|
||||
_MACFILTER_BY_MODE = {"whitelist": "allow", "blacklist": "deny", "off": None}
|
||||
@@ -641,26 +639,6 @@ class OpenWrtWirelessMixin(UciStepsMixin):
|
||||
_flush()
|
||||
return entries
|
||||
|
||||
def push_radio_channel(self, radio: str, channel: int) -> None:
|
||||
"""Set a new channel on *radio* via UCI and restart the wireless stack.
|
||||
|
||||
Uses ``wifi`` (full down/up cycle) rather than ``wifi reload``.
|
||||
``wifi reload`` only re-applies the running config without changing
|
||||
the physical channel on many hardware/driver combinations; a full
|
||||
restart is required for channel changes to take effect.
|
||||
|
||||
Each step's exit status is checked (:mod:`napalm_openwrt.uci_steps`): a
|
||||
refused ``uci set`` (a radio that does not exist) raises, and wifi is not
|
||||
restarted for it.
|
||||
|
||||
:param radio: UCI radio name, e.g. ``"radio0"``.
|
||||
:param channel: Channel number to set; ``0`` sets UCI ``auto``.
|
||||
:raises CommandErrorException: when a step is refused, naming it.
|
||||
"""
|
||||
ch_val = "auto" if channel == 0 else str(channel)
|
||||
change = uci("set", f"{_WIRELESS}.{radio}.channel={ch_val}")
|
||||
self._uci_apply(_WIRELESS, [change], _WIFI_RESTART)
|
||||
|
||||
def push_mac_acl(self, ssid_name: str, mode: str, macs: list[str]) -> None:
|
||||
"""Rewrite macfilter mode + maclist entries on every wifi-iface matching *ssid_name*.
|
||||
|
||||
|
||||
Reference in new issue
Block a user