forked from pool/cloud-init
Robert Schweikert
b363ee2095
- add patch azure_1269626.diff, fix for upstream bug 1269626 + Azure instance do not boot properly after a capture operation OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=7
88 lines
3.0 KiB
Diff
88 lines
3.0 KiB
Diff
=== modified file 'cloudinit/sources/DataSourceAzure.py'
|
|
--- cloudinit/sources/DataSourceAzure.py 2014-01-09 18:12:40 +0000
|
|
+++ cloudinit/sources/DataSourceAzure.py 2014-02-07 11:51:56 +0000
|
|
@@ -84,9 +84,14 @@
|
|
|
|
candidates = [self.seed_dir]
|
|
candidates.extend(list_possible_azure_ds_devs())
|
|
+ previous_ovf_cfg = None
|
|
if ddir:
|
|
candidates.append(ddir)
|
|
|
|
+ previous_ovf_cfg = None
|
|
+ if os.path.exists("%s/ovf-env.xml" % ddir):
|
|
+ previous_ovf_cfg = load_azure_ds_dir(ddir)
|
|
+
|
|
found = None
|
|
|
|
for cdev in candidates:
|
|
@@ -104,6 +109,11 @@
|
|
LOG.warn("%s was not mountable" % cdev)
|
|
continue
|
|
|
|
+ if ret != previous_ovf_cfg:
|
|
+ LOG.info(("instance configuration has changed, "
|
|
+ "removing old agent directory"))
|
|
+ util.del_dir(ddir)
|
|
+
|
|
(md, self.userdata_raw, cfg, files) = ret
|
|
self.seed = cdev
|
|
self.metadata = util.mergemanydict([md, DEFAULT_METADATA])
|
|
|
|
=== modified file 'tests/unittests/test_datasource/test_azure.py'
|
|
--- tests/unittests/test_datasource/test_azure.py 2013-10-02 21:05:15 +0000
|
|
+++ tests/unittests/test_datasource/test_azure.py 2014-02-07 11:51:56 +0000
|
|
@@ -119,6 +119,10 @@
|
|
{'ovf-env.xml': data['ovfcontent']})
|
|
|
|
mod = DataSourceAzure
|
|
+ ddir = "%s/var/lib/waagent" % self.tmp
|
|
+ mod.BUILTIN_DS_CONFIG['data_dir'] = ddir
|
|
+ if not os.path.isdir(ddir):
|
|
+ os.makedirs(ddir)
|
|
|
|
self.apply_patches([(mod, 'list_possible_azure_ds_devs', dsdevs)])
|
|
|
|
@@ -338,6 +342,40 @@
|
|
|
|
self.assertEqual(userdata, dsrc.userdata_raw)
|
|
|
|
+ def test_existing_ovf_same(self):
|
|
+ mydata = "FOOBAR"
|
|
+ odata = {'UserData': base64.b64encode(mydata)}
|
|
+ data = {'ovfcontent': construct_valid_ovf_env(data=odata)}
|
|
+
|
|
+ with open("%s/ovf-env.xml" % self.tmp, 'w') as fp:
|
|
+ fp.write(construct_valid_ovf_env(data=odata))
|
|
+ with open("%s/sem" % self.tmp, 'w') as fp:
|
|
+ fp.write("test")
|
|
+
|
|
+ dsrc = self._get_ds(data)
|
|
+ ret = dsrc.get_data()
|
|
+ self.assertTrue(ret)
|
|
+ self.assertEqual(dsrc.userdata_raw, mydata)
|
|
+ self.assertTrue(os.path.exists("%s/sem" % self.tmp))
|
|
+
|
|
+ def test_existing_ovf_diff(self):
|
|
+ mydata = "FOOBAR"
|
|
+ odata = {'UserData': base64.b64encode(mydata)}
|
|
+ data = {'ovfcontent': construct_valid_ovf_env(data=odata)}
|
|
+
|
|
+ data_dir = "%s/var/lib/waagent" % self.tmp
|
|
+ os.makedirs(data_dir)
|
|
+ with open("%s/ovf-env.xml" % data_dir, 'w') as fp:
|
|
+ fp.write(construct_valid_ovf_env())
|
|
+ with open("%s/sem" % data_dir, 'w') as fp:
|
|
+ fp.write("test")
|
|
+
|
|
+ dsrc = self._get_ds(data)
|
|
+ ret = dsrc.get_data()
|
|
+ self.assertTrue(ret)
|
|
+ self.assertEqual(dsrc.userdata_raw, mydata)
|
|
+ self.assertFalse(os.path.exists("%s/sem" % data_dir))
|
|
+
|
|
|
|
class TestReadAzureOvf(MockerTestCase):
|
|
def test_invalid_xml_raises_non_azure_ds(self):
|
|
|