summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-16 10:57:28 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-16 10:57:28 -0700
commit60f176e13836d77616ae07774fda2139fde790fc (patch)
tree16ccc7670f53e2ff503a04757fbad07d94feffdb /cloudinit
parentdb19f526b65f11ecabfbdbe86cb546881727d647 (diff)
downloadvyos-cloud-init-60f176e13836d77616ae07774fda2139fde790fc.tar.gz
vyos-cloud-init-60f176e13836d77616ae07774fda2139fde790fc.zip
Allow the user data processor to be passed in.
This could and should be useful for unit testing.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/sources/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
index 46350255..5842d41b 100644
--- a/cloudinit/sources/__init__.py
+++ b/cloudinit/sources/__init__.py
@@ -42,7 +42,7 @@ class DataSource(object):
__metaclass__ = abc.ABCMeta
- def __init__(self, sys_cfg, distro, paths):
+ def __init__(self, sys_cfg, distro, paths, ud_proc=None):
self.sys_cfg = sys_cfg
self.distro = distro
self.paths = paths
@@ -54,11 +54,15 @@ class DataSource(object):
name = name[DS_PREFIX:]
self.ds_cfg = util.get_cfg_by_path(self.sys_cfg,
("datasource", name), {})
+ if not ud_proc:
+ self.ud_proc = ud.UserDataProcessor(self.paths)
+ else:
+ self.ud_proc = ud_proc
def get_userdata(self):
if self.userdata is None:
raw_data = self.get_userdata_raw()
- self.userdata = ud.UserDataProcessor(self.paths).process(raw_data)
+ self.userdata = self.ud_proc.process(raw_data)
return self.userdata
def get_userdata_raw(self):