From 3169f1270fe8217fe57c9301e48b550539f14b77 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 29 Nov 2020 13:32:03 +0100 Subject: ntp: T2297: support configuration of NTP pool set system ntp server pool --- data/templates/ntp/ntp.conf.tmpl | 14 +++++++------- interface-definitions/ntp.xml.in | 6 ++++++ smoketest/scripts/cli/test_system_ntp.py | 7 +++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/data/templates/ntp/ntp.conf.tmpl b/data/templates/ntp/ntp.conf.tmpl index bb0067bfb..3f319c89b 100644 --- a/data/templates/ntp/ntp.conf.tmpl +++ b/data/templates/ntp/ntp.conf.tmpl @@ -13,13 +13,13 @@ restrict -6 ::1 # # Configurable section # -{% if server %} -{% for srv in server %} -{% set options = '' %} -{% set options = options + 'noselect ' if server[srv].noselect is defined else '' %} -{% set options = options + 'preempt ' if server[srv].preempt is defined else '' %} -{% set options = options + 'prefer ' if server[srv].prefer is defined else '' %} -server {{ srv | replace('_', '-') }} iburst {{ options }} +{% if server is defined and server is not none %} +{% for server, config in server.items() %} +{% set association = 'server' %} +{% if config.pool is defined %} +{% set association = 'pool' %} +{% endif %} +{{ association }} {{ server | replace('_', '-') }} iburst {{ 'noselect' if config.noselect is defined }} {{ 'preempt' if config.preempt is defined }} {{ 'prefer' if config.prefer is defined }} {% endfor %} {% endif %} diff --git a/interface-definitions/ntp.xml.in b/interface-definitions/ntp.xml.in index 6070cafe0..6a8eb0818 100644 --- a/interface-definitions/ntp.xml.in +++ b/interface-definitions/ntp.xml.in @@ -20,6 +20,12 @@ + + + Associate with a number of remote servers + + + Specifies the association as preemptable rather than the default persistent diff --git a/smoketest/scripts/cli/test_system_ntp.py b/smoketest/scripts/cli/test_system_ntp.py index 822a9aff2..e2744c936 100755 --- a/smoketest/scripts/cli/test_system_ntp.py +++ b/smoketest/scripts/cli/test_system_ntp.py @@ -51,11 +51,15 @@ class TestSystemNTP(unittest.TestCase): """ Test basic NTP support with multiple servers and their options """ servers = ['192.0.2.1', '192.0.2.2'] options = ['noselect', 'preempt', 'prefer'] + ntp_pool = 'pool.vyos.io' for server in servers: for option in options: self.session.set(base_path + ['server', server, option]) + # Test NTP pool + self.session.set(base_path + ['server', ntp_pool, 'pool']) + # commit changes self.session.commit() @@ -65,6 +69,9 @@ class TestSystemNTP(unittest.TestCase): test = f'{server} iburst ' + ' '.join(options) self.assertTrue(test in tmp) + tmp = get_config_value('pool') + self.assertTrue(f'{ntp_pool} iburst' in tmp) + # Check for running process self.assertTrue(process_named_running(PROCESS_NAME)) -- cgit v1.2.3