summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-19 21:38:43 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-19 21:38:43 -0700
commitbd5075dc77219df36cd1209582d3e004a6d96449 (patch)
treef25901a25ba27da9eb46d9454eb724f92ec2d936 /cloudinit
parent28e0ecf1b7c99a783bdba901544fa9c1a8e37f65 (diff)
downloadvyos-cloud-init-bd5075dc77219df36cd1209582d3e004a6d96449.tar.gz
vyos-cloud-init-bd5075dc77219df36cd1209582d3e004a6d96449.zip
1. Don't force the datasource to always fetch in construction (sometimes not wanted)
2. Add a run single transform function that can be used by the run single main entrypoint action 3. Add a find transform function to be used by the run single action to determine if a transform name is valid
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/stages.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index 95ac5313..7e64d3cd 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -379,7 +379,7 @@ class Init(object):
class Transforms(object):
def __init__(self, init, cfg_files=None):
- self.datasource = init.fetch()
+ self.datasource = init.datasource
self.cfg_files = cfg_files
self.base_cfg = copy.deepcopy(init.cfg)
self.init = init
@@ -418,7 +418,6 @@ class Transforms(object):
return util.mergemanydict(t_cfgs)
-
def _read_transforms(self, name):
module_list = []
if name not in self.cfg:
@@ -513,7 +512,31 @@ class Transforms(object):
failures.append((name, e))
return (am_ran, failures)
- def run(self, name):
- raw_mods = self._read_transforms(name)
+ def find_transform(self, tr_name, sections):
+ found_where = []
+ for n in sections:
+ mods = self._read_transforms(n)
+ for mod_info in mods:
+ if mod_info.get('mod') == tr_name:
+ found_where.append(n)
+ return found_where
+
+ def run_single(self, tr_name, section):
+ mods = self._read_transforms(section)
+ mod_tr = None
+ for mod_info in mods:
+ if mod_info.get('mod') == tr_name:
+ mod_tr = mod_info
+ break
+ if not mod_tr:
+ # Nothing to run, does that transform exist there??
+ return (0, 0)
+ else:
+ raw_mods = [mod_tr]
+ mostly_mods = self._fixup_transforms(raw_mods)
+ return self._run_transforms(mostly_mods)
+
+ def run_section(self, section_name):
+ raw_mods = self.read_transforms(section_name)
mostly_mods = self._fixup_transforms(raw_mods)
return self._run_transforms(mostly_mods)