feat(time-sync): servers and zone through OpenMediaVault's own settings #24

Merged
christianmanivong merged 1 commits from feature/time-sync-2370 into main 2026-11-11 14:27:33 +00:00
Owner

What

napalm-linux now brings napalm-device-types' PosixTimeSyncMixin (4.35.0, NAPALM/napalm-linux#74). On OpenMediaVault its write is the wrong way in, so OmvTimeSyncMixin (napalm_openmediavault/_time_sync.py) goes through OMV's own settings instead. See NetOrk/netork#2370 (part of NetOrk/netork#2360).

  • get_time_sync(): ntp_servers and timezone come from System.getTimeSettings, which is what the web UI shows and what OMV deploys. The comma-separated ntptimeservers are split, and there are no servers while ntpenable is off, because OMV stops chronyd then. synchronized and daemon stay napalm-linux's reading of the host (chronyd's selected source).
  • configure_time_sync(): the contract's template, with both steps going through System.setTimeSettings. A server write switches NTP on. The other fields are kept as getTimeSettings returned them (ntpclients too, date left out). Then Config.applyChanges runs for the modules that change made dirty, plus chrony/timezone if they were already dirty, the same way set_hostname does it. Other modules left pending in the web UI stay pending. A value OMV already has is not written again, so a second identical write changes nothing. verify reads back through getTimeSettings.
  • Nothing is written to the host's own files: no sources.d drop-in, no commented-out lines, no timedatectl set-timezone.
  • time_sync_writes is both values.
  • The floor rises to napalm-device-types>=4.35.0. napalm-linux stays at >=0.17.0: #74 is unreleased and its main still says 0.17.0, CI installs napalm-linux from git main, and this mixin needs nothing beyond device-types 4.35.0 (it brings PosixTimeSyncMixin itself).
  • README rows and a CHANGELOG entry under [Unreleased].

Why

OMV generates /etc/chrony/chrony.conf and the zone from conf.system.time through Salt. A generic write would be taken back the next time OMV deploys its time settings, and netOrk's automatic alignment would then rewrite it on every poll.

Tests

tests/test_time_sync.py (27 tests) fakes omv-rpc/the dirty-modules file and the host's reading. The fixtures follow OMV 7's getTimeSettings answer and generated chrony.conf. They were not captured from a box, because no live device was touched. The tests failed first against napalm-linux main (the inherited POSIX write ran). Now 152 tests pass, the new module has 100% coverage, and ruff, mypy, napalm-standard check and ratchet are clean.

## What napalm-linux now brings napalm-device-types' `PosixTimeSyncMixin` (4.35.0, NAPALM/napalm-linux#74). On OpenMediaVault its write is the wrong way in, so `OmvTimeSyncMixin` (`napalm_openmediavault/_time_sync.py`) goes through OMV's own settings instead. See NetOrk/netork#2370 (part of NetOrk/netork#2360). - `get_time_sync()`: `ntp_servers` and `timezone` come from `System.getTimeSettings`, which is what the web UI shows and what OMV deploys. The comma-separated `ntptimeservers` are split, and there are no servers while `ntpenable` is off, because OMV stops chronyd then. `synchronized` and `daemon` stay napalm-linux's reading of the host (chronyd's selected source). - `configure_time_sync()`: the contract's template, with both steps going through `System.setTimeSettings`. A server write switches NTP on. The other fields are kept as `getTimeSettings` returned them (`ntpclients` too, `date` left out). Then `Config.applyChanges` runs for the modules that change made dirty, plus `chrony`/`timezone` if they were already dirty, the same way `set_hostname` does it. Other modules left pending in the web UI stay pending. A value OMV already has is not written again, so a second identical write changes nothing. `verify` reads back through `getTimeSettings`. - Nothing is written to the host's own files: no `sources.d` drop-in, no commented-out lines, no `timedatectl set-timezone`. - `time_sync_writes` is both values. - The floor rises to `napalm-device-types>=4.35.0`. `napalm-linux` stays at `>=0.17.0`: #74 is unreleased and its `main` still says 0.17.0, CI installs napalm-linux from git `main`, and this mixin needs nothing beyond device-types 4.35.0 (it brings `PosixTimeSyncMixin` itself). - README rows and a CHANGELOG entry under [Unreleased]. ## Why OMV generates `/etc/chrony/chrony.conf` and the zone from `conf.system.time` through Salt. A generic write would be taken back the next time OMV deploys its time settings, and netOrk's automatic alignment would then rewrite it on every poll. ## Tests `tests/test_time_sync.py` (27 tests) fakes `omv-rpc`/the dirty-modules file and the host's reading. The fixtures follow OMV 7's `getTimeSettings` answer and generated `chrony.conf`. They were not captured from a box, because no live device was touched. The tests failed first against napalm-linux `main` (the inherited POSIX write ran). Now 152 tests pass, the new module has 100% coverage, and ruff, mypy, `napalm-standard check` and `ratchet` are clean.
christianmanivong added 1 commit 2026-11-11 14:19:27 +00:00
feat(time-sync): servers and zone through OpenMediaVault's own settings
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 17s
driver / types (pull_request) Successful in 1m15s
driver / test (3.12) (pull_request) Successful in 1m11s
driver / test (3.13) (pull_request) Successful in 1m0s
driver / lowest (pull_request) Successful in 30s
driver / build (pull_request) Successful in 34s
driver / security (pull_request) Successful in 1m12s
CI / driver (pull_request) Successful in 2m58s
driver / publish (pull_request) Skipped
70ad7883bc
napalm-linux now brings napalm-device-types' PosixTimeSyncMixin (4.35.0). Its write -- a chrony drop-in with every other source commented out, timedatectl set-timezone -- is the wrong way in on OpenMediaVault: OMV generates chrony.conf and the zone from conf.system.time through Salt and would take the change back on its next deploy, the web UI would keep showing its own servers, and netOrk's automatic alignment would rewrite on every poll (NetOrk/netork#2370).

OmvTimeSyncMixin reads the servers and the zone from System.getTimeSettings (no servers while NTP is off) and keeps the host's reading for whether the clock is synchronised and by which client. Both values are written through System.setTimeSettings, NTP switched on for servers, and only the modules that change made dirty are applied, plus chrony and timezone if already dirty, as set_hostname does. A value OMV already has is not written again, so a second write changes nothing. The floor rises to napalm-device-types 4.35.0.
christianmanivong merged commit 0619bb2085 into main 2026-11-11 14:27:33 +00:00
christianmanivong deleted branch feature/time-sync-2370 2026-11-11 14:27:33 +00:00
Sign in to join this conversation.