feat(firmware): offer the newest release of the line and install it with owut (NetOrk/netork#2615)

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.
This commit is contained in:
Christian Manivong committed 2026-11-17 11:06:32 +01:00
1 parent 6ff893649c
commit 530f04055c
6 files changed
+582 -2

No files matched your search

+23
View File
@@ -71,6 +71,7 @@ device.close()
| `put_scheduled_job(spec)` / `delete_scheduled_job(key, digest=)` | ✅ | an application's own job: two marked lines in the user's crontab; `@daily` and the other aliases as five fields, `@reboot` refused (BusyBox crond has no special times) |
| `get_ntp_servers` / `get_ntp_peers` | ✅ | `system.ntp.server` in UCI, every server of the list; none while `system.ntp.enabled` is off -- the same list as `get_time_sync()` |
| `get_time_sync()` | ✅ | napalm-device-types `TimeSyncMixin`: the servers as above, the zone from `zonename` where the rule in `timezone` is that zone's (else the one zone with that rule, or none); `synchronized` is not readable (None) |
| `get_firmware_offer()` | ✅ | napalm-device-types `FirmwareOfferMixin`: the newest release of the device's own line on the attended sysupgrade server (see *Firmware upgrade*) |
## Configuration management
@@ -127,6 +128,28 @@ start it), opens tcp/`listen_port` for the allowed sources in the zone that owns
management address where a firewall runs, then enables and restarts it. Zabbix publishes
no repository for OpenWrt; the feed is the only source.
## Firmware upgrade
A package upgrade writes the new package to the overlay while the old one stays in the
read-only image, so the overlay only fills. A sysupgrade to the next release of the
device's own line brings those packages, and every package installed since, in the new
image.
- `get_firmware_offer()` reads `/etc/openwrt_release` and the sysupgrade server the device is
set to (`attendedsysupgrade.@server[0].url`, else `https://sysupgrade.openwrt.org`), and
looks the release line up in the server's `/json/v1/overview.json`. That file is fetched by
the caller, at most once a day per server and process. `latest_version` is the newest
release of the device's line (release candidates only where the line has no release),
`latest_major_version` the newest later line, `installable` whether owut is installed (left
out before 24.10, where owut does not exist). A snapshot, or a target the line does not
build, has no offer.
- `start_firmware_upgrade(version)` runs `owut upgrade --version-to <version>` as root,
detached from the session, with its output in `/tmp/owut-upgrade.log`. It refuses while
another upgrade runs or owut is missing.
- `get_update_progress()` reads that log: `running`, then `done` once owut hands the image to
sysupgrade (which keeps the configuration and restarts the device), or `failed` when owut
stopped before that.
## Wireless writes
`push_mac_acl(ssid_name, mode, macs)` (napalm-device-types `MacAclMixin`) rewrites the