diff options
author | PengpengSun <40026211+PengpengSun@users.noreply.github.com> | 2021-09-17 01:43:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-16 12:43:59 -0500 |
commit | 5ea2c669d6e8a9ab30f3107bee45cecc5fa1b081 (patch) | |
tree | 9cef6a572ed6ef8b366a03dcd475a081ad0268e2 /tests/unittests | |
parent | d4fe7bc4c320023263075258027eae210e7497e1 (diff) | |
download | vyos-cloud-init-5ea2c669d6e8a9ab30f3107bee45cecc5fa1b081.tar.gz vyos-cloud-init-5ea2c669d6e8a9ab30f3107bee45cecc5fa1b081.zip |
VMware: Fix typo introduced in #947 and add test (#1019)
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/test_datasource/test_ovf.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_ovf.py b/tests/unittests/test_datasource/test_ovf.py index 9f52b504..2ca10781 100644 --- a/tests/unittests/test_datasource/test_ovf.py +++ b/tests/unittests/test_datasource/test_ovf.py @@ -518,6 +518,49 @@ class TestDatasourceOVF(CiTestCase): 'vmware (%s/seed/ovf-env.xml)' % self.tdir, ds.subplatform) + def test_get_data_vmware_guestinfo_with_network_config(self): + network_config = dedent("""\ + network: + version: 2 + ethernets: + nics: + nameservers: + addresses: + - 127.0.0.53 + search: + - vmware.com + match: + name: eth* + gateway4: 10.10.10.253 + dhcp4: false + addresses: + - 10.10.10.1/24 + """) + network_config_b64 = base64.b64encode(network_config.encode()).decode() + props = {"network-config": network_config_b64, + "password": "passw0rd", + "instance-id": "inst-001"} + env = fill_properties(props) + paths = Paths({'cloud_dir': self.tdir, 'run_dir': self.tdir}) + ds = self.datasource(sys_cfg={}, distro={}, paths=paths) + with mock.patch(MPATH + 'transport_vmware_guestinfo', + return_value=env): + with mock.patch(MPATH + 'transport_iso9660', + return_value=NOT_FOUND): + self.assertTrue(ds.get_data()) + self.assertEqual('inst-001', ds.metadata['instance-id']) + self.assertEqual( + {'version': 2, 'ethernets': + {'nics': + {'nameservers': + {'addresses': ['127.0.0.53'], + 'search': ['vmware.com']}, + 'match': {'name': 'eth*'}, + 'gateway4': '10.10.10.253', + 'dhcp4': False, + 'addresses': ['10.10.10.1/24']}}}, + ds.network_config) + def test_get_data_cloudinit_metadata_json(self): """Test metadata can be loaded to cloud-init metadata and network. The metadata format is json. |