summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_ntp.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2017-11-21 11:43:26 -0700
committerChad Smith <chad.smith@canonical.com>2017-11-21 11:43:26 -0700
commit5b974bbab161e6cd73751bf27b7741f6b0d19051 (patch)
treef634411a9b12b2e36ff8beefbec39dad21cd45ea /tests/unittests/test_handler/test_handler_ntp.py
parentc9c7ff70f55ee024dd54336f07ba52acec1f6929 (diff)
parent7624348712b4502f0085d30c05b34dce3f2ceeae (diff)
downloadvyos-cloud-init-5b974bbab161e6cd73751bf27b7741f6b0d19051.tar.gz
vyos-cloud-init-5b974bbab161e6cd73751bf27b7741f6b0d19051.zip
merge from 7624348712b4502f0085d30c05b34dce3f2ceeae at 17.1-41-g76243487
Diffstat (limited to 'tests/unittests/test_handler/test_handler_ntp.py')
-rw-r--r--tests/unittests/test_handler/test_handler_ntp.py26
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