summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas@t-8ch.de>2021-10-19 02:09:40 +0200
committerGitHub <noreply@github.com>2021-10-18 19:09:40 -0500
commita0a68a24c34ee268962e7a3c3844c59ab4036bf9 (patch)
treeff5620ffc3001af98c446d789f2ad50aa54334a6
parent70f0ee78ce4926cb79f37e13568deba298321016 (diff)
downloadcloud-init-git-a0a68a24c34ee268962e7a3c3844c59ab4036bf9.tar.gz
VMware: read network-config from ISO (#1066)
There is no reason for the ISO missing this functionality. As discussed in https://github.com/canonical/cloud-init/pull/947/files#r707338489
-rw-r--r--cloudinit/sources/DataSourceOVF.py3
-rw-r--r--doc/sources/ovf/example/ovf-env.xml2
-rw-r--r--tests/unittests/test_datasource/test_ovf.py10
-rw-r--r--tools/.github-cla-signers1
4 files changed, 11 insertions, 5 deletions
diff --git a/cloudinit/sources/DataSourceOVF.py b/cloudinit/sources/DataSourceOVF.py
index 08a205f1..5257a534 100644
--- a/cloudinit/sources/DataSourceOVF.py
+++ b/cloudinit/sources/DataSourceOVF.py
@@ -360,8 +360,7 @@ class DataSourceOVF(sources.DataSource):
if contents:
break
if contents:
- read_network = ('com.vmware.guestInfo' == name)
- (md, ud, cfg) = read_ovf_environment(contents, read_network)
+ (md, ud, cfg) = read_ovf_environment(contents, True)
self.environment = contents
if 'network-config' in md and md['network-config']:
self._network_config = md['network-config']
diff --git a/doc/sources/ovf/example/ovf-env.xml b/doc/sources/ovf/example/ovf-env.xml
index 4ef4ee63..e5f4e262 100644
--- a/doc/sources/ovf/example/ovf-env.xml
+++ b/doc/sources/ovf/example/ovf-env.xml
@@ -42,7 +42,7 @@
<Property oe:key="user-data" oe:value="IyEvYmluL3NoCmVjaG8gImhpIHdvcmxkIgo="/>
<Property oe:key="password" oe:value="passw0rd"/>
<!--
- network-config is optional, it can only be read from VMware guestinfo.ovfEnv
+ network-config is optional.
The value for network-config is to be base64 encoded.
It will be decoded, and then processed normally as network-config.
Set ovf-env.xml to VMware guestinfo.ovfEnv by below command:
diff --git a/tests/unittests/test_datasource/test_ovf.py b/tests/unittests/test_datasource/test_ovf.py
index 2ca10781..f5818a3a 100644
--- a/tests/unittests/test_datasource/test_ovf.py
+++ b/tests/unittests/test_datasource/test_ovf.py
@@ -519,6 +519,12 @@ class TestDatasourceOVF(CiTestCase):
ds.subplatform)
def test_get_data_vmware_guestinfo_with_network_config(self):
+ self._test_get_data_with_network_config(guestinfo=False, iso=True)
+
+ def test_get_data_iso9660_with_network_config(self):
+ self._test_get_data_with_network_config(guestinfo=True, iso=False)
+
+ def _test_get_data_with_network_config(self, guestinfo, iso):
network_config = dedent("""\
network:
version: 2
@@ -544,9 +550,9 @@ class TestDatasourceOVF(CiTestCase):
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):
+ return_value=env if guestinfo else NOT_FOUND):
with mock.patch(MPATH + 'transport_iso9660',
- return_value=NOT_FOUND):
+ return_value=env if iso else NOT_FOUND):
self.assertTrue(ds.get_data())
self.assertEqual('inst-001', ds.metadata['instance-id'])
self.assertEqual(
diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers
index 0aa168d6..4b7ccb9f 100644
--- a/tools/.github-cla-signers
+++ b/tools/.github-cla-signers
@@ -63,6 +63,7 @@ slyon
smoser
sshedi
stappersg
+t-8ch
TheRealFalcon
taoyama
timothegenzmer