Merge lp:~nuclearbob/utah/bug1043419 into lp:utah

Proposed by Max Brustkern
Status: Merged
Approved by: Javier Collado
Approved revision: 692
Merged at revision: 696
Proposed branch: lp:~nuclearbob/utah/bug1043419
Merge into: lp:utah
Diff against target: 16 lines (+3/-3)
1 file modified
utah/provisioning/vm/libvirtvm.py (+3/-3)
To merge this branch: bzr merge lp:~nuclearbob/utah/bug1043419
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Max Brustkern (community) Needs Resubmitting
Joe Talbott (community) Approve
Review via email: mp+127795@code.launchpad.net

Description of the change

This branch should fix bug 1043419, which caused attempts to provision a VM with multiple disks to fail. I don't have an preseed capable of automating this provisioning yet, so that will need to be provided by test case authors wishing to utilize multiple disks, but this fixes the code issue.

To post a comment you must log in.
Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks okay to me.

Merge away!

review: Approve
Revision history for this message
Javier Collado (javier.collado) wrote :

I don't see what was the issue, but I believe that enumerate would be a more pythonic way to iterate over the indexes and sizes in the array:

for index, size in enumerate(disksizes):
    disksize = '{}G'.format(size)
    basename = 'disk{}.qcow2.format(index)

review: Needs Fixing
Revision history for this message
Javier Collado (javier.collado) wrote :

In the previous code, there is a quote missing:
'disk{}.qcow2'.format(index)

lp:~nuclearbob/utah/bug1043419 updated
691. By Max Brustkern

Changed to use enumerate

692. By Max Brustkern

Fixed typo

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Thanks, I didn't know about enumerate. I've added that, and tested VM creation with a few different disk combinations. Let me know if you've got any other thoughts, and if not, I'll merge.

review: Needs Resubmitting
Revision history for this message
Javier Collado (javier.collado) wrote :

Looks good to me now. Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/provisioning/vm/libvirtvm.py'
2--- utah/provisioning/vm/libvirtvm.py 2012-08-30 08:31:37 +0000
3+++ utah/provisioning/vm/libvirtvm.py 2012-10-04 15:11:22 +0000
4@@ -426,9 +426,9 @@
5 if disksizes is None:
6 disksizes = self.disksizes
7 self.disks = []
8- for size in disksizes:
9- disksize = str(size) + 'G'
10- basename = 'disk' + str(disksizes.index(size)) + '.qcow2'
11+ for index, size in enumerate(disksizes):
12+ disksize = '{}G'.format(size)
13+ basename = 'disk{}.qcow2'.format(index)
14 diskfile = os.path.join(self.directory, basename)
15 if not os.path.isfile(diskfile):
16 cmd = ['qemu-img', 'create', '-f', 'qcow2', diskfile, disksize]

Subscribers

People subscribed via source and target branches