Merge lp:~huerlisi/vmbuilder/dev into lp:vmbuilder

Proposed by Simon Huerlimann
Status: Merged
Approved by: Soren Hansen
Approved revision: no longer in the source branch.
Merged at revision: 452
Proposed branch: lp:~huerlisi/vmbuilder/dev
Merge into: lp:vmbuilder
Diff against target: 132 lines (+30/-16)
4 files modified
VMBuilder/contrib/cli.py (+23/-13)
VMBuilder/disk.py (+1/-1)
VMBuilder/plugins/kvm/vm.py (+4/-0)
VMBuilder/plugins/ubuntu/distro.py (+2/-2)
To merge this branch: bzr merge lp:~huerlisi/vmbuilder/dev
Reviewer Review Type Date Requested Status
Soren Hansen Approve
Review via email: mp+24724@code.launchpad.net

Description of the change

Hi Soren

Here's my attempt at helping to make vmbuilder the simplest VM builder on Earth;-)

My branch contains the following changes:
* Some typo/language fixes
* Support for swapsize == 0, thereby fixing Launchpad bug #403149
* Support more than one raw devices, including support for partition files

Currently mostly doing coding using Ruby/Git/Github, this is my first attempt at Python/Bzr/Launchpad. I would appreciate any hint (create topic branches for bug fixes, use XXX commenting style...) on how to do vmbuilder development which fits into your workflow.

Thanx for all the good stuff and kind regards
Simon Hürlimann

To post a comment you must log in.
lp:~huerlisi/vmbuilder/dev updated
439. By Soren Hansen

Make install_file work in non-context plugins.

440. By Soren Hansen

Revive firstscripts plugins. This fixes the --firstboot and --firstlogin
options, both of which went missing with 0.12.

441. By Soren Hansen

Replace "-p" argument to blkid with "-c /dev/null". According to the docs, they should be equivalent, but in some versions of blkid, -s is not properly applied when using -p. Thanks to Danilo Šegan (Данило Шеган) for the patch.

442. By Soren Hansen

