summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-02-10 15:05:41 -0500
committerScott Moser <smoser@ubuntu.com>2014-02-10 15:05:41 -0500
commitc09e8cd6e81e478dd5276275418b70d5d946f479 (patch)
treeaa886a5d746b9619d61edfaa952b2bc2f56fa19c /cloudinit
parentceffb35a2ddfb5f309417aaa68e7ff70199690fa (diff)
downloadvyos-cloud-init-c09e8cd6e81e478dd5276275418b70d5d946f479.tar.gz
vyos-cloud-init-c09e8cd6e81e478dd5276275418b70d5d946f479.zip
change behavior to only delete SharedConfig.xml.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/sources/DataSourceAzure.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index eee36d22..6b48a340 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -84,14 +84,9 @@ 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:
@@ -109,11 +104,6 @@ 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])
@@ -138,10 +128,27 @@ class DataSourceAzureNet(sources.DataSource):
user_ds_cfg = util.get_cfg_by_path(self.cfg, DS_CFG_PATH, {})
self.ds_cfg = util.mergemanydict([user_ds_cfg, self.ds_cfg])
mycfg = self.ds_cfg
+ ddir = mycfg['data_dir']
+
+ if found != ddir:
+ cached_ovfenv = util.load_file(
+ os.path.join(ddir, 'ovf-env.xml'), quiet=True)
+ if cached_ovfenv != files['ovf-env.xml']:
+ # source was not walinux-agent's datadir, so we have to clean
+ # up so 'wait_for_files' doesn't return early due to stale data
+ toclean = ['SharedConfig.xml']
+ cleaned = []
+ for f in [os.path.join(ddir, f) for f in toclean]:
+ if os.path.exists(f):
+ util.del_file(f)
+ cleaned.append(f)
+ if cleaned:
+ LOG.info("removed stale file(s) in '%s': %s",
+ ddir, str(cleaned))
# walinux agent writes files world readable, but expects
# the directory to be protected.
- write_files(mycfg['data_dir'], files, dirmode=0700)
+ write_files(ddir, files, dirmode=0700)
# handle the hostname 'publishing'
try:
@@ -159,13 +166,13 @@ class DataSourceAzureNet(sources.DataSource):
util.logexc(LOG, "agent command '%s' failed.",
mycfg['agent_command'])
- shcfgxml = os.path.join(mycfg['data_dir'], "SharedConfig.xml")
+ shcfgxml = os.path.join(ddir, "SharedConfig.xml")
wait_for = [shcfgxml]
fp_files = []
for pk in self.cfg.get('_pubkeys', []):
bname = str(pk['fingerprint'] + ".crt")
- fp_files += [os.path.join(mycfg['data_dir'], bname)]
+ fp_files += [os.path.join(ddir, bname)]
missing = util.log_time(logfunc=LOG.debug, msg="waiting for files",
func=wait_for_files,