diff options
author | Christian Breunig <christian@breunig.cc> | 2024-09-20 08:45:31 +0200 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-09-21 08:51:28 +0200 |
commit | 90ab441a55b2ec769e7a6fea1dd57bef89b8857c (patch) | |
tree | 8a2fbc7682728a4205af088e471f1111a5cc02d9 /src/conf_mode | |
parent | a5a6e57b3f7ba7d76bffcfb8dcb086d79f51202a (diff) | |
download | vyos-1x-90ab441a55b2ec769e7a6fea1dd57bef89b8857c.tar.gz vyos-1x-90ab441a55b2ec769e7a6fea1dd57bef89b8857c.zip |
T6630: ntp: rename ptp-transport to ptp and use defaultValue for port
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/service_ntp.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/conf_mode/service_ntp.py b/src/conf_mode/service_ntp.py index f7dbc3776..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): @@ -89,10 +98,10 @@ def verify(ntp): if 'server' in ntp: for host, server in ntp['server'].items(): - if 'ptp_transport' in server: - if 'ptp_transport' not in ntp: - raise ConfigError('ptp-transport must be enabled on the service '\ - f'before it can be used with server {host}') + 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 |