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).
This commit is contained in:
Joshua Harlow 2012-08-20 12:20:26 -07:00
parent 24b7cd50d2
commit 39a66befd8

View File

@ -22,8 +22,6 @@ from cloudinit import util
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
NONE_IID = 'iid-datasource-none'
class DataSourceNone(sources.DataSource): class DataSourceNone(sources.DataSource):
def __init__(self, sys_cfg, distro, paths, ud_proc=None): def __init__(self, sys_cfg, distro, paths, ud_proc=None):
@ -33,10 +31,17 @@ class DataSourceNone(sources.DataSource):
self.userdata_raw = '' self.userdata_raw = ''
def get_data(self): 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 return True
def get_instance_id(self): def get_instance_id(self):
return NONE_IID return 'iid-datasource-none'
def __str__(self): def __str__(self):
return util.obj_name(self) return util.obj_name(self)
@ -46,10 +51,9 @@ class DataSourceNone(sources.DataSource):
return True return True
# Used to match classes to dependencies (this will always match) # Used to match classes to dependencies
datasources = [ datasources = [
(DataSourceNone, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)), (DataSourceNone, (sources.DEP_FILESYSTEM, sources.DEP_NETWORK)),
(DataSourceNone, (sources.DEP_FILESYSTEM,)),
(DataSourceNone, []), (DataSourceNone, []),
] ]