diff options
author | Chad Smith <chad.smith@canonical.com> | 2017-11-16 20:58:45 -0700 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2017-11-16 20:58:45 -0700 |
commit | d90318b21d0379e24337bcb92a0a90ebfa359c35 (patch) | |
tree | 598603dd1a072f1e4e34ef745511a77e05033904 /tests/unittests/test_handler | |
parent | 6ad23fe9b11f07e4404c8a1f2f1e9cba2640dceb (diff) | |
download | vyos-cloud-init-d90318b21d0379e24337bcb92a0a90ebfa359c35.tar.gz vyos-cloud-init-d90318b21d0379e24337bcb92a0a90ebfa359c35.zip |
ntp: fix configuration template rendering for openSUSE and SLES
Add opensuse distro support to cc_ntp module.
LP: #1726572
Diffstat (limited to 'tests/unittests/test_handler')
-rw-r--r-- | tests/unittests/test_handler/test_handler_ntp.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_ntp.py b/tests/unittests/test_handler/test_handler_ntp.py index 3abe5786..28a8455d 100644 --- a/tests/unittests/test_handler/test_handler_ntp.py +++ b/tests/unittests/test_handler/test_handler_ntp.py @@ -430,5 +430,31 @@ class TestNtp(FilesystemMockingTestCase): "[Time]\nNTP=192.168.2.1 192.168.2.2 0.mypool.org \n", content.decode()) + def test_write_ntp_config_template_defaults_pools_empty_lists_sles(self): + """write_ntp_config_template defaults pools servers upon empty config. + + When both pools and servers are empty, default NR_POOL_SERVERS get + configured. + """ + distro = 'sles' + mycloud = self._get_cloud(distro) + ntp_conf = self.tmp_path('ntp.conf', self.new_root) # Doesn't exist + # Create ntp.conf.tmpl + with open('{0}.tmpl'.format(ntp_conf), 'wb') as stream: + stream.write(NTP_TEMPLATE) + with mock.patch('cloudinit.config.cc_ntp.NTP_CONF', ntp_conf): + cc_ntp.write_ntp_config_template({}, mycloud, ntp_conf) + content = util.read_file_or_url('file://' + ntp_conf).contents + default_pools = [ + "{0}.opensuse.pool.ntp.org".format(x) + for x in range(0, cc_ntp.NR_POOL_SERVERS)] + self.assertEqual( + "servers []\npools {0}\n".format(default_pools), + content.decode()) + self.assertIn( + "Adding distro default ntp pool servers: {0}".format( + ",".join(default_pools)), + self.logs.getvalue()) + # vi: ts=4 expandtab |