get_time_sync() and configure_time_sync() through napalm-device-types' TimeSyncMixin (4.35.0), in a new napalm_tplink_jetstream/time_sync.py; time_sync_writes = {"ntp_servers", "timezone"}.
Read: the servers of the system-time ntp <zone> <primary> <backup> <hours> line of show running-config (one listed as primary and backup counts once, a 0.0.0.0 backup not at all). timezone is None: the switch keeps a UTC offset, not a name. synchronized and daemon are None (the CLI shows no sync state). get_ntp_servers() now reads through the same parser.
Servers: at most 2, IPv4 addresses only (the CLI takes a primary and a backup IP); more, a host name or an IPv6 address is refused before anything is sent. One server goes in as primary and backup. The zone token and fetching rate of the existing line are kept (UTC and 12 h when the switch was on manual time — writing the line switches it to NTP).
Zone: the IANA name becomes its UTC offset from the switch's list (UTC+01:00, UTC, UTC+05:30, ...) and system-time dst recurring <week> <day> <month> <HH:MM> ... <minutes> from the zone's POSIX rule (posix_tz + parse_posix_tz), or no system-time dst for a zone without summer time. A zone whose summer time is behind its standard time (Europe/Dublin) is turned round. An offset the switch does not offer (Chatham, Eucla, Kiribati) or a change outside a day's HH:MM (America/Nuuk, Asia/Gaza) is refused before anything is sent. On a switch without an ntp line the zone alone is refused: the switch keeps it with the servers.
Servers and zone share the line: a call with both writes it once, with the new offset.
Idempotent: only lines that differ from the running config are sent, and only then copy running-config startup-config.
tests/unit/test_time_sync.py (33 tests) against a fake switch that keeps the system-time lines as show running-config lists them and applies what the driver sends in configure: read, write, the same values twice sending nothing, refusals sending nothing, a refused command failing the step without a save. The command syntax is from TP-Link's CLI reference guide; no recording of these lines from a real switch exists yet, so a first run on a lab switch should confirm the dst recurring week numbering (5 = last) and the UTC token.
## What
`get_time_sync()` and `configure_time_sync()` through napalm-device-types' `TimeSyncMixin` (4.35.0), in a new `napalm_tplink_jetstream/time_sync.py`; `time_sync_writes = {"ntp_servers", "timezone"}`.
- **Read:** the servers of the `system-time ntp <zone> <primary> <backup> <hours>` line of `show running-config` (one listed as primary and backup counts once, a `0.0.0.0` backup not at all). `timezone` is `None`: the switch keeps a UTC offset, not a name. `synchronized` and `daemon` are `None` (the CLI shows no sync state). `get_ntp_servers()` now reads through the same parser.
- **Servers:** at most 2, IPv4 addresses only (the CLI takes a primary and a backup IP); more, a host name or an IPv6 address is refused before anything is sent. One server goes in as primary and backup. The zone token and fetching rate of the existing line are kept (UTC and 12 h when the switch was on manual time — writing the line switches it to NTP).
- **Zone:** the IANA name becomes its UTC offset from the switch's list (`UTC+01:00`, `UTC`, `UTC+05:30`, ...) and `system-time dst recurring <week> <day> <month> <HH:MM> ... <minutes>` from the zone's POSIX rule (`posix_tz` + `parse_posix_tz`), or `no system-time dst` for a zone without summer time. A zone whose summer time is behind its standard time (Europe/Dublin) is turned round. An offset the switch does not offer (Chatham, Eucla, Kiribati) or a change outside a day's HH:MM (America/Nuuk, Asia/Gaza) is refused before anything is sent. On a switch without an `ntp` line the zone alone is refused: the switch keeps it with the servers.
- Servers and zone share the line: a call with both writes it once, with the new offset.
- **Idempotent:** only lines that differ from the running config are sent, and only then `copy running-config startup-config`.
- Connection code (`_ssh.py`, `open()`) untouched (netOrk #1720).
## Why
netOrk aligns every device's NTP servers and time zone with its site's (NetOrk/netork#2360). Part of NetOrk/netork#2366.
## Tests
`tests/unit/test_time_sync.py` (33 tests) against a fake switch that keeps the `system-time` lines as `show running-config` lists them and applies what the driver sends in `configure`: read, write, the same values twice sending nothing, refusals sending nothing, a refused command failing the step without a save. The command syntax is from TP-Link's CLI reference guide; no recording of these lines from a real switch exists yet, so a first run on a lab switch should confirm the `dst recurring` week numbering (5 = last) and the `UTC` token.
pytest 97 passed, ruff format/check clean, mypy clean, `napalm-standard check` passes, `napalm-standard ratchet` within the baseline (`tplink_jetstream.py` 1999 -> 1987 lines).
Related: NetOrk/netork#2366
netOrk aligns every device's NTP servers and time zone with its site's
(NetOrk/netork#2360, #2366). A JetStream keeps both in one line,
system-time ntp <zone> <primary> <backup> <hours>, with the zone as a
UTC offset from a fixed list and summer time in a system-time dst line
of its own.
get_time_sync() reads the servers from that line and the zone as None:
the switch keeps no name to map back. configure_time_sync() writes an
IANA zone as its offset and a dst recurring rule from the zone's POSIX
rule (posix_tz/parse_posix_tz), and refuses before sending anything
what the switch cannot take: more than two servers, anything but IPv4
addresses, an offset it does not offer, a change outside HH:MM of a day.
Servers and zone share the ntp line, so a call with both writes it once.
A change is saved to the startup configuration; values the switch
already has are not sent again, so the alignment on every poll does not
churn.
The code lives in time_sync.py; get_ntp_servers() now reads through it,
so the driver file shrinks (1999 -> 1987 lines).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
get_time_sync()andconfigure_time_sync()through napalm-device-types'TimeSyncMixin(4.35.0), in a newnapalm_tplink_jetstream/time_sync.py;time_sync_writes = {"ntp_servers", "timezone"}.system-time ntp <zone> <primary> <backup> <hours>line ofshow running-config(one listed as primary and backup counts once, a0.0.0.0backup not at all).timezoneisNone: the switch keeps a UTC offset, not a name.synchronizedanddaemonareNone(the CLI shows no sync state).get_ntp_servers()now reads through the same parser.UTC+01:00,UTC,UTC+05:30, ...) andsystem-time dst recurring <week> <day> <month> <HH:MM> ... <minutes>from the zone's POSIX rule (posix_tz+parse_posix_tz), orno system-time dstfor a zone without summer time. A zone whose summer time is behind its standard time (Europe/Dublin) is turned round. An offset the switch does not offer (Chatham, Eucla, Kiribati) or a change outside a day's HH:MM (America/Nuuk, Asia/Gaza) is refused before anything is sent. On a switch without anntpline the zone alone is refused: the switch keeps it with the servers.copy running-config startup-config._ssh.py,open()) untouched (netOrk #1720).Why
netOrk aligns every device's NTP servers and time zone with its site's (NetOrk/netork#2360). Part of NetOrk/netork#2366.
Tests
tests/unit/test_time_sync.py(33 tests) against a fake switch that keeps thesystem-timelines asshow running-configlists them and applies what the driver sends inconfigure: read, write, the same values twice sending nothing, refusals sending nothing, a refused command failing the step without a save. The command syntax is from TP-Link's CLI reference guide; no recording of these lines from a real switch exists yet, so a first run on a lab switch should confirm thedst recurringweek numbering (5 = last) and theUTCtoken.pytest 97 passed, ruff format/check clean, mypy clean,
napalm-standard checkpasses,napalm-standard ratchetwithin the baseline (tplink_jetstream.py1999 -> 1987 lines).Related: NetOrk/netork#2366