summaryrefslogtreecommitdiff
path: root/cloudinit/stages.py
diff options
context:
space:
mode:
authorWesley Wiedenmeier <wesley.wiedenmeier@gmail.com>2016-03-21 23:56:23 -0500
committerWesley Wiedenmeier <wesley.wiedenmeier@gmail.com>2016-03-21 23:56:23 -0500
commit6082a5b0c2b1a52ddbf63bfd80331f28f8cdc4fa (patch)
treed42a72aad62a96870ad36dca8f7d85ce09582311 /cloudinit/stages.py
parentbb9cb8df25eaeca8740f5e1bcbc9cd2feafcba24 (diff)
parent4f2065ad569355d5d0bc54176bde6b8e55047341 (diff)
downloadvyos-cloud-init-6082a5b0c2b1a52ddbf63bfd80331f28f8cdc4fa.tar.gz
vyos-cloud-init-6082a5b0c2b1a52ddbf63bfd80331f28f8cdc4fa.zip
Merge from trunk
Diffstat (limited to 'cloudinit/stages.py')
-rw-r--r--cloudinit/stages.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index dbcf3d55..edad6450 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -140,7 +140,7 @@ class Init(object):
]
return initial_dirs
- def purge_cache(self, rm_instance_lnk=True):
+ def purge_cache(self, rm_instance_lnk=False):
rm_list = []
rm_list.append(self.paths.boot_finished)
if rm_instance_lnk:
@@ -238,21 +238,29 @@ class Init(object):
cfg_list = self.cfg.get('datasource_list') or []
return (cfg_list, pkg_list)
- def _get_data_source(self):
+ def _get_data_source(self, existing):
if self.datasource is not NULL_DATA_SOURCE:
return self.datasource
with events.ReportEventStack(
name="check-cache",
- description="attempting to read from cache",
+ description="attempting to read from cache [%s]" % existing,
parent=self.reporter) as myrep:
ds = self._restore_from_cache()
- if ds:
- LOG.debug("Restored from cache, datasource: %s", ds)
- myrep.description = "restored from cache"
+ if ds and existing == "trust":
+ myrep.description = "restored from cache: %s" % ds
+ elif ds and existing == "check":
+ if hasattr(ds, 'check_instance_id') and ds.check_instance_id():
+ myrep.description = "restored from checked cache: %s" % ds
+ else:
+ myrep.description = "cache invalid in datasource: %s" % ds
+ ds = None
else:
myrep.description = "no cache found"
+ LOG.debug(myrep.description)
+
if not ds:
+ util.del_file(self.paths.instance_link)
(cfg_list, pkg_list) = self._get_datasources()
# Deep copy so that user-data handlers can not modify
# (which will affect user-data handlers down the line...)
@@ -332,8 +340,8 @@ class Init(object):
self._reset()
return iid
- def fetch(self):
- return self._get_data_source()
+ def fetch(self, existing="check"):
+ return self._get_data_source(existing=existing)
def instancify(self):
return self._reflect_cur_instance()