feat(time-sync): NTP servers and time zone through TimeSyncMixin
driver / standard (pull_request) Successful in 15s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 53s
driver / test (3.12) (pull_request) Successful in 58s
driver / test (3.13) (pull_request) Successful in 56s
driver / lowest (pull_request) Successful in 27s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 58s
CI / driver (pull_request) Successful in 2m26s
driver / publish (pull_request) Skipped

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.
This commit is contained in:
Christian Manivong committed 2026-11-11 15:22:54 +01:00
1 parent e7bd0c17f5
commit 7bb15f5af3
8 files changed
+870 -37

No files matched your search

+21 -2
View File
@@ -8,6 +8,19 @@ recorded here; their history is the git log.
## [Unreleased]
### Added
- Time sync (napalm-device-types `TimeSyncMixin`, NetOrk/netork#2364): `get_time_sync()`
reads the router's NTP servers and its zone from one `uci -q show system`;
`configure_time_sync()` writes both. The servers replace `system.ntp.server`, enable
the client and turn off the servers of a DHCP lease (`use_dhcp=0`), so the router
takes time from exactly these; `sysntpd` restarts. The zone is written as its name
(`zonename`, in LuCI's spelling) and its POSIX rule (`timezone`, from
napalm-device-types' `posix_tz`), then `/etc/init.d/system reload` and a restart of
logd apply it -- the rule, not the name, is what libc reads (NetOrk/netork#1849). A
value the router already has is not written again and nothing restarts. The zone
reads by its name only where the rule in force is that zone's: a router whose rule
differs from its `zonename`, or that has a rule only, reads as the one zone with that
rule, or as no zone where several share it. `synchronized` is None: BusyBox ntpd keeps
no state to read.
- `get_host_status()` (napalm-device-types `HostStatusMixin`), over an SSH exec channel:
whether the router needs a reboot, how full its filesystems are, and -- with
napalm-device-types 4.32 or newer -- whether apk (OpenWrt 25.12) or opkg (before) was
@@ -32,8 +45,12 @@ recorded here; their history is the git log.
to do on every poll (#8). Needs napalm-device-types with `LldpAgentMixin`.
### Changed
- The floor on napalm-device-types is 4.26.0, the first release with `PosixScheduledJobsMixin`
(it was 4.24.0, for the shared `lldpctl` parser).
- `get_ntp_servers()` and `get_ntp_peers()` read over an SSH exec channel, with the same
reading as `get_time_sync()`, and name no servers while the NTP client is disabled
(`system.ntp.enabled='0'`): sysntpd then starts no ntpd.
- The floor on napalm-device-types is 4.35.0, the first release with `TimeSyncMixin`
(it was 4.26.0 for `PosixScheduledJobsMixin`, and 4.24.0 for the shared `lldpctl`
parser before that).
- Python 3.12 is the floor (`requires-python = ">=3.12"`): netOrk runs every driver
on 3.12, so 3.10 and 3.11 are no longer tested (NAPALM/driver-standard#6).
- The floor on napalm is 5.1: older releases import `pkg_resources`, which a Python
@@ -45,6 +62,8 @@ recorded here; their history is the git log.
`manage_service("lldpd", "enable")` and `manage_service("lldpd", "start")` (#8).
### Fixed
- `get_ntp_servers()` names every server of the `system.ntp.server` list; it kept only
the first, as uci prints a list as `'a' 'b' 'c'` on one line.
- `get_lldp_neighbors()` and `get_lldp_neighbors_detail()` keep an interface name with
a dot whole: the neighbours of a VLAN interface such as `eth0.1` used to come back
under `eth0` with every field empty (#26). A neighbour that names its port by MAC