From c1d2bc7ff9824b967cca21ed0254e4ee47168b10 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 20 Aug 2012 12:20:26 -0700 Subject: Remove the matching of the filesystem dep and add in the ability to use any fallback userdata or metadata found in the datasource config (if provided). --- cloudinit/sources/DataSourceNone.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'cloudinit/sources/DataSourceNone.py') diff --git a/cloudinit/sources/DataSourceNone.py b/cloudinit/sources/DataSourceNone.py index e53eb280..b186113c 100644 --- a/cloudinit/sources/DataSourceNone.py +++ b/cloudinit/sources/DataSourceNone.py @@ -22,8 +22,6 @@ from cloudinit import util LOG = logging.getLogger(__name__) -NONE_IID = 'iid-datasource-none' - class DataSourceNone(sources.DataSource): def __init__(self, sys_cfg, distro, paths, ud_proc=None): @@ -33,10 +31,17 @@ class DataSourceNone(sources.DataSource): self.userdata_raw = '' def get_data(self): + # If the datasource config has any provided 'fallback' + # userdata or metadata, use it... + if 'userdata' in self.ds_cfg: + self.userdata = self.ds_cfg['userdata'] + self.userdata_raw = util.yaml_dumps(self.userdata) + if 'metadata' in self.ds_cfg: + self.metadata = self.ds_cfg['metadata'] return True def get_instance_id(self): - return NONE_IID + return 'iid-datasource-none' def __str__(self): return util.obj_name(self) @@ -46,10 +51,9 @@ class DataSourceNone(sources.DataSource): return True -# Used to match classes to dependencies (this will always match) +# Used to match classes to dependencies datasources = [ (DataSourceNone, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)), - (DataSourceNone, (sources.DEP_FILESYSTEM,)), (DataSourceNone, []), ] -- cgit v1.2.3