summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-20 12:13:14 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-20 12:13:14 -0700
commit6daf4e670d1eb19a87f2f5175b8afe26ada77d9b (patch)
treecb4595414929835b995048fc2809bd8389297b78 /cloudinit
parent806251d1c1541d4f14a8f7ef7557633ae13c70ea (diff)
downloadvyos-cloud-init-6daf4e670d1eb19a87f2f5175b8afe26ada77d9b.tar.gz
vyos-cloud-init-6daf4e670d1eb19a87f2f5175b8afe26ada77d9b.zip
Add the ability to only fetch a local datasource instead of also trying to fetch an offical datasource from an external source.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/stages.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index f39b6532..334d5004 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -209,13 +209,13 @@ 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, local_only=False):
if self.datasource:
return self.datasource
ds = self._restore_from_cache()
if ds:
- LOG.debug("Restored from cache datasource: %s" % ds)
- else:
+ LOG.debug("Restored from cache, datasource: %s", ds)
+ if not ds and not local_only:
(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...)
@@ -225,10 +225,11 @@ class Init(object):
self.paths,
ds_deps, cfg_list, pkg_list)
LOG.debug("Loaded datasource %s - %s", dsname, ds)
- self.datasource = ds
- # Ensure we adjust our path members datasource
- # now that we have one (thus allowing ipath to be used)
- self.paths.datasource = ds
+ if ds:
+ self.datasource = ds
+ # Ensure we adjust our path members datasource
+ # now that we have one (thus allowing ipath to be used)
+ self.paths.datasource = ds
return ds
def _reflect_cur_instance(self):
@@ -276,8 +277,8 @@ class Init(object):
"%s\n" % (previous_iid))
return iid
- def fetch(self):
- return self._get_data_source()
+ def fetch(self, local_only=False):
+ return self._get_data_source(local_only)
def instancify(self):
return self._reflect_cur_instance()