summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2024-09-24 10:08:55 +0100
committerGitHub <noreply@github.com>2024-09-24 10:08:55 +0100
commitcf55d9db374cccb263d671a4e9c7ba8e2cd93df5 (patch)
tree1135752fb44b0c0c2e16d0baac50009d8c7dc831 /src
parent644a91e970c96de01d2e17a7ea91502b8f7265e6 (diff)
parent917c658e37b619b1b2cd261ae43dd02f11eef720 (diff)
downloadvyos-1x-cf55d9db374cccb263d671a4e9c7ba8e2cd93df5.tar.gz
vyos-1x-cf55d9db374cccb263d671a4e9c7ba8e2cd93df5.zip
Merge pull request #3966 from lucasec/t6630
T6630: ntp: support hardware timestamp offload and other mechanisms to improve accuracy
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/service_ntp.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/conf_mode/service_ntp.py b/src/conf_mode/service_ntp.py
index 83880fd72..32563aa0e 100755
--- a/src/conf_mode/service_ntp.py
+++ b/src/conf_mode/service_ntp.py
@@ -17,6 +17,7 @@
import os
from vyos.config import Config
+from vyos.config import config_dict_merge
from vyos.configdict import is_node_changed
from vyos.configverify import verify_vrf
from vyos.configverify import verify_interface_exists
@@ -42,13 +43,21 @@ def get_config(config=None):
if not conf.exists(base):
return None
- ntp = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True, with_defaults=True)
+ ntp = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True)
ntp['config_file'] = config_file
ntp['user'] = user_group
tmp = is_node_changed(conf, base + ['vrf'])
if tmp: ntp.update({'restart_required': {}})
+ # We have gathered the dict representation of the CLI, but there are default
+ # options which we need to update into the dictionary retrived.
+ default_values = conf.get_config_defaults(**ntp.kwargs, recursive=True)
+ # Only defined PTP default port, if PTP feature is in use
+ if 'ptp' not in ntp:
+ del default_values['ptp']
+
+ ntp = config_dict_merge(default_values, ntp)
return ntp
def verify(ntp):
@@ -87,6 +96,15 @@ def verify(ntp):
if ipv6_addresses > 1:
raise ConfigError(f'NTP Only admits one ipv6 value for listen-address parameter ')
+ if 'server' in ntp:
+ for host, server in ntp['server'].items():
+ if 'ptp' in server:
+ if 'ptp' not in ntp:
+ raise ConfigError('PTP must be enabled for the NTP service '\
+ f'before it can be used for server "{host}"')
+ else:
+ break
+
return None
def generate(ntp):