driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 57s
driver / test (3.12) (pull_request) Successful in 58s
driver / test (3.13) (pull_request) Successful in 51s
driver / lowest (pull_request) Successful in 26s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 57s
CI / driver (pull_request) Successful in 2m23s
driver / publish (pull_request) Skipped
netOrk keeps one list of NTP servers and a time zone per site and aligns a device that differs (NetOrk/netork#2360). A Windows host takes part through w32time and its time zone, in one PowerShell script per read. The servers and the mode are read from w32time's registry values, group policy's first, not from w32tm /query /configuration, whose text is in the host's language; synchronised is the leap indicator on the first line of w32tm /query /status, which reads the same in any language. The servers are written the way w32tm /config /manualpeerlist /syncfromflags:manual writes them (NtpServer with 0x8, Type NTP), followed by w32tm /config /update: no value passes a native command line, whose quoting Windows PowerShell 5.1 mangles. A domain member that takes its time from the domain hierarchy (NT5DS, AllSync) and a host whose w32time comes from group policy refuse the write: their time is set elsewhere, and a local write would be overridden or break the domain's time. Windows keeps a Windows zone, which stands for several IANA zones, so Europe/Vienna written would read back as Europe/Berlin and the poll would align the host forever. The IANA name written is kept beside it in HKLM\SOFTWARE\napalm-windows and read back while the host is still in that Windows zone. The zone is read from the registry, which [TimeZoneInfo]::Local caches for the life of the remote session. The zone table is now CLDR's windowsZones.xml (release 49) both ways, generated by tools/windows_zones.py with tzdata's links and committed with its source and checksum; nothing is fetched at runtime. CLDR's old names (Asia/Calcutta) read as their current ones (Asia/Kolkata). Writes the host already has are skipped. Needs napalm-device-types 4.35.0. Refs NetOrk/netork#2367
32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
"""Windows time zone ids and IANA names, both ways.
|
|
|
|
Windows names its zones by their standard-time name (``W. Europe Standard Time``);
|
|
the contracts want an IANA name. The tables are CLDR's ``windowsZones.xml``,
|
|
generated into :mod:`napalm_windows._windows_zones` by ``tools/windows_zones.py``
|
|
and never fetched at runtime:
|
|
|
|
* reading, a Windows zone is the zone CLDR names for its territory ``001`` -- one
|
|
of several a Windows zone stands for (``W. Europe Standard Time`` is Berlin,
|
|
Vienna, Rome, ...). A zone not in the table is ``None``: the reading says it does
|
|
not know rather than guess;
|
|
* writing, every IANA name CLDR maps, and the tzdata links to and from them, has
|
|
its Windows zone.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from napalm_windows._windows_zones import IANA_TO_WINDOWS, WINDOWS_TO_IANA
|
|
|
|
|
|
def iana_time_zone(windows_id: str | None) -> str | None:
|
|
"""The IANA name of the Windows zone *windows_id*; None for one the table lacks."""
|
|
return WINDOWS_TO_IANA.get(windows_id or "")
|
|
|
|
|
|
def windows_time_zone(iana: str | None) -> str | None:
|
|
"""The Windows zone that keeps the IANA zone *iana*; None for one Windows lacks."""
|
|
return IANA_TO_WINDOWS.get(iana or "")
|
|
|
|
|
|
__all__ = ["IANA_TO_WINDOWS", "WINDOWS_TO_IANA", "iana_time_zone", "windows_time_zone"]
|