get_firmware_offer() looks the device's release line up in the attended
sysupgrade server's overview.json, fetched at most once a day per server.
start_firmware_upgrade() runs owut upgrade detached from the session, and
get_update_progress() follows its log until owut hands the image to sysupgrade.
An access point runs no container engine. configure_zabbix_agent(settings)
installs zabbix-agentd from the feed after loading the package index, writes the
caller's values into /etc/zabbix_agentd.conf (the old file stays as .bak),
enables the agent in UCI, without which its init script does not start it, and
opens tcp/ListenPort for the allowed sources in the zone that owns the
management address where a firewall runs. Zabbix publishes no repository for
OpenWrt; the feed is the only source.
The SNMP agent's firewall step writes its rule through _allow_in_management_zone
now, split into the zone, the rule and the reload; the rule is the same.
Needs napalm-device-types 4.40.0.
After a reboot apk and opkg have no package index. get_available_updates()
raised a bare RuntimeError for that, which netOrk could not tell from a
read that failed. It now raises napalm-device-types' PackageIndexMissing,
so netOrk loads the index instead of reporting a communication error.
Needs napalm-device-types 4.39.0.
Refs NetOrk/netork#2527
A replace commit_config() and rollback() wrote the config as root to a
fixed name in /tmp (/tmp/napalm_candidate.uci, /tmp/napalm_rollback.uci)
and imported it with a second command. A local account could place that
file beforehand, or swap it in between, and have its own config imported
and committed (NetOrk/netork#2446).
Each import is now one command: a mktemp file made under umask 077, the
config written to it, `uci import < "$f" && uci commit`, then the file
removed.
The name stood between single quotes of its own in
`uci set system.@system[0].hostname='<name>'`, so a name with a single
quote ended them and the rest ran as root (NetOrk/netork#2456). The
command is now built with uci_steps.uci(), which quotes each word with
shlex.
Fixtures, docstring examples and the README use neutral host names
(ap-01, ap-02) and addresses from the documentation ranges 192.0.2.0/24,
198.51.100.0/24 and 203.0.113.0/24, mapped one to one so every test
keeps its meaning: the management network test still has its address
inside that network, a route still covers its prefix. Loopback, the
wildcard address and netmasks are unchanged.
push_mac_acl wrote macfilter='allow' for "whitelist" and 'deny' for any
other mode but "off", so a mode the driver does not know -- a typo, or a
new mode from the caller -- became a deny list. It now raises ValueError
naming the mode before the first command is sent.
Closes#39
push_mac_acl and push_radio_channel sent each step through the
interactive shell and never looked at the result: a refused uci set,
add_list, commit or wifi reload passed silently, an SSID no wifi-iface
carried did nothing, and wifi was restarted after a refused channel.
Each step now runs on an SSH exec channel of its own, as root, with its
exit status checked (uci_steps.UciStepsMixin). A refused step raises
CommandErrorException naming the command and what the router said; a
refusal before the commit reverts what was staged, so a later commit
does not apply half of it, and wifi is not restarted. push_mac_acl
reads the sections once, raises when none carries the SSID, and deletes
macfilter/maclist only where a section has them instead of hiding each
delete's status behind `|| true`.
Closes#35
DHCP option 42 counts (NetOrk/netork#2380): a router that gets the
site's time giver from its lease is aligned. The first time sync commit
set use_dhcp=0 on every write, which cut a router off from the giver its
DHCP server hands out.
A write now leaves use_dhcp as the router has it, and the "already has
these servers" check no longer rewrites a router only because use_dhcp
is on. get_time_sync() reads what sysntpd adds to ntpd's list while
use_dhcp is on -- each interface's data.ntpserver in ubus call
network.interface dump, which /lib/netifd/dhcp.script fills from
udhcpc's ntpsrv, only the dhcp_interface list's where it names any -- in
the same round trip as uci, into dhcp_ntp_servers: [] while use_dhcp or
the client is off, None where netifd gives no answer.
Needs napalm-device-types 4.36.0 (TimeSyncDict.dhcp_ntp_servers).
netOrk aligns every device's time sources and zone through the driver
(NetOrk/netork#2360); for APs that replaces the UCI commands netOrk
built itself for the AP profile fields (NetOrk/netork#2364).
Both values live in UCI's system config:
- The servers are system.ntp.server. A write replaces the list, enables
the client, sets use_dhcp=0 so the servers of a DHCP lease are not
added, and restarts sysntpd: the router ends up with exactly these.
A disabled client reads as no servers.
- The zone is zonename (the IANA name, in LuCI's spelling with spaces)
and timezone, the POSIX rule from posix_tz that libc reads as TZ. The
rule is what counts (NetOrk/netork#1849), so the name is read as the
zone only where the rule in force is that zone's; a rule alone reads
as the one zone that has it, or None where several share it. A write
sets both, reloads /etc/init.d/system and restarts logd, which reads
the zone at start.
netOrk aligns on every poll, so each step compares first and writes
and restarts nothing when the router already has the values. GMT0 (the
stock rule) counts as UTC's time.
get_ntp_servers now uses the same reading, so it agrees with
get_time_sync; it used to keep only the first server of a list, as uci
prints a list as 'a' 'b' on one line. synchronized is None: BusyBox
ntpd keeps no state to read.
The floor on napalm-device-types is 4.35.0, the first with
TimeSyncMixin.
The router's host status, read by napalm-device-types' command over an
SSH exec channel: whether it needs a reboot, how full its filesystems
are, and, with napalm-device-types 4.32, whether apk or opkg was left
halfway.
Refs NetOrk/netork#851
get_scheduled_jobs reads every crontab in /etc/crontabs in one round trip
as root, with the time zone from UCI and each crontab's package from opkg;
manage_scheduled_job enables, disables or runs one now; put_ and
delete_scheduled_job write and remove an application's own job as marked
lines in the user's crontab. BusyBox crond has no /etc/crontab, cron.d,
run-parts, anacron or systemd, so none is read.
OpenWrt's BusyBox differs from what the POSIX mixin assumes, so a few
steps are the driver's own:
- crontab -l says only "can't open" for a missing crontab, as for an
unreadable one: the file is read directly, a missing one is empty, and
one that cannot be read is never written.
- crontab FILE exits 0 when it could not write: every write is read back.
- cron is enabled and restarted after each write; OpenWrt does not start
crond while /etc/crontabs is empty.
- crond has no special times: aliases are written as five fields and
@reboot is refused.
- crond hands the whole command to sh and takes only SHELL and PATH from
the crontab, so a run now does the same (% is no stdin).
- there is no su and no timeout before 25.x: another user's job runs
through start-stop-daemon -c, and the run is bounded by timeout only
where the router has it.
Every write changes only the job's own line, so the reboot failback line
in /etc/crontabs/root stays as it is.
Requires napalm-device-types 4.26.0.
Closes#32
lldpd tells the chassis MAC, but get_lldp_neighbors reported only name
and port, so netOrk, which matches a neighbour by MAC first, could match
OpenWrt's neighbours by name only. napalm-device-types' lldp_neighbors
projection now carries mac (lower case) when the chassis id is a MAC
address, as napalm-linux reports it.
Closes#31
lldpctl's error text has no "=", so a missing lldpctl or a stopped
lldpd read as a device without neighbours. lldpctl now runs as
napalm-device-types' LLDPCTL_KEYVALUE_COMMAND, which brings its exit
status and message back, and the shared parser raises on a failure.
get_environment swallowed an unreadable /proc/stat or /proc/meminfo
and reported 0 % CPU and 0 bytes of memory, a plausible value instead
of a failure. Both now raise ValueError; 0 % stays for counters that
did not move between the two reads.
Closes#27
The local interface was the second dotted part of the key, so the
neighbours of eth0.1 landed under eth0 with every field missed. The
remote port was read from port.ifname or port.id.value, and lldpd
prints a port given by MAC or local id as port.mac / port.local, never
as id.value, so that port came back empty.
lldpd's output now goes through napalm-device-types'
parse_lldpctl_keyvalue and its two NAPALM projections, which keep the
interface name up to the neighbour's first field and read the ids under
whatever type lldpd prints. The detail gains the system description and
capabilities on the way. The module is under strict mypy now; the floor
on napalm-device-types rises to 4.24.0.
Closes#26
install_package and uninstall_package searched the output for keywords.
opkg's dependency failure ("Collected errors:") contains none of them and
read as success; a successful install naming a "failed" file read as a
failure. Append the exit-status marker and let the status alone decide.
Closes#28
The LLDP getters started lldpd and rewrote its interface list on every
poll; with read-only getters that setup needs an action. The driver
mixes in napalm-device-types' LldpAgentMixin and writes the step the
template leaves to it: lldpd.config.interface in UCI. A VLAN device is
written as the device under it, as the old helper did, since lldpd
sends on the L2 device. Which interfaces is the caller's choice.
Refs #8
get_lldp_neighbors, which a poll calls every time, enabled and started a
stopped lldpd and rewrote lldpd's interface list with uci, restarting
the daemon. A getter must not change the device. Both LLDP getters now
only run lldpctl; installing and starting lldpd are ensure_package and
manage_service.
Closes#8
The keyvalue output was grouped by local interface only, so with several
neighbours on one port their keys overwrote each other and one mixed
entry came back. A neighbour now ends where the next one opens (alias,
then via, as lldpd prints it); a key repeated inside one neighbour, such
as one mgmt-ip per address, does not start a new one.
Closes#9
get_environment promised two samples one second apart but read
/proc/stat once, so the figure was the average since boot: a box at
100 % for the last minute showed its lifetime average. It now reads the
cpu line twice, a second apart, and uses the difference.
Closes#10
apply_updates ran apk/opkg upgrade and returned success whatever
happened, so a failed upgrade was reported as done. The command now
prints its exit status after the marker get_available_updates already
uses; a non-zero or missing status is a failure, named in "error".
Closes#11
manage_service returned success for every action, so a failed start or
a missing init script showed up as done. The command now prints its
exit status after a marker, and only that status decides.
Closes#3