Update my (Soren's) e-mail address.

443. By Soren Hansen

Add QEMu as a target Hypervisor. It acts exactly the same as KVM, but
the libvirt plugin makes sure it runs through qemu rather than kvm. This
is useful for non-VT-capable hosts.

444. By Soren Hansen

Prepare for 0.12.4 release.

445. By Soren Hansen

Fall back to a C locale if no LANG environment is set.

446. By Soren Hansen

Move get_locale out of Ubuntu class and add unit tests for it.

447. By Soren Hansen

Merge lp:~danilo/vmbuilder/bug-536940

448. By Soren Hansen

Add Maverick as a valid Ubuntu series.

449. By Soren Hansen

Dont' attempt to locale-gen a C locale. That's silly.

450. By Soren Hansen

Merge lp:~lfaraone/vmbuilder/lp580237

Revision history for this message
Soren Hansen (soren) wrote :

On Wed, May 05, 2010 at 06:32:29AM -0000, Simon Huerlimann wrote:
> Simon Huerlimann has proposed merging lp:~huerlisi/vmbuilder/dev into lp:vmbuilder.

Thank you! Please accept my apologies for the delay. I'll try to respond
in a more timely fashion in the future.

> @@ -234,29 +238,35 @@
> try:
> curdisk = list()
> size = 0
> + count = 0
> for line in file(self.options.part):
> pair = line.strip().split(' ',1)
[...]
> + def do_disk(self, hypervisor, curdisk, size, count):
> default_filesystem = hypervisor.distro.preferred_filesystem()
> - disk = hypervisor.add_disk(util.tmpfile(keep=False), size+1)
> - logging.debug("do_disk - size: %d" % size)
> + if self.options.raw:
> + disk = hypervisor.add_disk(filename=self.options.raw[count])

I took the liberty of renaming "count" to "disk_idx" for clarity.

Other than that, it looks great.

  review approve
  merge approved

--
Soren Hansen
Ubuntu Developer
http://www.ubuntu.com/

review: Approve
lp:~huerlisi/vmbuilder/dev updated
451. By Soren Hansen

Add an .overwrite attribute to Context objects, defaulting to False.
Set it according to the --overwrite option in the CLI.
Fix a 0.11ism in libvirt plugin.

452. By Soren Hansen

Merge lp:~huerlisi/vmbuilder/dev

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'VMBuilder/contrib/cli.py'
2--- VMBuilder/contrib/cli.py 2010-03-30 20:51:26 +0000
3+++ VMBuilder/contrib/cli.py 2010-05-06 13:54:27 +0000
4@@ -55,8 +55,8 @@
5 group.add_option('--rootsize', metavar='SIZE', default=4096, help='Size (in MB) of the root filesystem [default: %default]')
6 group.add_option('--optsize', metavar='SIZE', default=0, help='Size (in MB) of the /opt filesystem. If not set, no /opt filesystem will be added.')
7 group.add_option('--swapsize', metavar='SIZE', default=1024, help='Size (in MB) of the swap partition [default: %default]')
8- group.add_option('--raw', metavar='PATH', type='str', help="Specify a file (or block device) to as first disk image.")
9- group.add_option('--part', metavar='PATH', type='str', help="Allows to specify a partition table in PATH each line of partfile should specify (root first): \n mountpoint size \none per line, separated by space, where size is in megabytes. You can have up to 4 virtual disks, a new disk starts on a line containing only '---'. ie: \n root 2000 \n /boot 512 \n swap 1000 \n --- \n /var 8000 \n /var/log 2000")
10+ group.add_option('--raw', metavar='PATH', type='str', action='append', help="Specify a file (or block device) to use as first disk image (can be specified multiple times).")
11+ group.add_option('--part', metavar='PATH', type='str', help="Specify a partition table in PATH. Each line of partfile should specify (root first): \n mountpoint size \none per line, separated by space, where size is in megabytes. You can have up to 4 virtual disks, a new disk starts on a line containing only '---'. ie: \n root 2000 \n /boot 512 \n swap 1000 \n --- \n /var 8000 \n /var/log 2000")
12 optparser.add_option_group(group)
13
14 hypervisor, distro = self.handle_args(optparser, sys.argv[1:])
15@@ -190,14 +190,17 @@
16 if hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
17 tmpfile = util.tmpfile(keep=False)
18 hypervisor.add_filesystem(filename=tmpfile, size='%dM' % rootsize, type='ext3', mntpnt='/')
19- tmpfile = util.tmpfile(keep=False)
20- hypervisor.add_filesystem(filename=tmpfile, size='%dM' % swapsize, type='swap', mntpnt=None)
21+ if swapsize > 0:
22+ tmpfile = util.tmpfile(keep=False)
23+ hypervisor.add_filesystem(filename=tmpfile, size='%dM' % swapsize, type='swap', mntpnt=None)
24 if optsize > 0:
25 tmpfile = util.tmpfile(keep=False)
26 hypervisor.add_filesystem(filename=tmpfile, size='%dM' % optsize, type='ext3', mntpnt='/opt')
27 else:
28 if self.options.raw:
29- disk = hypervisor.add_disk(filename=self.options.raw)
30+ for raw_disk in self.options.raw:
31+ hypervisor.add_disk(filename=raw_disk)
32+ disk = hypervisor.disks[0]
33 else:
34 size = rootsize + swapsize + optsize
35 tmpfile = util.tmpfile(keep=False)
36@@ -205,8 +208,9 @@
37 offset = 0
38 disk.add_part(offset, rootsize, default_filesystem, '/')
39 offset += rootsize
40- disk.add_part(offset, swapsize, 'swap', 'swap')
41- offset += swapsize
42+ if swapsize > 0:
43+ disk.add_part(offset, swapsize, 'swap', 'swap')
44+ offset += swapsize
45 if optsize > 0:
46 disk.add_part(offset, optsize, default_filesystem, '/opt')
47 else:
48@@ -234,29 +238,35 @@
49 try:
50 curdisk = list()
51 size = 0
52+ count = 0
53 for line in file(self.options.part):
54 pair = line.strip().split(' ',1)
55 if pair[0] == '---':
56- self.do_disk(hypervisor, curdisk, size)
57+ self.do_disk(hypervisor, curdisk, size, count)
58 curdisk = list()
59 size = 0
60+ count += 1
61 elif pair[0] != '':
62 logging.debug("part: %s, size: %d" % (pair[0], int(pair[1])))
63 curdisk.append((pair[0], pair[1]))
64 size += int(pair[1])
65
66- self.do_disk(hypervisor, curdisk, size)
67+ self.do_disk(hypervisor, curdisk, size, count)
68
69 except IOError, (errno, strerror):
70 hypervisor.optparser.error("%s parsing --part option: %s" % (errno, strerror))
71
72- def do_disk(self, hypervisor, curdisk, size):
73+ def do_disk(self, hypervisor, curdisk, size, count):
74 default_filesystem = hypervisor.distro.preferred_filesystem()
75- disk = hypervisor.add_disk(util.tmpfile(keep=False), size+1)
76- logging.debug("do_disk - size: %d" % size)
77+ if self.options.raw:
78+ disk = hypervisor.add_disk(filename=self.options.raw[count])
79+ else:
80+ disk = hypervisor.add_disk(util.tmpfile(keep=False), size+1)
81+
82+ logging.debug("do_disk #%i - size: %d" % (count, size))
83 offset = 0
84 for pair in curdisk:
85- logging.debug("do_disk - part: %s, size: %s, offset: %d" % (pair[0], pair[1], offset))
86+ logging.debug("do_disk #%i - part: %s, size: %s, offset: %d" % (count, pair[0], pair[1], offset))
87 if pair[0] == 'root':
88 disk.add_part(offset, int(pair[1]), default_filesystem, '/')
89 elif pair[0] == 'swap':
90
91=== modified file 'VMBuilder/disk.py'
92--- VMBuilder/disk.py 2010-03-29 22:29:36 +0000
93+++ VMBuilder/disk.py 2010-05-06 13:54:27 +0000
94@@ -183,7 +183,7 @@
95
96 if tries >= max_tries:
97 # try it one last time
98- logging.info("Could not unmount '%s' after '%d' attempts. Final attempt" % (self.filename, tries))
99+ logging.info("Could not unmap '%s' after '%d' attempts. Final attempt" % (self.filename, tries))
100 run_cmd('kpartx', '-d', self.filename, ignore_fail=ignore_fail)
101
102 for part in self.partitions:
103
104=== modified file 'VMBuilder/plugins/kvm/vm.py'
105--- VMBuilder/plugins/kvm/vm.py 2010-02-24 22:16:46 +0000
106+++ VMBuilder/plugins/kvm/vm.py 2010-05-06 13:54:27 +0000
107@@ -48,6 +48,10 @@
108 self.cmdline += ['"$@"']
109
110 def deploy(self, destdir):
111+ # No need create run script if vm is registered with libvirt
112+ if self.context.get_setting('libvirt'):
113+ return
114+
115 script = '%s/run.sh' % destdir
116 fp = open(script, 'w')
117 fp.write("#!/bin/sh\n\nexec %s\n" % ' '.join(self.cmdline))
118
119=== modified file 'VMBuilder/plugins/ubuntu/distro.py'
120--- VMBuilder/plugins/ubuntu/distro.py 2010-03-30 03:17:57 +0000
121+++ VMBuilder/plugins/ubuntu/distro.py 2010-05-06 13:54:27 +0000
122@@ -39,8 +39,8 @@
123
124 def register_options(self):
125 group = self.setting_group('Package options')
126- group.add_setting('addpkg', type='list', metavar='PKG', help='Install PKG into the guest (can be specfied multiple times).')
127- group.add_setting('removepkg', type='list', metavar='PKG', help='Remove PKG from the guest (can be specfied multiple times)')
128+ group.add_setting('addpkg', type='list', metavar='PKG', help='Install PKG into the guest (can be specified multiple times).')
129+ group.add_setting('removepkg', type='list', metavar='PKG', help='Remove PKG from the guest (can be specified multiple times)')
130 group.add_setting('seedfile', metavar="SEEDFILE", help='Seed the debconf database with the contents of this seed file before installing packages')
131
132 group = self.setting_group('General OS options')

Subscribers

People subscribed via source and target branches