feat(time-sync): the box's NTP servers through TimeSyncMixin #13

Merged
christianmanivong merged 1 commits from feature/time-sync-2367 into main 2026-11-11 14:51:42 +00:00
Owner

Summary

The Fritz!Box takes part in netOrk's time sync (NetOrk/netork#2360) through napalm-device-types' TimeSyncMixin, over TR-064's Time:1 service.

Changes

  • get_time_sync(): one call, Time1.GetInfo. ntp_servers are NewNTPServer1/NewNTPServer2 in that order; an empty slot is no server. AVM documents the zone fields as "not supported" (TR-064 Support – Time, version 5, 2025-08-07), and the box fills NewLocalTimeZoneName with a POSIX rule (CET-1CEST,M3.5.0,M10.5.0/3) or nothing. So timezone is None unless the box names an IANA zone. synchronized and daemon are None, because TR-064 reports neither.
  • configure_time_sync(ntp_servers=[...]): Time1.SetNTPServers, with an empty second slot for one server. time_sync_writes is {"ntp_servers"} because TR-064 cannot write the zone. More than two servers are refused in the write step before anything is sent. A list the box already has (case-insensitive, same order) is not written again, so a poll that aligns the box every time does not churn. verify reads it back.
  • A box without the Time1 service raises FritzServiceError on read.
  • napalm-device-types>=4.35.0. The README has a Time sync section and the CHANGELOG is updated. The driver has no get_ntp_servers(), so it has nothing to keep consistent with. get_system_config()'s ntp_server/ntp_server2 name the same servers (test).

NetOrk/netork#2371: TR-064 does not say whether the box serves time to its home network ("FRITZ!Box als Zeitserver im Heimnetz bereitstellen"). Time:1 has only GetInfo and SetNTPServers, and no other service carries the setting. The driver therefore reports nothing about it. Inventing an ntpd service or a socket would be a guess.

Related Issue

Part of NetOrk/netork#2367 (epic NetOrk/netork#2360); see NetOrk/netork#2371

Testing

  • pytest: 90 passed, coverage 82.6% (floor 81). The new tests/unit/test_time_sync.py fakes the Time:1 service with AVM's documented answers, and SetNTPServers updates what GetInfo reads. It covers one or two servers, empty slots, the POSIX rule as zone, more than two refused, no rewrite, a refused write (UPnP 606) and a box that keeps its old servers (verify fails).
  • ruff format, ruff check, mypy, napalm-standard check and ratchet, and bandit are clean.
  • Not run against a box.
## Summary The Fritz!Box takes part in netOrk's time sync (NetOrk/netork#2360) through napalm-device-types' `TimeSyncMixin`, over TR-064's `Time:1` service. ## Changes - `get_time_sync()`: one call, `Time1.GetInfo`. `ntp_servers` are `NewNTPServer1`/`NewNTPServer2` in that order; an empty slot is no server. AVM documents the zone fields as "not supported" ([TR-064 Support – Time](https://fritz.support/resources/TR-064_Time.pdf), version 5, 2025-08-07), and the box fills `NewLocalTimeZoneName` with a POSIX rule (`CET-1CEST,M3.5.0,M10.5.0/3`) or nothing. So `timezone` is `None` unless the box names an IANA zone. `synchronized` and `daemon` are `None`, because TR-064 reports neither. - `configure_time_sync(ntp_servers=[...])`: `Time1.SetNTPServers`, with an empty second slot for one server. `time_sync_writes` is `{"ntp_servers"}` because TR-064 cannot write the zone. More than two servers are refused in the write step before anything is sent. A list the box already has (case-insensitive, same order) is not written again, so a poll that aligns the box every time does not churn. `verify` reads it back. - A box without the `Time1` service raises `FritzServiceError` on read. - `napalm-device-types>=4.35.0`. The README has a *Time sync* section and the CHANGELOG is updated. The driver has no `get_ntp_servers()`, so it has nothing to keep consistent with. `get_system_config()`'s `ntp_server`/`ntp_server2` name the same servers (test). NetOrk/netork#2371: TR-064 does not say whether the box serves time to its home network ("FRITZ!Box als Zeitserver im Heimnetz bereitstellen"). `Time:1` has only `GetInfo` and `SetNTPServers`, and no other service carries the setting. The driver therefore reports nothing about it. Inventing an `ntpd` service or a socket would be a guess. ## Related Issue Part of NetOrk/netork#2367 (epic NetOrk/netork#2360); see NetOrk/netork#2371 ## Testing - `pytest`: 90 passed, coverage 82.6% (floor 81). The new `tests/unit/test_time_sync.py` fakes the `Time:1` service with AVM's documented answers, and `SetNTPServers` updates what `GetInfo` reads. It covers one or two servers, empty slots, the POSIX rule as zone, more than two refused, no rewrite, a refused write (UPnP 606) and a box that keeps its old servers (verify fails). - `ruff format`, `ruff check`, `mypy`, `napalm-standard check` and `ratchet`, and `bandit` are clean. - Not run against a box.
christianmanivong added 1 commit 2026-11-11 14:28:42 +00:00
feat(time-sync): the box's NTP servers through TimeSyncMixin
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 12s
driver / test (3.12) (pull_request) Successful in 53s
driver / types (pull_request) Successful in 1m0s
driver / test (3.13) (pull_request) Successful in 52s
driver / lowest (pull_request) Successful in 26s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m0s
CI / driver (pull_request) Successful in 2m26s
driver / publish (pull_request) Skipped
fe0e0b3e7d
netOrk keeps one list of NTP servers per site and aligns a device that
differs (NetOrk/netork#2360). The Fritz!Box takes part through TR-064's
Time:1 service: GetInfo reads NewNTPServer1/2, SetNTPServers writes
them.

AVM documents Time:1's zone fields as not supported, and the box keeps
its zone as a POSIX rule or nothing, so the zone is read as None unless
the box names an IANA zone, and time_sync_writes is {"ntp_servers"}.
The box has two server slots: a longer list is refused before anything
is written, and a list the box already has is not written again, so a
poll that aligns the box every time does not churn.

TR-064 says neither whether the clock is synchronised nor whether the
box serves time to its LAN (NetOrk/netork#2371); both stay unreported.

Needs napalm-device-types 4.35.0.

Refs NetOrk/netork#2367
christianmanivong merged commit c587915584 into main 2026-11-11 14:51:42 +00:00
christianmanivong deleted branch feature/time-sync-2367 2026-11-11 14:51:42 +00:00
Sign in to join this conversation.