summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/sources/DataSourceConfigDrive.py25
-rw-r--r--cloudinit/sources/helpers/openstack.py1
2 files changed, 19 insertions, 7 deletions
diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
index 0c35f83a..83cc6b25 100644
--- a/cloudinit/sources/DataSourceConfigDrive.py
+++ b/cloudinit/sources/DataSourceConfigDrive.py
@@ -125,7 +125,14 @@ class DataSourceConfigDrive(openstack.SourceMixin, sources.DataSource):
self.userdata_raw = results.get('userdata')
self.version = results['version']
self.files.update(results.get('files', {}))
- self.vendordata_raw = results.get('vendordata')
+
+ # If there is no vendordata, set vd to an empty dict instead of None
+ vd = results.get('vendordata', {})
+ # if vendordata includes 'cloud-init', then read that explicitly
+ # for cloud-init (for namespacing).
+ if 'cloud-init' in vd:
+ self.vendordata_raw = vd['cloud-init']
+
return True
@@ -160,13 +167,17 @@ def get_ds_mode(cfgdrv_ver, ds_cfg=None, user=None):
return "net"
-def read_config_drive(source_dir, version="2012-08-10"):
- reader = openstack.ConfigDriveReader(source_dir)
- finders = [
- (reader.read_v2, [], {'version': version}),
- (reader.read_v1, [], {}),
- ]
+def read_config_drive(source_dir):
excps = []
+ finders = []
+ reader = openstack.ConfigDriveReader(source_dir)
+
+ # openstack.OS_VERSIONS is stored in chronological order, so to check the
+ # newest first, use reversed()
+ for version in reversed(openstack.OS_VERSIONS):
+ finders.append((reader.read_v2, [], {'version': version}))
+ finders.append((reader.read_v1, [], {}))
+
for (functor, args, kwargs) in finders:
try:
return functor(*args, **kwargs)
diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py
index 3c3de7e4..ed91a55c 100644
--- a/cloudinit/sources/helpers/openstack.py
+++ b/cloudinit/sources/helpers/openstack.py
@@ -48,6 +48,7 @@ OS_LATEST = 'latest'
OS_FOLSOM = '2012-08-10'
OS_GRIZZLY = '2013-04-04'
OS_HAVANA = '2013-10-17'
+# keep this in chronological order by time: add new entries to the end
OS_VERSIONS = (
OS_FOLSOM,
OS_GRIZZLY,