summaryrefslogtreecommitdiff
path: root/cloudinit/sources/__init__.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2013-09-10 14:15:30 -0400
committerScott Moser <smoser@ubuntu.com>2013-09-10 14:15:30 -0400
commit8ed952a461ed81af4011e02f3df47add1066cd0f (patch)
tree5638e3d2f58ee5e98ed9a14cadfbc0353b140240 /cloudinit/sources/__init__.py
parentc0d1a59d96a16c080ad8b8278251294cccc21894 (diff)
downloadvyos-cloud-init-8ed952a461ed81af4011e02f3df47add1066cd0f.tar.gz
vyos-cloud-init-8ed952a461ed81af4011e02f3df47add1066cd0f.zip
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.
Diffstat (limited to 'cloudinit/sources/__init__.py')
-rw-r--r--cloudinit/sources/__init__.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
index 1dfdf9bf..7dc1fbde 100644
--- a/cloudinit/sources/__init__.py
+++ b/cloudinit/sources/__init__.py
@@ -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: