Merge lp:~jeffmarcom/checkbox/kvm-cloud_data into lp:checkbox
Status: | Merged |
---|---|
Approved by: | Zygmunt Krynicki |
Approved revision: | 1996 |
Merged at revision: | 1994 |
Proposed branch: | lp:~jeffmarcom/checkbox/kvm-cloud_data |
Merge into: | lp:checkbox |
Diff against target: |
199 lines (+75/-29) 2 files modified
debian/changelog (+3/-1) scripts/virtualization (+72/-28) |
To merge this branch: | bzr merge lp:~jeffmarcom/checkbox/kvm-cloud_data |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zygmunt Krynicki (community) | Approve | ||
Review via email: mp+153878@code.launchpad.net |
Description of the change
This fixes an issue where a recent change in cloud-init in the latest 12.04.2 precise cloud images prevented the VM from booting successfully if cloud config data was not supplied.
The virtualization test now creates a cloud data disk that includes generic user data and meta data files to assist during cloud-init stages of boot process. Supplying this data is dependent on whether the "cloud" string is part of the image to test.
Output from run:
DEBUG:root:
DEBUG:root:Creating cloud user-data
DEBUG:root:Creating cloud meta-data
DEBUG:root:
DEBUG:root:
DEBUG:root:Using params:kvm -m 256 -net nic -net user,net=
Cloud-init v. 0.7.2 running 'modules:final' at Mon, 18 Mar 2013 17:21:40 +0000. Up 201.27 seconds.
========= CERTIFICATION TEST =========
ci-info: no authorized ssh keys fingerprints found for user ubuntu.ci-info: no authorized ssh keys fingerprints found for user ubuntu.ec2:
ec2: #######
ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----
ec2: 1024 19:d3:e4:
ec2: 256 13:74:68:
ec2: 2048 6c:f1:e8:
ec2: -----END SSH HOST KEY FINGERPRINTS-----
ec2: #######
-----BEGIN SSH HOST KEY KEYS-----
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXN
ssh-rsa AAAAB3NzaC1yc2E
-----END SSH HOST KEY KEYS-----
Cloud-init v. 0.7.2 finished at Mon, 18 Mar 2013 17:21:44 +0000. Datasource DataSourceNoClo
32 - logging. error(" Failed download {}: {}".format( image_url, exception)) error(" Failed download: %s", exception)
33 + logging.
You may want to replace that with:
logging. exception( "Failed to download image: %s", image_url)
This has the advantage of knowing everything there is to know about the exception _and_ displaying a traceback.
89 +#cloud-config
90 +
91 +# run commands
92 +# default: none
93 +# runcmd contains a list of either lists or a string
94 +# each item will be executed in order at rc.local like level with
95 +# output to the console
96 +# - if the item is a list, the items will be properly executed as if
97 +# passed to execve(3) (with the first arg as the command).
98 +# - if the item is a string, it will be simply written to the file and
99 +# will be interpreted by 'sh'
100 +#
101 +# Note, that the list has to be proper yaml, so you have to escape
102 +# any characters yaml would eat (':' can be problematic)
Perhaps the comment in the embedded data section is not that interesting, this is an automated test after all. I would move that comment to the method, indented it as with everything else.
113 + with open(file, "wt") as data_file: data_file. fileno( ), 0o777)
114 + os.fchmod(
I would use mode=0o777 there, otherwise there is a race condition where an attacker can open the file before you change the permission. After that the attacker can read or write anything.
Still, what's the point of using 0o777?
111 + for file in ['user-data', 'meta-data']: debug(" Creating cloud %s", file) data_file. fileno( ), 0o777) write(vars( )[file. replace( "-", "_")]) iso_cmd) , stderr=PIPE, stdout=PIPE, newlines= True)
112 + logging.
113 + with open(file, "wt") as data_file:
114 + os.fchmod(
115 + data_file.
116 +
117 + # Create Data ISO hosting user & meta cloud config data
118 + iso_cmd = \
119 + '''
120 + genisoimage -output seed.iso -volid
121 + cidata -joliet -rock user-data meta-data
122 + '''
123 +
124 + iso_build = Popen(
125 + shlex.split(
126 + universal_
I think it's much better to just use ['genisoimage', '-output', 'seed.iso', '-volid', ...] and not use shlex for that.
128 + error, output = iso_build. communicate( ) returncode != 0: error(" Cloud data disk creation failed")
129 +
130 + if iso_build.
131 + logging.
Perhaps what you want instead is subprocess. check_output( ) it does everything above in one call
None of that is a critical problem though, I'm not -1 this