get_time_sync() and configure_time_sync() through napalm-device-types' TimeSyncMixin (4.35.0), in a new napalm_procurve/time_sync.py; time_sync_writes = {"ntp_servers", "timezone"}.
Read: the time lines of show running-config -- over SSH/Telnet directly, over REST through the /cli endpoint (as get_snmp_config does): the sntp server priority <1-3> servers in priority order, or the ntp server lines on a 16.x switch running timesync ntp. timezone is None: the switch keeps time timezone <minutes> and a time daylight-time-rule, no name. synchronized/daemon are None.
Servers: written in the protocol the switch runs -- SNTP (max 3) unless it runs timesync ntp (max 8, ntp server <ip> iburst); a switch on TimeP or no protocol gets sntp unicast and timesync sntp. IP addresses only (v4 or v6), no host names. Too many servers or a host name is refused before anything is sent. Servers already in place from the first one on are kept; from the first difference on the old ones are removed (no sntp server priority <n> <ip> / no ntp server <ip>) and the rest added in order.
Zone:time timezone <minutes> (-720..840) and a summer-time rule from the zone's POSIX rule: the US dates as canada-and-continental-us, the EU dates as western-europe (offset <= 0) or middle-europe-and-portugal, the reverse EU dates as southern-hemisphere, any other Sunday rule as user-defined begin-date MM/DD end-date MM/DD (the date from which the first Sunday on or after hits the transition), none without summer time. Negative summer time (Europe/Dublin) is turned round. Refused before anything is sent: a summer-time shift other than one hour (Lord Howe), a change on a weekday other than Sunday (Israel, Egypt). Either EU rule reads back as matching the EU dates, and a user-defined rule compares by its dates, so a switch set by hand is not rewritten.
Idempotent: only lines that differ are sent, and only then write memory.
REST: writes need the CLI, so the temporary SSH session configure_snmp_agent opened on port 22 is now a _config_cli() context manager both use; it opens only when there is something to write.
get_ntp_servers() reads through get_time_sync() on every transport (it took every IPv4 address of show ntp associations over SSH and the ntp/server resource over REST). It and get_ntp_stats() (unchanged, now with a test) move to time_sync.py, so procurve.py shrinks 1383 -> 1345 lines. The now unused parsers.parse_ntp_servers() and ProcurveApiClient.get_ntp_servers() are removed.
tests/unit/test_time_sync.py (39 tests) against a fake switch that keeps the time lines as show running-config lists them and applies what the driver sends in configure (it refuses an SNTP priority already in use, so the order remove-then-add is checked): SNTP and NTP mode, a bare switch, read over REST via /cli, writes over REST via a temporary SSH session (none opened when nothing changes, a failed SSH fails the step), the same values twice sending nothing, refusals sending nothing, a refused line failing without a save, zone translation for US/EU/Dublin/India/Nepal/Sydney/Auckland. The command syntax is from HPE's management and configuration guides; no recording of these lines from a real switch exists yet, so a first run on a lab switch should confirm the user-defined date semantics and the removal syntax.
pytest 192 passed, ruff format/check clean, mypy clean, napalm-standard check passes, napalm-standard ratchet within the baseline.
## What
`get_time_sync()` and `configure_time_sync()` through napalm-device-types' `TimeSyncMixin` (4.35.0), in a new `napalm_procurve/time_sync.py`; `time_sync_writes = {"ntp_servers", "timezone"}`.
- **Read:** the time lines of `show running-config` -- over SSH/Telnet directly, over REST through the `/cli` endpoint (as `get_snmp_config` does): the `sntp server priority <1-3>` servers in priority order, or the `ntp server` lines on a 16.x switch running `timesync ntp`. `timezone` is `None`: the switch keeps `time timezone <minutes>` and a `time daylight-time-rule`, no name. `synchronized`/`daemon` are `None`.
- **Servers:** written in the protocol the switch runs -- SNTP (max 3) unless it runs `timesync ntp` (max 8, `ntp server <ip> iburst`); a switch on TimeP or no protocol gets `sntp unicast` and `timesync sntp`. IP addresses only (v4 or v6), no host names. Too many servers or a host name is refused before anything is sent. Servers already in place from the first one on are kept; from the first difference on the old ones are removed (`no sntp server priority <n> <ip>` / `no ntp server <ip>`) and the rest added in order.
- **Zone:** `time timezone <minutes>` (-720..840) and a summer-time rule from the zone's POSIX rule: the US dates as `canada-and-continental-us`, the EU dates as `western-europe` (offset <= 0) or `middle-europe-and-portugal`, the reverse EU dates as `southern-hemisphere`, any other Sunday rule as `user-defined begin-date MM/DD end-date MM/DD` (the date from which the first Sunday on or after hits the transition), `none` without summer time. Negative summer time (Europe/Dublin) is turned round. Refused before anything is sent: a summer-time shift other than one hour (Lord Howe), a change on a weekday other than Sunday (Israel, Egypt). Either EU rule reads back as matching the EU dates, and a user-defined rule compares by its dates, so a switch set by hand is not rewritten.
- **Idempotent:** only lines that differ are sent, and only then `write memory`.
- **REST:** writes need the CLI, so the temporary SSH session `configure_snmp_agent` opened on port 22 is now a `_config_cli()` context manager both use; it opens only when there is something to write.
- `get_ntp_servers()` reads through `get_time_sync()` on every transport (it took every IPv4 address of `show ntp associations` over SSH and the `ntp/server` resource over REST). It and `get_ntp_stats()` (unchanged, now with a test) move to `time_sync.py`, so `procurve.py` shrinks 1383 -> 1345 lines. The now unused `parsers.parse_ntp_servers()` and `ProcurveApiClient.get_ntp_servers()` are removed.
## 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` (39 tests) against a fake switch that keeps the time lines as `show running-config` lists them and applies what the driver sends in `configure` (it refuses an SNTP priority already in use, so the order remove-then-add is checked): SNTP and NTP mode, a bare switch, read over REST via `/cli`, writes over REST via a temporary SSH session (none opened when nothing changes, a failed SSH fails the step), the same values twice sending nothing, refusals sending nothing, a refused line failing without a save, zone translation for US/EU/Dublin/India/Nepal/Sydney/Auckland. The command syntax is from HPE's management and configuration guides; no recording of these lines from a real switch exists yet, so a first run on a lab switch should confirm the `user-defined` date semantics and the removal syntax.
pytest 192 passed, ruff format/check clean, mypy clean, `napalm-standard check` passes, `napalm-standard ratchet` within the baseline.
Related: NetOrk/netork#2366
netOrk aligns every device's NTP servers and time zone with its site's
(NetOrk/netork#2360, #2366). A ProCurve keeps them as configuration
lines: sntp server priority <1-3> (or ntp server lines when 16.x runs
timesync ntp), time timezone <minutes> and time daylight-time-rule.
get_time_sync() reads those lines from show running-config, over REST
through the /cli endpoint, and the zone as None: the switch keeps
minutes and a rule, no name. configure_time_sync() writes the servers
in the protocol the switch runs (SNTP unless it runs NTP, switching
TimeP to sntp unicast), keeping those already in place from the first
on; the zone as minutes and the switch's own US/EU rule, or user-defined
dates for other Sunday rules, from the zone's POSIX rule. What the switch
cannot take is refused before anything is sent: more than 3 SNTP or 8
NTP servers, host names, half an hour of summer time, a change on a
weekday. A change is saved with write memory; values already in place
are not sent again, so the alignment on every poll does not churn.
Over REST the writes need the CLI, so the temporary SSH session
configure_snmp_agent opened is now the _config_cli() context manager
both use. get_ntp_servers() reads through get_time_sync() on every
transport; it and get_ntp_stats() move to time_sync.py with the rest of
the clock, so procurve.py shrinks (1383 -> 1339 lines). The unused
parse_ntp_servers() and ProcurveApiClient.get_ntp_servers() are gone.
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_procurve/time_sync.py;time_sync_writes = {"ntp_servers", "timezone"}.show running-config-- over SSH/Telnet directly, over REST through the/cliendpoint (asget_snmp_configdoes): thesntp server priority <1-3>servers in priority order, or thentp serverlines on a 16.x switch runningtimesync ntp.timezoneisNone: the switch keepstime timezone <minutes>and atime daylight-time-rule, no name.synchronized/daemonareNone.timesync ntp(max 8,ntp server <ip> iburst); a switch on TimeP or no protocol getssntp unicastandtimesync sntp. IP addresses only (v4 or v6), no host names. Too many servers or a host name is refused before anything is sent. Servers already in place from the first one on are kept; from the first difference on the old ones are removed (no sntp server priority <n> <ip>/no ntp server <ip>) and the rest added in order.time timezone <minutes>(-720..840) and a summer-time rule from the zone's POSIX rule: the US dates ascanada-and-continental-us, the EU dates aswestern-europe(offset <= 0) ormiddle-europe-and-portugal, the reverse EU dates assouthern-hemisphere, any other Sunday rule asuser-defined begin-date MM/DD end-date MM/DD(the date from which the first Sunday on or after hits the transition),nonewithout summer time. Negative summer time (Europe/Dublin) is turned round. Refused before anything is sent: a summer-time shift other than one hour (Lord Howe), a change on a weekday other than Sunday (Israel, Egypt). Either EU rule reads back as matching the EU dates, and a user-defined rule compares by its dates, so a switch set by hand is not rewritten.write memory.configure_snmp_agentopened on port 22 is now a_config_cli()context manager both use; it opens only when there is something to write.get_ntp_servers()reads throughget_time_sync()on every transport (it took every IPv4 address ofshow ntp associationsover SSH and thentp/serverresource over REST). It andget_ntp_stats()(unchanged, now with a test) move totime_sync.py, soprocurve.pyshrinks 1383 -> 1345 lines. The now unusedparsers.parse_ntp_servers()andProcurveApiClient.get_ntp_servers()are removed.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(39 tests) against a fake switch that keeps the time lines asshow running-configlists them and applies what the driver sends inconfigure(it refuses an SNTP priority already in use, so the order remove-then-add is checked): SNTP and NTP mode, a bare switch, read over REST via/cli, writes over REST via a temporary SSH session (none opened when nothing changes, a failed SSH fails the step), the same values twice sending nothing, refusals sending nothing, a refused line failing without a save, zone translation for US/EU/Dublin/India/Nepal/Sydney/Auckland. The command syntax is from HPE's management and configuration guides; no recording of these lines from a real switch exists yet, so a first run on a lab switch should confirm theuser-defineddate semantics and the removal syntax.pytest 192 passed, ruff format/check clean, mypy clean,
napalm-standard checkpasses,napalm-standard ratchetwithin the baseline.Related: NetOrk/netork#2366