diff options
author | Lucas Christian <lucas@lucasec.com> | 2024-08-08 23:30:40 -0700 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-09-21 08:51:28 +0200 |
commit | e504e0cac55725e93f21322877bb7d0c4f97c992 (patch) | |
tree | 1afa58398bccb29dab7812024f138ec059e03902 | |
parent | 46a76acc85e775e87db5a82fea7bd520d7765369 (diff) | |
download | vyos-1x-e504e0cac55725e93f21322877bb7d0c4f97c992.tar.gz vyos-1x-e504e0cac55725e93f21322877bb7d0c4f97c992.zip |
T6630: ntp: add "interleave" option
-rw-r--r-- | data/templates/chrony/chrony.conf.j2 | 2 | ||||
-rw-r--r-- | interface-definitions/service_ntp.xml.in | 6 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_service_ntp.py | 29 |
3 files changed, 36 insertions, 1 deletions
diff --git a/data/templates/chrony/chrony.conf.j2 b/data/templates/chrony/chrony.conf.j2 index e3f078fdc..86c20a4d8 100644 --- a/data/templates/chrony/chrony.conf.j2 +++ b/data/templates/chrony/chrony.conf.j2 @@ -42,7 +42,7 @@ user {{ user }} {% if config.pool is vyos_defined %} {% set association = 'pool' %} {% endif %} -{{ association }} {{ server | replace('_', '-') }} iburst {{ 'nts' if config.nts is vyos_defined }} {{ 'noselect' if config.noselect is vyos_defined }} {{ 'prefer' if config.prefer is vyos_defined }} +{{ association }} {{ server | replace('_', '-') }} iburst {{- ' nts' if config.nts is vyos_defined }} {{- ' noselect' if config.noselect is vyos_defined }} {{- ' prefer' if config.prefer is vyos_defined }} {{- ' xleave' if config.interleave is vyos_defined }} {% endfor %} {% endif %} diff --git a/interface-definitions/service_ntp.xml.in b/interface-definitions/service_ntp.xml.in index c057b62b5..eca0ada63 100644 --- a/interface-definitions/service_ntp.xml.in +++ b/interface-definitions/service_ntp.xml.in @@ -86,6 +86,12 @@ <valueless/> </properties> </leafNode> + <leafNode name="interleave"> + <properties> + <help>Use the interleaved mode for the server</help> + <valueless/> + </properties> + </leafNode> </children> </tagNode> </children> diff --git a/smoketest/scripts/cli/test_service_ntp.py b/smoketest/scripts/cli/test_service_ntp.py index ae45fe2f4..fe6b1a529 100755 --- a/smoketest/scripts/cli/test_service_ntp.py +++ b/smoketest/scripts/cli/test_service_ntp.py @@ -165,5 +165,34 @@ class TestSystemNTP(VyOSUnitTestSHIM.TestCase): self.assertIn(f'maxslewrate 1000', config) self.assertIn(f'smoothtime 400 0.001024 leaponly', config) + def test_interleave_option(self): + # "interleave" option differs from some others in that the + # name is not a 1:1 mapping from VyOS config + servers = ['192.0.2.1', '192.0.2.2'] + options = ['prefer'] + offload_interface = 'eth0' + + for server in servers: + for option in options: + self.cli_set(base_path + ['server', server, option]) + self.cli_set(base_path + ['server', server, 'interleave']) + + # commit changes + self.cli_commit() + + # Check generated configuration + # this file must be read with higher permissions + config = cmd(f'sudo cat {NTP_CONF}') + self.assertIn('driftfile /run/chrony/drift', config) + self.assertIn('dumpdir /run/chrony', config) + self.assertIn('ntsdumpdir /run/chrony', config) + self.assertIn('clientloglimit 1048576', config) + self.assertIn('rtcsync', config) + self.assertIn('makestep 1.0 3', config) + self.assertIn('leapsectz right/UTC', config) + + for server in servers: + self.assertIn(f'server {server} iburst ' + ' '.join(options) + ' xleave', config) + if __name__ == '__main__': unittest.main(verbosity=2) |