fix DataSource base class to set up ds_cfg for 'Net' sources
When the base DataSource class would set 'ds_cfg' for the specific datasources' config, it would fail for the DataSources that are just named 'DataSourceFooNet' and we wanted to set configuration in 'Foo'. For example, both DataSourceOpenNebula and DataSourceOpenNebulaNet want to read datasource config from sources: OpenNebula: foo: bar But without this change, 'ds_cfg' would not be setup properly for OpenNebulaNet.
This commit is contained in:
parent
d151eab415
commit
d1e12ad902
@ -53,9 +53,16 @@ class DataSource(object):
|
||||
self.userdata = None
|
||||
self.metadata = None
|
||||
self.userdata_raw = None
|
||||
|
||||
# find the datasource config name.
|
||||
# remove 'DataSource' from classname on front, and remove 'Net' on end.
|
||||
# Both Foo and FooNet sources expect config in cfg['sources']['Foo']
|
||||
name = type_utils.obj_name(self)
|
||||
if name.startswith(DS_PREFIX):
|
||||
name = name[len(DS_PREFIX):]
|
||||
if name.endswith('Net'):
|
||||
name = name[0:-3]
|
||||
|
||||
self.ds_cfg = util.get_cfg_by_path(self.sys_cfg,
|
||||
("datasource", name), {})
|
||||
if not ud_proc:
|
||||
|
Loading…
x
Reference in New Issue
Block a user