Skip to content

Commit a0a68a2

Browse files
authored
VMware: read network-config from ISO (canonical#1066)
There is no reason for the ISO missing this functionality. As discussed in https://github.com/canonical/cloud-init/pull/947/files#r707338489
1 parent 70f0ee7 commit a0a68a2

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

cloudinit/sources/DataSourceOVF.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ def _get_data(self):
360360
if contents:
361361
break
362362
if contents:
363-
read_network = ('com.vmware.guestInfo' == name)
364-
(md, ud, cfg) = read_ovf_environment(contents, read_network)
363+
(md, ud, cfg) = read_ovf_environment(contents, True)
365364
self.environment = contents
366365
if 'network-config' in md and md['network-config']:
367366
self._network_config = md['network-config']

doc/sources/ovf/example/ovf-env.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<Property oe:key="user-data" oe:value="IyEvYmluL3NoCmVjaG8gImhpIHdvcmxkIgo="/>
4343
<Property oe:key="password" oe:value="passw0rd"/>
4444
<!--
45-
network-config is optional, it can only be read from VMware guestinfo.ovfEnv
45+
network-config is optional.
4646
The value for network-config is to be base64 encoded.
4747
It will be decoded, and then processed normally as network-config.
4848
Set ovf-env.xml to VMware guestinfo.ovfEnv by below command:

tests/unittests/test_datasource/test_ovf.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ def test_get_data_vmware_seed_platform_info(self):
519519
ds.subplatform)
520520

521521
def test_get_data_vmware_guestinfo_with_network_config(self):
522+
self._test_get_data_with_network_config(guestinfo=False, iso=True)
523+
524+
def test_get_data_iso9660_with_network_config(self):
525+
self._test_get_data_with_network_config(guestinfo=True, iso=False)
526+
527+
def _test_get_data_with_network_config(self, guestinfo, iso):
522528
network_config = dedent("""\
523529
network:
524530
version: 2
@@ -544,9 +550,9 @@ def test_get_data_vmware_guestinfo_with_network_config(self):
544550
paths = Paths({'cloud_dir': self.tdir, 'run_dir': self.tdir})
545551
ds = self.datasource(sys_cfg={}, distro={}, paths=paths)
546552
with mock.patch(MPATH + 'transport_vmware_guestinfo',
547-
return_value=env):
553+
return_value=env if guestinfo else NOT_FOUND):
548554
with mock.patch(MPATH + 'transport_iso9660',
549-
return_value=NOT_FOUND):
555+
return_value=env if iso else NOT_FOUND):
550556
self.assertTrue(ds.get_data())
551557
self.assertEqual('inst-001', ds.metadata['instance-id'])
552558
self.assertEqual(

tools/.github-cla-signers

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ slyon
6363
smoser
6464
sshedi
6565
stappersg
66+
t-8ch
6667
TheRealFalcon
6768
taoyama
6869
timothegenzmer

0 commit comments

Comments
 (0)