diff options
author | Scott Moser <smoser@brickies.net> | 2017-01-20 10:06:55 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-01-20 10:06:55 -0500 |
commit | d00b7dba8767618ae360f56bf64b7ab7a8c49d2e (patch) | |
tree | 349799f76c39669a03a6acbd48502970c0abb994 /tests/unittests/test_datasource/test_azure.py | |
parent | fa3009b64949fef3744ddb940f01477dfa2d25e5 (diff) | |
parent | 7fb6f78177b5ece10ca7c54ba3958010a9987f06 (diff) | |
download | vyos-cloud-init-d00b7dba8767618ae360f56bf64b7ab7a8c49d2e.tar.gz vyos-cloud-init-d00b7dba8767618ae360f56bf64b7ab7a8c49d2e.zip |
merge from 0.7.9 at 0.7.9
Diffstat (limited to 'tests/unittests/test_datasource/test_azure.py')
-rw-r--r-- | tests/unittests/test_datasource/test_azure.py | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py index 07127008..8d22bb59 100644 --- a/tests/unittests/test_datasource/test_azure.py +++ b/tests/unittests/test_datasource/test_azure.py @@ -1,3 +1,5 @@ +# This file is part of cloud-init. See LICENSE file for license information. + from cloudinit import helpers from cloudinit.util import b64e, decode_binary, load_file from cloudinit.sources import DataSourceAzure @@ -93,7 +95,7 @@ class TestAzureDataSource(TestCase): for module, name, new in patches: self.patches.enter_context(mock.patch.object(module, name, new)) - def _get_ds(self, data): + def _get_ds(self, data, agent_command=None): def dsdevs(): return data.get('dsdevs', []) @@ -137,6 +139,8 @@ class TestAzureDataSource(TestCase): dsrc = mod.DataSourceAzureNet( data.get('sys_cfg', {}), distro=None, paths=self.paths) + if agent_command is not None: + dsrc.ds_cfg['agent_command'] = agent_command return dsrc @@ -299,7 +303,7 @@ class TestAzureDataSource(TestCase): data = {'ovfcontent': construct_valid_ovf_env(data=odata, pubkeys=pubkeys)} - dsrc = self._get_ds(data) + dsrc = self._get_ds(data, agent_command=['not', '__builtin__']) ret = dsrc.get_data() self.assertTrue(ret) for mypk in mypklist: @@ -314,7 +318,7 @@ class TestAzureDataSource(TestCase): data = {'ovfcontent': construct_valid_ovf_env(data=odata, pubkeys=pubkeys)} - dsrc = self._get_ds(data) + dsrc = self._get_ds(data, agent_command=['not', '__builtin__']) ret = dsrc.get_data() self.assertTrue(ret) @@ -330,7 +334,7 @@ class TestAzureDataSource(TestCase): data = {'ovfcontent': construct_valid_ovf_env(data=odata, pubkeys=pubkeys)} - dsrc = self._get_ds(data) + dsrc = self._get_ds(data, agent_command=['not', '__builtin__']) ret = dsrc.get_data() self.assertTrue(ret) @@ -487,12 +491,15 @@ class TestAzureBounce(TestCase): def tearDown(self): self.patches.close() - def _get_ds(self, ovfcontent=None): + def _get_ds(self, ovfcontent=None, agent_command=None): if ovfcontent is not None: populate_dir(os.path.join(self.paths.seed_dir, "azure"), {'ovf-env.xml': ovfcontent}) - return DataSourceAzure.DataSourceAzureNet( + dsrc = DataSourceAzure.DataSourceAzureNet( {}, distro=None, paths=self.paths) + if agent_command is not None: + dsrc.ds_cfg['agent_command'] = agent_command + return dsrc def get_ovf_env_with_dscfg(self, hostname, cfg): odata = { @@ -537,14 +544,17 @@ class TestAzureBounce(TestCase): host_name = 'unchanged-host-name' self.get_hostname.return_value = host_name cfg = {'hostname_bounce': {'policy': 'force'}} - self._get_ds(self.get_ovf_env_with_dscfg(host_name, cfg)).get_data() + self._get_ds(self.get_ovf_env_with_dscfg(host_name, cfg), + agent_command=['not', '__builtin__']).get_data() self.assertEqual(1, perform_hostname_bounce.call_count) def test_different_hostnames_sets_hostname(self): expected_hostname = 'azure-expected-host-name' self.get_hostname.return_value = 'default-host-name' self._get_ds( - self.get_ovf_env_with_dscfg(expected_hostname, {})).get_data() + self.get_ovf_env_with_dscfg(expected_hostname, {}), + agent_command=['not', '__builtin__'], + ).get_data() self.assertEqual(expected_hostname, self.set_hostname.call_args_list[0][0][0]) @@ -554,14 +564,18 @@ class TestAzureBounce(TestCase): expected_hostname = 'azure-expected-host-name' self.get_hostname.return_value = 'default-host-name' self._get_ds( - self.get_ovf_env_with_dscfg(expected_hostname, {})).get_data() + self.get_ovf_env_with_dscfg(expected_hostname, {}), + agent_command=['not', '__builtin__'], + ).get_data() self.assertEqual(1, perform_hostname_bounce.call_count) def test_different_hostnames_sets_hostname_back(self): initial_host_name = 'default-host-name' self.get_hostname.return_value = initial_host_name self._get_ds( - self.get_ovf_env_with_dscfg('some-host-name', {})).get_data() + self.get_ovf_env_with_dscfg('some-host-name', {}), + agent_command=['not', '__builtin__'], + ).get_data() self.assertEqual(initial_host_name, self.set_hostname.call_args_list[-1][0][0]) @@ -572,7 +586,9 @@ class TestAzureBounce(TestCase): initial_host_name = 'default-host-name' self.get_hostname.return_value = initial_host_name self._get_ds( - self.get_ovf_env_with_dscfg('some-host-name', {})).get_data() + self.get_ovf_env_with_dscfg('some-host-name', {}), + agent_command=['not', '__builtin__'], + ).get_data() self.assertEqual(initial_host_name, self.set_hostname.call_args_list[-1][0][0]) @@ -583,7 +599,7 @@ class TestAzureBounce(TestCase): self.get_hostname.return_value = old_hostname cfg = {'hostname_bounce': {'interface': interface, 'policy': 'force'}} data = self.get_ovf_env_with_dscfg(hostname, cfg) - self._get_ds(data).get_data() + self._get_ds(data, agent_command=['not', '__builtin__']).get_data() self.assertEqual(1, self.subp.call_count) bounce_env = self.subp.call_args[1]['env'] self.assertEqual(interface, bounce_env['interface']) @@ -595,7 +611,7 @@ class TestAzureBounce(TestCase): DataSourceAzure.BUILTIN_DS_CONFIG['hostname_bounce']['command'] = cmd cfg = {'hostname_bounce': {'policy': 'force'}} data = self.get_ovf_env_with_dscfg('some-hostname', cfg) - self._get_ds(data).get_data() + self._get_ds(data, agent_command=['not', '__builtin__']).get_data() self.assertEqual(1, self.subp.call_count) bounce_args = self.subp.call_args[1]['args'] self.assertEqual(cmd, bounce_args) @@ -630,3 +646,5 @@ class TestReadAzureOvf(TestCase): (_md, _ud, cfg) = DataSourceAzure.read_azure_ovf(content) for mypk in mypklist: self.assertIn(mypk, cfg['_pubkeys']) + +# vi: ts=4 expandtab |