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
1=== modified file 'cloudinit/sources/DataSourceConfigDrive.py'
2--- cloudinit/sources/DataSourceConfigDrive.py 2014-02-25 01:17:07 +0000
3+++ cloudinit/sources/DataSourceConfigDrive.py 2014-09-10 16:03:24 +0000
4@@ -125,7 +125,14 @@
5 self.userdata_raw = results.get('userdata')
6 self.version = results['version']
7 self.files.update(results.get('files', {}))
8- self.vendordata_raw = results.get('vendordata')
9+
10+ # If there is no vendordata, set vd to an empty dict instead of None
11+ vd = results.get('vendordata', {})
12+ # if vendordata includes 'cloud-init', then read that explicitly
13+ # for cloud-init (for namespacing).
14+ if 'cloud-init' in vd:
15+ self.vendordata_raw = vd['cloud-init']
16+
17 return True
18
19
20@@ -160,13 +167,17 @@
21 return "net"
22
23
24-def read_config_drive(source_dir, version="2012-08-10"):
25+def read_config_drive(source_dir):
26+ excps = []
27+ finders = []
28 reader = openstack.ConfigDriveReader(source_dir)
29- finders = [
30- (reader.read_v2, [], {'version': version}),
31- (reader.read_v1, [], {}),
32- ]
33- excps = []
34+
35+ # openstack.OS_VERSIONS is stored in chronological order, so to check the
36+ # newest first, use reversed()
37+ for version in reversed(openstack.OS_VERSIONS):
38+ finders.append((reader.read_v2, [], {'version': version}))
39+ finders.append((reader.read_v1, [], {}))
40+
41 for (functor, args, kwargs) in finders:
42 try:
43 return functor(*args, **kwargs)
44
45=== modified file 'cloudinit/sources/helpers/openstack.py'
46--- cloudinit/sources/helpers/openstack.py 2014-08-27 21:03:43 +0000
47+++ cloudinit/sources/helpers/openstack.py 2014-09-10 16:03:24 +0000
48@@ -48,6 +48,7 @@
49 OS_FOLSOM = '2012-08-10'
50 OS_GRIZZLY = '2013-04-04'
51 OS_HAVANA = '2013-10-17'
52+# keep this in chronological order by time: add new entries to the end
53 OS_VERSIONS = (
54 OS_FOLSOM,
55 OS_GRIZZLY,