diff options
author | Ben Howard <ben.howard@canonical.com> | 2014-02-07 13:49:03 +0200 |
---|---|---|
committer | Ben Howard <ben.howard@canonical.com> | 2014-02-07 13:49:03 +0200 |
commit | ceffb35a2ddfb5f309417aaa68e7ff70199690fa (patch) | |
tree | a0810797bd45c06ce913d788b507021e747e0a49 /cloudinit | |
parent | 3087da32ec5cf84c51e0ebdd80a71a84b174a392 (diff) | |
download | vyos-cloud-init-ceffb35a2ddfb5f309417aaa68e7ff70199690fa.tar.gz vyos-cloud-init-ceffb35a2ddfb5f309417aaa68e7ff70199690fa.zip |
Made new ovf-env.xml handling more robust. Test cases included
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/sources/DataSourceAzure.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index 448915d7..eee36d22 100644 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -84,21 +84,20 @@ class DataSourceAzureNet(sources.DataSource): 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: try: if cdev.startswith("/dev/"): ret = util.mount_cb(cdev, load_azure_ds_dir) - - # If we load the OVF from a device, it means that a - # new ovf-env.xml has been found. (LP: #1269626) - if os.path.exists(ddir): - LOG.info("removing old agent directory %s" % ddir) - util.del_dir(ddir) else: ret = load_azure_ds_dir(cdev) @@ -110,6 +109,11 @@ class DataSourceAzureNet(sources.DataSource): 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]) |