feat(time-sync): read the time servers and zone of config.xml (NetOrk/netork#2363)
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m1s
driver / test (3.12) (pull_request) Successful in 1m9s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / lowest (pull_request) Successful in 36s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 58s
CI / driver (pull_request) Successful in 2m33s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m1s
driver / test (3.12) (pull_request) Successful in 1m9s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / lowest (pull_request) Successful in 36s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 58s
CI / driver (pull_request) Successful in 2m33s
driver / publish (pull_request) Skipped
netOrk aligns every device with one list of time servers and a zone per site (NetOrk/netork#2360) through napalm-device-types 4.35.0's TimeSyncMixin. OPNsense keeps both in config.xml, <system><timeservers> and <system><timezone>, set on the legacy pages services_ntpd.php and system_general.php. No API controller reads or writes them, on 26.7 and on master, so get_time_sync() reads them from the configuration download get_config already uses and asks /api/ntpd/service/status whether ntpd follows a system peer. The driver writes neither value: time_sync_writes is empty and configure_time_sync is None. Restoring an edited config.xml or running the initial setup wizard would rewrite far more than the clock, on a box that is often the gateway and its LAN's time server. TIME_SERVERS_MENU and TIME_ZONE_MENU say where a person sets them, as SSH_SETTINGS_MENU does for the SSH algorithms. get_ntp_servers() now returns the same configured list. It read a "peers" field the status endpoint does not have (it answers with ntpq's associations as "rows") and so never found a server.
This commit is contained in:
1 parent
a6c3eb2604
commit
6fdc3ff2c7
10 files changed
+592
-64
No files matched your search
@@ -798,44 +798,6 @@ class TestGetLldpNeighborsDetail:
|
||||
assert driver.get_lldp_neighbors_detail() == {}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# get_ntp_servers()
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
NTP_STATUS_RESPONSE = {
|
||||
"peers": [
|
||||
{"address": "pool.ntp.org", "state": "synced"},
|
||||
{"address": "time.cloudflare.com", "state": "candidate"},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
class TestGetNtpServers:
|
||||
def test_entry_count(self, driver):
|
||||
driver._get = lambda path: NTP_STATUS_RESPONSE
|
||||
servers = driver.get_ntp_servers()
|
||||
assert len(servers) == 2
|
||||
|
||||
def test_server_addresses(self, driver):
|
||||
driver._get = lambda path: NTP_STATUS_RESPONSE
|
||||
servers = driver.get_ntp_servers()
|
||||
assert "pool.ntp.org" in servers
|
||||
assert "time.cloudflare.com" in servers
|
||||
|
||||
def test_value_is_empty_dict(self, driver):
|
||||
driver._get = lambda path: NTP_STATUS_RESPONSE
|
||||
for v in driver.get_ntp_servers().values():
|
||||
assert v == {}
|
||||
|
||||
def test_endpoint_failure_returns_empty(self, driver):
|
||||
driver._get = lambda path: (_ for _ in ()).throw(Exception("service not running"))
|
||||
assert driver.get_ntp_servers() == {}
|
||||
|
||||
def test_empty_peers(self, driver):
|
||||
driver._get = lambda path: {"peers": []}
|
||||
assert driver.get_ntp_servers() == {}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# get_vlans()
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user