vmbuilder team mailing list archive
-
vmbuilder team
-
Mailing list archive
-
Message #00033
[Merge] lp:~huerlisi/vmbuilder/dev into lp:vmbuilder
Simon Huerlimann has proposed merging lp:~huerlisi/vmbuilder/dev into lp:vmbuilder.
Requested reviews:
VMBuilder (vmbuilder)
Related bugs:
#403149 vmbuilder should allow for no swapfile
https://bugs.launchpad.net/bugs/403149
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
--
https://code.launchpad.net/~huerlisi/vmbuilder/dev/+merge/24724
Your team VMBuilder is requested to review the proposed merge of lp:~huerlisi/vmbuilder/dev into lp:vmbuilder.
=== modified file 'VMBuilder/contrib/cli.py'
--- VMBuilder/contrib/cli.py 2010-03-30 20:51:26 +0000
+++ VMBuilder/contrib/cli.py 2010-05-05 06:32:28 +0000
@@ -55,8 +55,8 @@
group.add_option('--rootsize', metavar='SIZE', default=4096, help='Size (in MB) of the root filesystem [default: %default]')
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.')
group.add_option('--swapsize', metavar='SIZE', default=1024, help='Size (in MB) of the swap partition [default: %default]')
- group.add_option('--raw', metavar='PATH', type='str', help="Specify a file (or block device) to as first disk image.")
- 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")
+ 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).")
+ 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")
optparser.add_option_group(group)
hypervisor, distro = self.handle_args(optparser, sys.argv[1:])
@@ -190,14 +190,17 @@
if hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
tmpfile = util.tmpfile(keep=False)
hypervisor.add_filesystem(filename=tmpfile, size='%dM' % rootsize, type='ext3', mntpnt='/')
- tmpfile = util.tmpfile(keep=False)
- hypervisor.add_filesystem(filename=tmpfile, size='%dM' % swapsize, type='swap', mntpnt=None)
+ if swapsize > 0:
+ tmpfile = util.tmpfile(keep=False)
+ hypervisor.add_filesystem(filename=tmpfile, size='%dM' % swapsize, type='swap', mntpnt=None)
if optsize > 0:
tmpfile = util.tmpfile(keep=False)
hypervisor.add_filesystem(filename=tmpfile, size='%dM' % optsize, type='ext3', mntpnt='/opt')
else:
if self.options.raw:
- disk = hypervisor.add_disk(filename=self.options.raw)
+ for raw_disk in self.options.raw:
+ hypervisor.add_disk(filename=raw_disk)
+ disk = hypervisor.disks[0]
else:
size = rootsize + swapsize + optsize
tmpfile = util.tmpfile(keep=False)
@@ -205,8 +208,9 @@
offset = 0
disk.add_part(offset, rootsize, default_filesystem, '/')
offset += rootsize
- disk.add_part(offset, swapsize, 'swap', 'swap')
- offset += swapsize
+ if swapsize > 0:
+ disk.add_part(offset, swapsize, 'swap', 'swap')
+ offset += swapsize
if optsize > 0:
disk.add_part(offset, optsize, default_filesystem, '/opt')
else:
@@ -234,29 +238,35 @@
try:
curdisk = list()
size = 0
+ count = 0
for line in file(self.options.part):
pair = line.strip().split(' ',1)
if pair[0] == '---':
- self.do_disk(hypervisor, curdisk, size)
+ self.do_disk(hypervisor, curdisk, size, count)
curdisk = list()
size = 0
+ count += 1
elif pair[0] != '':
logging.debug("part: %s, size: %d" % (pair[0], int(pair[1])))
curdisk.append((pair[0], pair[1]))
size += int(pair[1])
- self.do_disk(hypervisor, curdisk, size)
+ self.do_disk(hypervisor, curdisk, size, count)
except IOError, (errno, strerror):
hypervisor.optparser.error("%s parsing --part option: %s" % (errno, strerror))
- def do_disk(self, hypervisor, curdisk, size):
+ 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])
+ else:
+ disk = hypervisor.add_disk(util.tmpfile(keep=False), size+1)
+
+ logging.debug("do_disk #%i - size: %d" % (count, size))
offset = 0
for pair in curdisk:
- logging.debug("do_disk - part: %s, size: %s, offset: %d" % (pair[0], pair[1], offset))
+ logging.debug("do_disk #%i - part: %s, size: %s, offset: %d" % (count, pair[0], pair[1], offset))
if pair[0] == 'root':
disk.add_part(offset, int(pair[1]), default_filesystem, '/')
elif pair[0] == 'swap':
=== modified file 'VMBuilder/disk.py'
--- VMBuilder/disk.py 2010-03-29 22:29:36 +0000
+++ VMBuilder/disk.py 2010-05-05 06:32:28 +0000
@@ -183,7 +183,7 @@
if tries >= max_tries:
# try it one last time
- logging.info("Could not unmount '%s' after '%d' attempts. Final attempt" % (self.filename, tries))
+ logging.info("Could not unmap '%s' after '%d' attempts. Final attempt" % (self.filename, tries))
run_cmd('kpartx', '-d', self.filename, ignore_fail=ignore_fail)
for part in self.partitions:
=== modified file 'VMBuilder/plugins/ubuntu/distro.py'
--- VMBuilder/plugins/ubuntu/distro.py 2010-03-30 03:17:57 +0000
+++ VMBuilder/plugins/ubuntu/distro.py 2010-05-05 06:32:28 +0000
@@ -39,8 +39,8 @@
def register_options(self):
group = self.setting_group('Package options')
- group.add_setting('addpkg', type='list', metavar='PKG', help='Install PKG into the guest (can be specfied multiple times).')
- group.add_setting('removepkg', type='list', metavar='PKG', help='Remove PKG from the guest (can be specfied multiple times)')
+ group.add_setting('addpkg', type='list', metavar='PKG', help='Install PKG into the guest (can be specified multiple times).')
+ group.add_setting('removepkg', type='list', metavar='PKG', help='Remove PKG from the guest (can be specified multiple times)')
group.add_setting('seedfile', metavar="SEEDFILE", help='Seed the debconf database with the contents of this seed file before installing packages')
group = self.setting_group('General OS options')