Merge lp:~jason-oldos/cloud-init/upgrade-configdrive into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Jay Faulkner
Status: Merged
Merged at revision: 1010
Proposed branch: lp:~jason-oldos/cloud-init/upgrade-configdrive
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 55 lines (+19/-7)
2 files modified
cloudinit/sources/DataSourceConfigDrive.py (+18/-7)
cloudinit/sources/helpers/openstack.py (+1/-0)
To merge this branch: bzr merge lp:~jason-oldos/cloud-init/upgrade-configdrive
Reviewer Review Type Date Requested Status
Scott Moser Pending
Review via email: mp+232312@code.launchpad.net

Description of the change

Upgraded DataSourceConfigDrive.py to support the most recent Openstack config drive revision.

This exposed a bug -- the vendor_data.json (added this version) was being parsed as yaml. This bug is fixed in this branch as well.

To post a comment you must log in.
1004. By Jay Faulkner

Add failback for older Openstack configdrive versions

- Also utilizing the constants defined in
  cloudinit/sources/helpers/openstack.py for configdrive versions

1005. By Jay Faulkner

Refactor vendor_data handling

vendor_data is guaranteed to be a dict if it exists; if it doesn't
exist ensure it's represented by an empty dict to avoid checking
it to see if it's a dict.

Revision history for this message
Joshua Harlow (harlowja) :
Revision history for this message
Joshua Harlow (harlowja) :
1006. By Jay Faulkner

Update read_config_drive to use OS_VERSIONS tuple for readers

Updated read_config_drive: removed the unused version kwarg, used the
OS_VERSIONS tuple from the openstack helper to avoid hardcoding
versions.

Added a comment to the tuple in helpers/openstack.py asking for it to
be kept in chronological order.

1007. By Jay Faulkner

Only use vendordata under cloud-init key for ConfigDrive

This data will be treated the same as vendordata from other sources.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cloudinit/sources/DataSourceConfigDrive.py'
--- cloudinit/sources/DataSourceConfigDrive.py 2014-02-25 01:17:07 +0000
+++ cloudinit/sources/DataSourceConfigDrive.py 2014-09-10 16:03:24 +0000
@@ -125,7 +125,14 @@
125 self.userdata_raw = results.get('userdata')125 self.userdata_raw = results.get('userdata')
126 self.version = results['version']126 self.version = results['version']
127 self.files.update(results.get('files', {}))127 self.files.update(results.get('files', {}))
128 self.vendordata_raw = results.get('vendordata')128
129 # If there is no vendordata, set vd to an empty dict instead of None
130 vd = results.get('vendordata', {})
131 # if vendordata includes 'cloud-init', then read that explicitly
132 # for cloud-init (for namespacing).
133 if 'cloud-init' in vd:
134 self.vendordata_raw = vd['cloud-init']
135
129 return True136 return True
130137
131138
@@ -160,13 +167,17 @@
160 return "net"167 return "net"
161168
162169
163def read_config_drive(source_dir, version="2012-08-10"):170def read_config_drive(source_dir):
171 excps = []
172 finders = []
164 reader = openstack.ConfigDriveReader(source_dir)173 reader = openstack.ConfigDriveReader(source_dir)
165 finders = [174
166 (reader.read_v2, [], {'version': version}),175 # openstack.OS_VERSIONS is stored in chronological order, so to check the
167 (reader.read_v1, [], {}),176 # newest first, use reversed()
168 ]177 for version in reversed(openstack.OS_VERSIONS):
169 excps = []178 finders.append((reader.read_v2, [], {'version': version}))
179 finders.append((reader.read_v1, [], {}))
180
170 for (functor, args, kwargs) in finders:181 for (functor, args, kwargs) in finders:
171 try:182 try:
172 return functor(*args, **kwargs)183 return functor(*args, **kwargs)
173184
=== modified file 'cloudinit/sources/helpers/openstack.py'
--- cloudinit/sources/helpers/openstack.py 2014-08-27 21:03:43 +0000
+++ cloudinit/sources/helpers/openstack.py 2014-09-10 16:03:24 +0000
@@ -48,6 +48,7 @@
48OS_FOLSOM = '2012-08-10'48OS_FOLSOM = '2012-08-10'
49OS_GRIZZLY = '2013-04-04'49OS_GRIZZLY = '2013-04-04'
50OS_HAVANA = '2013-10-17'50OS_HAVANA = '2013-10-17'
51# keep this in chronological order by time: add new entries to the end
51OS_VERSIONS = (52OS_VERSIONS = (
52 OS_FOLSOM,53 OS_FOLSOM,
53 OS_GRIZZLY,54 OS_GRIZZLY,