[Pkg-escience-soc2009] [SCM] Tool for creating VM images. branch, master, updated. 997bba691102edb88e5d92e641a8a5c5a72cc659

David Wendt dcrkid at yahoo.com
Tue Jun 16 22:12:12 UTC 2009


The following commit has been merged in the master branch:
commit a6e3149ef3bac763508aba1dba1f4db6baab75fb
Author: David Wendt <dcrkid at yahoo.com>
Date:   Tue Jun 16 17:15:39 2009 -0400

    VMBuilder 0.11 - now with EC2 patches and everything else you could want except Debian support

diff --git a/VMBuilder/__init__.py b/VMBuilder/__init__.py
index 87e2721..3a1edb0 100644
--- a/VMBuilder/__init__.py
+++ b/VMBuilder/__init__.py
@@ -1,14 +1,13 @@
 #!/usr/bin/python
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/disk.py b/VMBuilder/disk.py
index 627c710..603cb15 100644
--- a/VMBuilder/disk.py
+++ b/VMBuilder/disk.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -59,7 +58,7 @@ class Disk(object):
             self.filename = filename
         else:
             if self.preallocated:
-                raise VMBuilderException('Preallocated was set, but no filename given')
+                raise VMBuilderUserError('Preallocated was set, but no filename given')
             self.filename = 'disk%d.img' % len(self.vm.disks)
 
         self.partitions = []
@@ -180,7 +179,7 @@ class Disk(object):
         @type  destdir: string
         @param destdir: Target location of converted disk image
         @type  format: string
-        @param format: The target format (as understood by qemu-img)
+        @param format: The target format (as understood by qemu-img or vdi)
         @rtype:  string
         @return: the name of the converted image
         """
@@ -194,7 +193,10 @@ class Disk(object):
         destfile = '%s/%s.%s' % (destdir, filename, format)
 
         logging.info('Converting %s to %s, format %s' % (self.filename, format, destfile))
-        run_cmd(qemu_img_path(), 'convert', '-O', format, self.filename, destfile)
+        if format == 'vdi':
+            run_cmd(vbox_manager_path(), 'convertfromraw', '-format', 'VDI', self.filename, destfile)
+        else:
+            run_cmd(qemu_img_path(), 'convert', '-O', format, self.filename, destfile)
         os.unlink(self.filename)
         self.filename = os.path.abspath(destfile)
         return destfile
@@ -426,3 +428,10 @@ def qemu_img_path():
             path = '%s%s%s' % (dir, os.path.sep, exe)
             if os.access(path, os.X_OK):
                 return path
+
+def vbox_manager_path():
+    exe = 'VBoxManage'
+    for dir in os.environ['PATH'].split(os.path.pathsep):
+        path = '%s%s%s' % (dir, os.path.sep, exe)
+        if os.access(path, os.X_OK):
+            return path
diff --git a/VMBuilder/distro.py b/VMBuilder/distro.py
index b88c029..6e322d2 100644
--- a/VMBuilder/distro.py
+++ b/VMBuilder/distro.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -32,3 +31,6 @@ class Distro(VMBuilder.plugins.Plugin):
 
     def post_mount(self, fs):
         """Called each time a filesystem is mounted to let the distro add things to the filesystem"""
+
+    def install_vmbuilder_log(self, logfile):
+        """Let the distro copy the install logfile to the guest"""
diff --git a/VMBuilder/exception.py b/VMBuilder/exception.py
index dc4f09c..33099ea 100644
--- a/VMBuilder/exception.py
+++ b/VMBuilder/exception.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/frontend.py b/VMBuilder/frontend.py
index 8af774b..9e4a725 100644
--- a/VMBuilder/frontend.py
+++ b/VMBuilder/frontend.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/hypervisor.py b/VMBuilder/hypervisor.py
index cd0dfe2..46c12ce 100644
--- a/VMBuilder/hypervisor.py
+++ b/VMBuilder/hypervisor.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/log.py b/VMBuilder/log.py
index fb2c53a..ed89959 100644
--- a/VMBuilder/log.py
+++ b/VMBuilder/log.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,14 +19,25 @@
 #    Logging
 
 import logging
+import os
+import tempfile
 
-FORMAT='%(asctime)s %(levelname)-8s %(message)s'
-logging.basicConfig(format=FORMAT, level=logging.INFO)
+format = '%(asctime)s %(levelname)-8s: %(message)s'
+
+fd, logfile = tempfile.mkstemp()
+
+# Log everything to the logfile
+logging.basicConfig(format=format, level=logging.DEBUG, datefmt='%Y-%m-%d %H:%M', stream=os.fdopen(fd, 'a+'), filemode='w')
+
+console = logging.StreamHandler()
+console.setLevel(logging.INFO)
+console.setFormatter(logging.Formatter(format))
+logging.getLogger('').addHandler(console)
 
 def set_verbosity(option, opt_str, value, parser):
     if opt_str == '--debug':
-        logging.getLogger().setLevel(logging.DEBUG)
+        console.setLevel(logging.DEBUG)
     elif opt_str == '--verbose':
-        logging.getLogger().setLevel(logging.INFO)
+        console.setLevel(logging.INFO)
     elif opt_str == '--quiet':
-        logging.getLogger().setLevel(logging.CRITICAL)
+        console.setLevel(logging.CRITICAL)
diff --git a/VMBuilder/plugins/__init__.py b/VMBuilder/plugins/__init__.py
index c938e1c..044e8c8 100644
--- a/VMBuilder/plugins/__init__.py
+++ b/VMBuilder/plugins/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/cli/__init__.py b/VMBuilder/plugins/cli/__init__.py
index 30f0602..e0f148a 100644
--- a/VMBuilder/plugins/cli/__init__.py
+++ b/VMBuilder/plugins/cli/__init__.py
@@ -1,12 +1,11 @@
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,6 +22,7 @@ import optparse
 import sys
 import textwrap
 import VMBuilder
+from VMBuilder.disk import parse_size
 import VMBuilder.hypervisor
 _ = gettext
 
@@ -42,9 +42,10 @@ class CLI(VMBuilder.Frontend):
                     break
 
             vm = VMBuilder.VM(conf)
-            vm.register_setting('--rootsize', metavar='SIZE', type='int', default=4096, help='Size (in MB) of the root filesystem [default: %default]')
-            vm.register_setting('--optsize', metavar='SIZE', type='int', default=0, help='Size (in MB) of the /opt filesystem. If not set, no /opt filesystem will be added.')
-            vm.register_setting('--swapsize', metavar='SIZE', type='int', default=1024, help='Size (in MB) of the swap partition [default: %default]')
+            vm.register_setting('--version', action='callback', callback=self.versioninfo, callback_kwargs={ 'vm' : vm }, help='Show version information')
+            vm.register_setting('--rootsize', metavar='SIZE', default=4096, help='Size (in MB) of the root filesystem [default: %default]')
+            vm.register_setting('--optsize', metavar='SIZE', default=0, help='Size (in MB) of the /opt filesystem. If not set, no /opt filesystem will be added.')
+            vm.register_setting('--swapsize', metavar='SIZE', default=1024, help='Size (in MB) of the swap partition [default: %default]')
             vm.register_setting('--raw', metavar='PATH', type='string', help="Specify a file (or block device) to as first disk image.")
             vm.register_setting('--part', metavar='PATH', type='string', 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")
             self.set_usage(vm)
@@ -68,6 +69,10 @@ class CLI(VMBuilder.Frontend):
         except VMBuilder.VMBuilderUserError, e:
             print >> sys.stderr, e
 
+    def versioninfo(self, option, opt, value, parser, vm=None):
+        print '%(major)d.%(minor)d.r%(revno)d' % vm.get_version_info()
+        sys.exit(0)
+
     def set_usage(self, vm):
         vm.optparser.set_usage('%prog hypervisor distro [options]')
         vm.optparser.arg_help = (('hypervisor', vm.hypervisor_help), ('distro', vm.distro_help))
@@ -80,6 +85,9 @@ class CLI(VMBuilder.Frontend):
 
     def set_disk_layout(self, vm):
         if not vm.part:
+            vm.rootsize = parse_size(vm.rootsize)
+            vm.swapsize = parse_size(vm.swapsize)
+            vm.optsize = parse_size(vm.optsize)
             if vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
                 vm.add_filesystem(size='%dM' % vm.rootsize, type='ext3', mntpnt='/')
                 vm.add_filesystem(size='%dM' % vm.swapsize, type='swap', mntpnt=None)
diff --git a/VMBuilder/plugins/ec2/__init__.py b/VMBuilder/plugins/ec2/__init__.py
index 09593b2..02f2053 100644
--- a/VMBuilder/plugins/ec2/__init__.py
+++ b/VMBuilder/plugins/ec2/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,14 +16,19 @@
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-from VMBuilder import register_plugin, Plugin, VMBuilderUserError
-from VMBuilder.util import run_cmd
+import VMBuilder
+from   VMBuilder import register_plugin, Plugin, VMBuilderUserError, VMBuilderException
+from   VMBuilder.util import run_cmd
 import logging
+import os
 
 class EC2(Plugin):
     name = 'EC2 integration'
 
     def register_options(self):
+        # Don't pretend like we can do EC2 
+        if not isinstance(self.vm.hypervisor, VMBuilder.plugins.xen.Xen):
+            return
         group = self.vm.setting_group('EC2 integation')
         group.add_option('--ec2', action='store_true', help='Build for EC2')
         group.add_option('--ec2-name','--ec2-prefix', metavar='EC2_NAME', help='Name for the EC2 image.')
@@ -36,88 +40,121 @@ class EC2(Plugin):
         group.add_option('--ec2-secret-key', metavar='SECRET_ID', help='AWS secret access key.')
         group.add_option('--ec2-kernel','--ec2-aki', metavar='AKI', help='EC2 AKI (kernel) to use.')
         group.add_option('--ec2-ramdisk','--ec2-ari', metavar='ARI', help='EC2 ARI (ramdisk) to use.')
+        group.add_option('--ec2-version', metavar='EC2_VER', help='Specify the EC2 image version.')
+        group.add_option('--ec2-landscape', action='store_true', help='Install landscape client support')
+        group.add_option('--ec2-bundle', action='store_true', help='Bundle the instance')
+        group.add_option('--ec2-upload', action='store_true', help='Upload the instance')
+        group.add_option('--ec2-register', action='store_true', help='Register the instance')
         self.vm.register_setting_group(group)
 
     def preflight_check(self):
-        if not self.vm.ec2:
+        if not getattr(self.vm, 'ec2', False):
             return True
 
+        try:
+            run_cmd('ec2-ami-tools-version')
+        except VMBuilderException, e:
+            raise VMBuilderUserError('You need to have the Amazon EC2 AMI tools installed')
+
         if not self.vm.hypervisor.name == 'Xen':
             raise VMBuilderUserError('When building for EC2 you must use the xen hypervisor.')
 
-        if not self.vm.ec2_name:
-            raise VMBuilderUserError('When building for EC2 you must supply the name for the image.')
+        if self.vm.ec2_bundle:
+            if not self.vm.ec2_name:
+                raise VMBuilderUserError('When building for EC2 you must supply the name for the image.')
 
-        if not self.vm.ec2_cert:
-            raise VMBuilderUserError('When building for EC2 you must provide your PEM encoded public key certificate')
+            if not self.vm.ec2_cert:
+                if "EC2_CERT" in os.environ:
+                    self.vm.ec2_cert = os.environ["EC2_CERT"]
+                else:
+                    raise VMBuilderUserError('When building for EC2 you must provide your PEM encoded public key certificate')
 
-        if not self.vm.ec2_key:
-            raise VMBuilderUserError('When building for EC2 you must provide your PEM encoded private key file')
+            if not self.vm.ec2_key:
+                if "EC2_PRIVATE_KEY" in os.environ:
+                    self.vm.ec2_key = os.environ["EC2_PRIVATE_KEY"]
+                else:
+                    raise VMBuilderUserError('When building for EC2 you must provide your PEM encoded private key file')
 
-        if not self.vm.ec2_user:
-            raise VMBuilderUserError('When building for EC2 you must provide your EC2 user ID (your AWS account number, not your AWS access key ID)')
+            if not self.vm.ec2_user:
+                raise VMBuilderUserError('When building for EC2 you must provide your EC2 user ID (your AWS account number, not your AWS access key ID)')
 
-        if not self.vm.ec2_kernel:
-            logging.debug('No ec2-aki choosen setting to default. Use --ec2-kernel to change this')
-            if self.vm.arch == 'amd64':
-                self.vm.ec2_kernel = 'aki-d314f0ba'
-            else:
-                self.vm.ec2_kernel = 'aki-af14f0c6'
+            if not self.vm.ec2_kernel:
+                self.vm.ec2_kernel = self.vm.distro.get_ec2_kernel()
+                logging.debug('%s - to be used for AKI.' %(self.vm.ec2_kernel))
 
-        if not self.vm.ec2_ramdisk:
-            logging.debug('No ec2-ari choosen setting to default. Use --ec2-ramdisk to change this.')
-            if self.vm.arch == 'amd64':
-                self.vm.ec2_ramdisk = 'ari-d014f0b9'
-            else:
-                self.vm.ec2_ramdisk = 'ari-ac14f0c5'
+            if not self.vm.ec2_ramdisk:
+                self.vm.ec2_ramdisk = self.vm.distro.ec2_ramdisk_id()
+                logging.debug('%s - to be use for the ARI.' %(self.vm.ec2_ramdisk))
 
-        if not self.vm.ec2_bucket:
-            raise VMBuilderUserError('When building for EC2 you must provide an S3 bucket to hold the AMI')
+            if self.vm.ec2_upload:
+                if not self.vm.ec2_bucket:
+                    raise VMBuilderUserError('When building for EC2 you must provide an S3 bucket to hold the AMI')
 
-        if not self.vm.ec2_access_key:
-            raise VMBuilderUserError('When building for EC2 you must provide your AWS access key ID.')
+                if not self.vm.ec2_access_key:
+                    raise VMBuilderUserError('When building for EC2 you must provide your AWS access key ID.')
 
-        if not self.vm.ec2_secret_key:
-            raise VMBuilderUserError('When building for EC2 you must provide your AWS secret access key.')
+                if not self.vm.ec2_secret_key:
+                    raise VMBuilderUserError('When building for EC2 you must provide your AWS secret access key.')
 
+        if not self.vm.ec2_version:
+            raise VMBuilderUserError('When building for EC2 you must provide version info.')
 
         if not self.vm.addpkg:
              self.vm.addpkg = []
 
-        self.vm.addpkg += ['openssh-server']
-        self.vm.addpkg += ['ec2-init']
-        self.vm.addpkg += ['openssh-server']
-        self.vm.addpkg += ['ec2-modules']
-        self.vm.addpkg += ['server^']
-        self.vm.addpkg += ['standard^']
+        self.vm.addpkg += ['ec2-init',
+                          'openssh-server',
+                          'ec2-modules',
+                          'standard^',
+                          'ec2-ami-tools',
+                          'update-motd']
+
+        if self.vm.ec2_landscape:
+            logging.info('Installing landscape support')
+            self.vm.addpkg += ['landscape-client']
 
         if not self.vm.ppa:
             self.vm.ppa = []
 
-        self.vm.ppa += ['ubuntu-ec2']
+        self.vm.ppa += ['ubuntu-on-ec2/ppa']
 
     def post_install(self):
-        if not self.vm.ec2:
+        if not getattr(self.vm, 'ec2', False):
             return
 
         logging.info("Running ec2 postinstall")
-        self.install_from_template('/etc/event.d/xvc0', 'upstart')
-        self.run_in_target('passwd', '-l', self.vm.user)
+        self.install_from_template('/etc/ec2_version', 'ec2_version', { 'version' : self.vm.ec2_version } )
+        self.install_from_template('/etc/ssh/sshd_config', 'sshd_config')
+        self.install_from_template('/etc/sudoers', 'sudoers')
 
-    def deploy(self):
-        if not self.vm.ec2:
-            return False
-
-        bundle_cmdline = ['ec2-bundle-image', '--image', self.vm.filesystems[0].filename, '--cert', self.vm.ec2_cert, '--privatekey', self.vm.ec2_key, '--user', self.vm.ec2_user, '--prefix', self.vm.ec2_name, '-r', ['i386', 'x86_64'][self.vm.arch == 'amd64'], '-d', self.vm.workdir, '--kernel', self.vm.ec2_kernel, '--ramdisk', self.vm.ec2_ramdisk]
+        if self.vm.ec2_landscape:
+            self.install_from_template('/etc/default/landscape-client', 'landscape_client')
 
-        run_cmd(*bundle_cmdline)
+        self.vm.distro.disable_hwclock_access()
 
-        upload_cmdline = ['ec2-upload-bundle', '--retry', '--manifest', '%s/%s.manifest.xml' % (self.vm.workdir, self.vm.ec2_name), '--bucket', self.vm.ec2_bucket, '--access-key', self.vm.ec2_access_key, '--secret-key', self.vm.ec2_secret_key]
-        run_cmd(*upload_cmdline)
+    def deploy(self):
+        if not getattr(self.vm, 'ec2', False):
+            return False
 
-        from boto.ec2.connection import EC2Connection
-        conn = EC2Connection(self.vm.ec2_access_key, self.vm.ec2_secret_key)
-        print conn.register_image('%s/%s.manifest.xml' % (self.vm.ec2_bucket, self.vm.ec2_name))
+        if self.vm.ec2_bundle:
+            logging.info("Building EC2 bundle")
+            bundle_cmdline = ['ec2-bundle-image', '--image', self.vm.filesystems[0].filename, '--cert', self.vm.ec2_cert, '--privatekey', self.vm.ec2_key, '--user', self.vm.ec2_user, '--prefix', self.vm.ec2_name, '-r', ['i386', 'x86_64'][self.vm.arch == 'amd64'], '-d', self.vm.workdir, '--kernel', self.vm.ec2_kernel, '--ramdisk', self.vm.ec2_ramdisk]
+            run_cmd(*bundle_cmdline)
+
+            manifest = '%s/%s.manifest.xml' % (self.vm.workdir, self.vm.ec2_name)
+            if self.vm.ec2_upload:
+                logging.info("Uploading EC2 bundle")
+                upload_cmdline = ['ec2-upload-bundle', '--retry', '--manifest', manifest, '--bucket', self.vm.ec2_bucket, '--access-key', self.vm.ec2_access_key, '--secret-key', self.vm.ec2_secret_key]
+                run_cmd(*upload_cmdline)
+
+                if self.vm.ec2_register:
+                    from boto.ec2.connection import EC2Connection
+                    conn = EC2Connection(self.vm.ec2_access_key, self.vm.ec2_secret_key)
+                    conn.register_image('%s/%s.manifest.xml' % (self.vm.ec2_bucket, self.vm.ec2_name))
+            else:
+                self.vm.result_files.append(manifest)
+        else:
+            self.vm.result_files.append(self.vm.filesystems[0].filename)
 
         return True
 
diff --git a/VMBuilder/plugins/ec2/templates/ec2_version.tmpl b/VMBuilder/plugins/ec2/templates/ec2_version.tmpl
new file mode 100644
index 0000000..f43b9c6
--- /dev/null
+++ b/VMBuilder/plugins/ec2/templates/ec2_version.tmpl
@@ -0,0 +1 @@
+$version
diff --git a/VMBuilder/plugins/ec2/templates/landscape_client.tmpl b/VMBuilder/plugins/ec2/templates/landscape_client.tmpl
new file mode 100644
index 0000000..4ea1407
--- /dev/null
+++ b/VMBuilder/plugins/ec2/templates/landscape_client.tmpl
@@ -0,0 +1 @@
+CLOUD=1
diff --git a/VMBuilder/plugins/ec2/templates/sshd_config.tmpl b/VMBuilder/plugins/ec2/templates/sshd_config.tmpl
new file mode 100644
index 0000000..3691b82
--- /dev/null
+++ b/VMBuilder/plugins/ec2/templates/sshd_config.tmpl
@@ -0,0 +1,77 @@
+# Package generated configuration file
+# See the sshd(8) manpage for details
+
+# What ports, IPs and protocols we listen for
+Port 22
+# Use these options to restrict which interfaces/protocols sshd will bind to
+#ListenAddress ::
+#ListenAddress 0.0.0.0
+Protocol 2
+# HostKeys for protocol version 2
+HostKey /etc/ssh/ssh_host_rsa_key
+HostKey /etc/ssh/ssh_host_dsa_key
+#Privilege Separation is turned on for security
+UsePrivilegeSeparation yes
+
+# Lifetime and size of ephemeral version 1 server key
+KeyRegenerationInterval 3600
+ServerKeyBits 768
+
+# Logging
+SyslogFacility AUTH
+LogLevel INFO
+
+# Authentication:
+LoginGraceTime 120
+PermitRootLogin yes
+StrictModes yes
+
+RSAAuthentication yes
+PubkeyAuthentication yes
+#AuthorizedKeysFile	%h/.ssh/authorized_keys
+
+# Don't read the user's ~/.rhosts and ~/.shosts files
+IgnoreRhosts yes
+# For this to work you will also need host keys in /etc/ssh_known_hosts
+RhostsRSAAuthentication no
+# similar for protocol version 2
+HostbasedAuthentication no
+# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
+#IgnoreUserKnownHosts yes
+
+# To enable empty passwords, change to yes (NOT RECOMMENDED)
+PermitEmptyPasswords no
+
+# Change to yes to enable challenge-response passwords (beware issues with
+# some PAM modules and threads)
+ChallengeResponseAuthentication no
+
+# Change to no to disable tunnelled clear text passwords
+PasswordAuthentication no
+
+# Kerberos options
+#KerberosAuthentication no
+#KerberosGetAFSToken no
+#KerberosOrLocalPasswd yes
+#KerberosTicketCleanup yes
+
+# GSSAPI options
+#GSSAPIAuthentication no
+#GSSAPICleanupCredentials yes
+
+X11Forwarding yes
+X11DisplayOffset 10
+PrintMotd no
+PrintLastLog yes
+TCPKeepAlive yes
+#UseLogin no
+
+#MaxStartups 10:30:60
+#Banner /etc/issue.net
+
+# Allow client to pass locale environment variables
+AcceptEnv LANG LC_*
+
+Subsystem sftp /usr/lib/openssh/sftp-server
+
+UsePAM yes
diff --git a/VMBuilder/plugins/ubuntu/templates/sudoers.tmpl b/VMBuilder/plugins/ec2/templates/sudoers.tmpl
similarity index 75%
copy from VMBuilder/plugins/ubuntu/templates/sudoers.tmpl
copy to VMBuilder/plugins/ec2/templates/sudoers.tmpl
index f25be9b..46bfcf9 100644
--- a/VMBuilder/plugins/ubuntu/templates/sudoers.tmpl
+++ b/VMBuilder/plugins/ec2/templates/sudoers.tmpl
@@ -3,9 +3,9 @@
 # This file MUST be edited with the 'visudo' command as root.
 #
 # See the man page for details on how to write a sudoers file.
-# Defaults
+#
 
-Defaults	!lecture,tty_tickets,!fqdn
+Defaults	env_reset
 
 # Uncomment to allow members of group sudo to not need a password
 # %sudo ALL=NOPASSWD: ALL
@@ -18,6 +18,4 @@ Defaults	!lecture,tty_tickets,!fqdn
 
 # User privilege specification
 root	ALL=(ALL) ALL
-
-# Members of the admin group may gain root privileges
-%admin ALL=(ALL) ALL
+ubuntu  ALL=(ALL) NOPASSWD:ALL
diff --git a/VMBuilder/plugins/firstscripts/__init__.py b/VMBuilder/plugins/firstscripts/__init__.py
index cfcb18f..d7d18b8 100644
--- a/VMBuilder/plugins/firstscripts/__init__.py
+++ b/VMBuilder/plugins/firstscripts/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/kvm/__init__.py b/VMBuilder/plugins/kvm/__init__.py
index e711f7a..04d4665 100644
--- a/VMBuilder/plugins/kvm/__init__.py
+++ b/VMBuilder/plugins/kvm/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/kvm/vm.py b/VMBuilder/plugins/kvm/vm.py
index 83cddc3..78c87b0 100644
--- a/VMBuilder/plugins/kvm/vm.py
+++ b/VMBuilder/plugins/kvm/vm.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/libvirt/__init__.py b/VMBuilder/plugins/libvirt/__init__.py
index c0c7df5..b1b56ca 100644
--- a/VMBuilder/plugins/libvirt/__init__.py
+++ b/VMBuilder/plugins/libvirt/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/postinst/__init__.py b/VMBuilder/plugins/postinst/__init__.py
index 1b05e36..099da48 100644
--- a/VMBuilder/plugins/postinst/__init__.py
+++ b/VMBuilder/plugins/postinst/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/ubuntu/__init__.py b/VMBuilder/plugins/ubuntu/__init__.py
index 77e89ea..7bbf6ca 100644
--- a/VMBuilder/plugins/ubuntu/__init__.py
+++ b/VMBuilder/plugins/ubuntu/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/ubuntu/dapper.py b/VMBuilder/plugins/ubuntu/dapper.py
index 91cd351..9f18da4 100644
--- a/VMBuilder/plugins/ubuntu/dapper.py
+++ b/VMBuilder/plugins/ubuntu/dapper.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,6 +22,7 @@ import os
 import suite
 import shutil
 import socket
+import tempfile
 import VMBuilder
 import VMBuilder.disk as disk
 from   VMBuilder.util import run_cmd
@@ -52,6 +52,9 @@ class Dapper(suite.Suite):
         logging.debug("Setting up sources.list")
         self.install_sources_list()
 
+        logging.debug("Setting up apt proxy")
+        self.install_apt_proxy()
+
         logging.debug("Installing fstab")
         self.install_fstab()
 
@@ -78,18 +81,21 @@ class Dapper(suite.Suite):
             logging.debug("Creating device.map")
             self.install_device_map()
 
-        logging.debug("Installing ssh keys")
-        self.install_authorized_keys()
-
         logging.debug("Installing extra packages")
         self.install_extras()
 
         logging.debug("Creating initial user")
         self.create_initial_user()
 
+        logging.debug("Installing ssh keys")
+        self.install_authorized_keys()
+
         logging.debug("Copy host settings")
         self.copy_settings()
 
+        logging.debug("Setting timezone")
+        self.set_timezone()
+
         logging.debug("Making sure system is up-to-date")
         self.update()
 
@@ -99,11 +105,16 @@ class Dapper(suite.Suite):
         logging.debug("Unmounting volatile lrm filesystems")
         self.unmount_volatile()
 
+        if hasattr(self.vm, 'ec2') and self.vm.ec2:
+            logging.debug("Configuring for ec2")
+            self.install_ec2()
+
         logging.debug("Unpreventing daemons from starting")
         self.unprevent_daemons_starting()
 
     def update(self):
-        self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade')
+        self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade',
+                           env={ 'DEBIAN_FRONTEND' : 'noninteractive' })
         
     def install_authorized_keys(self):
         if self.vm.ssh_key:
@@ -114,14 +125,32 @@ class Dapper(suite.Suite):
             os.mkdir('%s/home/%s/.ssh' % (self.destdir, self.vm.user), 0700)
             shutil.copy(self.vm.ssh_user_key, '%s/home/%s/.ssh/authorized_keys' % (self.destdir, self.vm.user))
             os.chmod('%s/home/%s/.ssh/authorized_keys' % (self.destdir, self.vm.user), 0644)
+            self.run_in_target('chown', '-R', '%s:%s' % (self.vm.user,)*2, '/home/%s/.ssh/' % (self.vm.user)) 
+
         if self.vm.ssh_user_key or self.vm.ssh_key:
             if not self.vm.addpkg:
                 self.vm.addpkg = []
             self.vm.addpkg += ['openssh-server']
 
+    def update_passwords(self):
+        # Set the user password, using md5
+        self.run_in_target('chpasswd', '-m', stdin=('%s:%s\n' % (self.vm.user, getattr(self.vm, 'pass'))))
+
+        # Lock root account only if we didn't set the root password
+        if self.vm.rootpass:
+            self.run_in_target('chpasswd', '-m', stdin=('%s:%s\n' % ('root', self.vm.rootpass)))
+        else:
+            self.run_in_target('chpasswd', '-e', stdin='root:!\n')
+
+        if self.vm.lock_user:
+            logging.info('Locking %s' %(self.vm.user))
+            self.run_in_target('chpasswd', '-e', stdin=('%s:!\n' %(self.vm.user)))
+
     def create_initial_user(self):
-        self.run_in_target('adduser', '--disabled-password', '--gecos', self.vm.name, self.vm.user)
-        self.run_in_target('chpasswd', stdin=('%s:%s\n' % (self.vm.user, getattr(self.vm, 'pass'))))
+        if self.vm.uid:
+            self.run_in_target('adduser', '--disabled-password', '--uid', self.vm.uid, '--gecos', self.vm.name, self.vm.user)
+        else:
+            self.run_in_target('adduser', '--disabled-password', '--gecos', self.vm.name, self.vm.user)
         self.run_in_target('addgroup', '--system', 'admin')
         self.run_in_target('adduser', self.vm.user, 'admin')
 
@@ -129,8 +158,7 @@ class Dapper(suite.Suite):
         for group in ['adm', 'audio', 'cdrom', 'dialout', 'floppy', 'video', 'plugdev', 'dip', 'netdev', 'powerdev', 'lpadmin', 'scanner']:
             self.run_in_target('adduser', self.vm.user, group, ignore_fail=True)
 
-        # Lock root account
-        self.run_in_target('chpasswd', '-e', stdin='root:!\n')
+        self.update_passwords()
 
     def kernel_name(self):
         return 'linux-image-%s' % (self.vm.flavour or self.default_flavour[self.vm.arch],)
@@ -193,6 +221,10 @@ class Dapper(suite.Suite):
         # final vm is going to be on).
         self.run_in_target('apt-get', 'update', ignore_fail=final)
 
+    def install_apt_proxy(self):
+        if self.vm.proxy is not None:
+            self.vm.install_file('/etc/apt/apt.conf', '// Proxy added by vmbuilder\nAcquire::http { Proxy "%s"; };' % self.vm.proxy)
+
     def install_fstab(self):
         if self.vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
             self.install_from_template('/etc/fstab', 'dapper_fstab_fsimage', { 'fss' : disk.get_ordered_filesystems(self.vm), 'prefix' : self.disk_prefix })
@@ -203,12 +235,18 @@ class Dapper(suite.Suite):
         self.install_from_template('/boot/grub/device.map', 'devicemap', { 'prefix' : self.disk_prefix })
 
     def debootstrap(self):
-        cmd = ['/usr/sbin/debootstrap', '--arch=%s' % self.vm.arch, self.vm.suite, self.destdir, self.debootstrap_mirror()]
-        run_cmd(*cmd)
+        cmd = ['/usr/sbin/debootstrap', '--arch=%s' % self.vm.arch]
+        if self.vm.variant:
+            cmd += ['--variant=%s' % self.vm.variant]
+        cmd += [self.vm.suite, self.destdir, self.debootstrap_mirror()]
+        kwargs = { 'env' : { 'DEBIAN_FRONTEND' : 'noninteractive' } }
+        if self.vm.proxy:
+            kwargs['env']['http_proxy'] = self.vm.proxy
+        run_cmd(*cmd, **kwargs)
     
     def debootstrap_mirror(self):
         if self.vm.iso:
-            os.mkdir(isodir)
+            isodir = tempfile.mkdtemp()
             self.vm.add_clean_cb(lambda:os.rmdir(isodir))
             run_cmd('mount', '-o', 'loop', '-t', 'iso9660', self.vm.iso, isodir)
             self.vm.add_clean_cmd('umount', isodir)
@@ -220,9 +258,7 @@ class Dapper(suite.Suite):
 
 
     def install_mirrors(self):
-        if self.vm.iso:
-            mirror = "file:///isomnt"
-        elif self.vm.install_mirror:
+        if self.vm.install_mirror:
             mirror = self.vm.install_mirror
         else:
             mirror = self.vm.mirror
@@ -264,6 +300,7 @@ class Dapper(suite.Suite):
         self.vm.distro.run_in_target(*args, **kwargs)
 
     def copy_to_target(self, infile, destpath):
+        logging.debug("Copying %s on host to %s in guest" % (infile, destpath))
         dir = '%s/%s' % (self.destdir, os.path.dirname(destpath))
         if not os.path.isdir(dir):
             os.makedirs(dir)
@@ -282,9 +319,28 @@ class Dapper(suite.Suite):
     def copy_settings(self):
         self.copy_to_target('/etc/default/locale', '/etc/default/locale')
         self.copy_to_target('/etc/timezone', '/etc/timezone')
-        self.run_in_target('dpkg-reconfigure', '-pcritical', 'libc6')
+        self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'libc6')
         self.run_in_target('locale-gen', 'en_US')
         if self.vm.lang:
             self.run_in_target('locale-gen', self.vm.lang)
             self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang })
+        self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'locales')
         self.run_in_target('dpkg-reconfigure', '-pcritical', 'locales')
+
+    def install_vmbuilder_log(self, logfile, rootdir):
+        shutil.copy(logfile, '%s/var/log/vmbuilder-install.log' % (rootdir,))
+
+    def set_timezone(self):
+        if self.vm.timezone:
+            self.unlink('%s/etc/localtime' % self.destdir)
+            shutil.copy('%s/usr/share/zoneinfo/%s' % (self.destdir, self.vm.timezone), '%s/etc/localtime' % (self.destdir,))
+
+    def install_ec2(self):
+        if self.vm.ec2:
+            logging.debug('This suite does not support ec2')
+
+    def disable_hwclock_access(self):
+        fp = open('%s/etc/default/rcS' % self.destdir, 'a')
+        fp.write('HWCLOCKACCESS=no')
+        fp.close()
+
diff --git a/VMBuilder/plugins/ubuntu/distro.py b/VMBuilder/plugins/ubuntu/distro.py
index e24b1e2..6e7d9f1 100644
--- a/VMBuilder/plugins/ubuntu/distro.py
+++ b/VMBuilder/plugins/ubuntu/distro.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,14 +16,14 @@
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
+import logging
+import os
+import socket
+import types
 import VMBuilder
 from   VMBuilder           import register_distro, Distro
 from   VMBuilder.util      import run_cmd
-from   VMBuilder.exception import VMBuilderUserError
-import socket
-import logging
-import types
-import os
+from   VMBuilder.exception import VMBuilderUserError, VMBuilderException
 
 class Ubuntu(Distro):
     name = 'Ubuntu'
@@ -53,20 +52,27 @@ class Ubuntu(Distro):
         group = self.vm.setting_group('Installation options')
         group.add_option('--suite', default='jaunty', help='Suite to install. Valid options: %s [default: %%default]' % ' '.join(self.suites))
         group.add_option('--flavour', '--kernel-flavour', help='Kernel flavour to use. Default and valid options depend on architecture and suite')
+        group.add_option('--variant', metavar='VARIANT', help='Passed to debootstrap --variant flag; use minbase, buildd, or fakechroot.')
         group.add_option('--iso', metavar='PATH', help='Use an iso image as the source for installation of file. Full path to the iso must be provided. If --mirror is also provided, it will be used in the final sources.list of the vm.  This requires suite and kernel parameter to match what is available on the iso, obviously.')
         group.add_option('--mirror', metavar='URL', help='Use Ubuntu mirror at URL instead of the default, which is http://archive.ubuntu.com/ubuntu for official arches and http://ports.ubuntu.com/ubuntu-ports otherwise')
+        group.add_option('--proxy', metavar='URL', help='Use proxy at URL for cached packages')
         group.add_option('--install-mirror', metavar='URL', help='Use Ubuntu mirror at URL for the installation only. Apt\'s sources.list will still use default or URL set by --mirror')
         group.add_option('--security-mirror', metavar='URL', help='Use Ubuntu security mirror at URL instead of the default, which is http://security.ubuntu.com/ubuntu for official arches and http://ports.ubuntu.com/ubuntu-ports otherwise.')
         group.add_option('--install-security-mirror', metavar='URL', help='Use the security mirror at URL for installation only. Apt\'s sources.list will still use default or URL set by --security-mirror')
         group.add_option('--components', metavar='COMPS', help='A comma seperated list of distro components to include (e.g. main,universe).')
         group.add_option('--ppa', metavar='PPA', action='append', help='Add ppa belonging to PPA to the vm\'s sources.list.')
         group.add_option('--lang', metavar='LANG', default=self.get_locale(), help='Set the locale to LANG [default: %default]')
+        group.add_option('--timezone', action='store_true', help='Set the timezone to the vm.')
         self.vm.register_setting_group(group)
 
         group = self.vm.setting_group('Settings for the initial user')
         group.add_option('--user', default='ubuntu', help='Username of initial user [default: %default]')
         group.add_option('--name', default='Ubuntu', help='Full name of initial user [default: %default]')
         group.add_option('--pass', default='ubuntu', help='Password of initial user [default: %default]')
+        group.add_option('--rootpass', help='Initial root password (WARNING: this has strong security implications).')
+        group.add_option('--uid', help='Initial UID value.')
+        group.add_option('--gid', help='Initial GID value.')
+        group.add_option('--lock-user', action='store_true', help='Lock the initial user [default %default]')
         self.vm.register_setting_group(group)
 
         group = self.vm.setting_group('Other options')
@@ -93,10 +99,7 @@ class Ubuntu(Distro):
             self.vm.components = self.vm.components.split(',')
 
     def get_locale(self):
-        try:
-            return os.environ['LANG']
-        except:
-            return None
+        return os.getenv('LANG')
 
     def preflight_check(self):
         """While not all of these are strictly checks, their failure would inevitably
@@ -126,10 +129,24 @@ class Ubuntu(Distro):
 
         self.vm.virtio_net = self.use_virtio_net()
 
+        if self.vm.lang:
+            try:
+                run_cmd('locale-gen', '%s' % self.vm.lang)
+            except VMBuilderException, e:
+                msg = "locale-gen does not recognize your locale '%s'" % self.vm.lang
+                raise VMBuilderUserError(msg)
+
+        if self.vm.ec2:
+            self.get_ec2_kernel()
+            self.get_ec2_ramdisk()
+
     def install(self, destdir):
         self.destdir = destdir
         self.suite.install(destdir)
 
+    def install_vmbuilder_log(self, logfile, rootdir):
+        self.suite.install_vmbuilder_log(logfile, rootdir)
+
     def post_mount(self, fs):
         self.suite.post_mount(fs)
 
@@ -170,13 +187,29 @@ EOT''')
         else:
             raise VMBuilderUserError('There is no valid xen kernel for the suite selected.')
 
-    def xen_kernel_path(self):
-        path = '/boot/vmlinuz-%s-%s' % (self.xen_kernel_version(), self.suite.xen_kernel_flavour)
+    def xen_kernel_initrd_path(self, which):
+        path = '/boot/%s-%s-%s' % (which, self.xen_kernel_version(), self.suite.xen_kernel_flavour)
         return path
 
+    def xen_kernel_path(self):
+        return self.xen_kernel_initrd_path('kernel')
+
     def xen_ramdisk_path(self):
-        path = '/boot/initrd.img-%s-%s' % (self.xen_kernel_version(), self.suite.xen_kernel_flavour)
-        return path
+        return self.xen_kernel_initrd_path('ramdisk')
+
+    def get_ec2_kernel(self):
+        if self.suite.ec2_kernel_info:
+            return self.suite.ec2_kernel_info[self.vm.arch]
+        else:
+            raise VMBuilderUserError('EC2 is not supported for the suite selected')
+
+    def get_ec2_ramdisk(self):
+        if self.suite.ec2_ramdisk_info:
+            return self.suite.ec2_ramdisk_info[self.vm.arch]
+        else:
+            raise VMBuilderUserError('EC2 is not supported for the suite selected')
 
+    def disable_hwclock_access(self):
+        return self.suite.disable_hwclock_access()
 
 register_distro(Ubuntu)
diff --git a/VMBuilder/plugins/ubuntu/edgy.py b/VMBuilder/plugins/ubuntu/edgy.py
index 180ab0f..b2afbb1 100644
--- a/VMBuilder/plugins/ubuntu/edgy.py
+++ b/VMBuilder/plugins/ubuntu/edgy.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,6 +19,7 @@
 import logging
 import suite
 import shutil
+import os
 import VMBuilder.disk as disk
 from   VMBuilder.util import run_cmd
 from   VMBuilder.plugins.ubuntu.dapper import Dapper
@@ -49,14 +49,18 @@ proc                                            /proc           proc    defaults
 
     def copy_settings(self):
         self.copy_to_target('/etc/default/locale', '/etc/default/locale')
-        shutil.rmtree('%s/etc/console-setup' % self.destdir)
-        self.copy_to_target('/etc/console-setup', '/etc/console-setup')
-        self.copy_to_target('/etc/default/console-setup', '/etc/default/console-setup')
+        csdir = '%s/etc/console-setup' % self.destdir
+        have_cs = os.path.isdir(csdir)
+        if have_cs:
+            shutil.rmtree(csdir)
+            self.copy_to_target('/etc/console-setup', '/etc/console-setup')
+            self.copy_to_target('/etc/default/console-setup', '/etc/default/console-setup')
         self.copy_to_target('/etc/timezone', '/etc/timezone')
-        self.run_in_target('dpkg-reconfigure', '-pcritical', 'tzdata')
+        self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'tzdata')
         self.run_in_target('locale-gen', 'en_US')
         if self.vm.lang:
             self.run_in_target('locale-gen', self.vm.lang)
             self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang })
-        self.run_in_target('dpkg-reconfigure', '-pcritical', 'locales')
-        self.run_in_target('dpkg-reconfigure', '-pcritical', 'console-setup')
+        self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'locales')
+        if have_cs:
+            self.run_in_target('dpkg-reconfigure', '-fnoninteractive', '-pcritical', 'console-setup')
diff --git a/VMBuilder/plugins/ubuntu/feisty.py b/VMBuilder/plugins/ubuntu/feisty.py
index bcab738..42c3ac5 100644
--- a/VMBuilder/plugins/ubuntu/feisty.py
+++ b/VMBuilder/plugins/ubuntu/feisty.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/ubuntu/gutsy.py b/VMBuilder/plugins/ubuntu/gutsy.py
index 9f0ce58..5b9fe2e 100644
--- a/VMBuilder/plugins/ubuntu/gutsy.py
+++ b/VMBuilder/plugins/ubuntu/gutsy.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/ubuntu/hardy.py b/VMBuilder/plugins/ubuntu/hardy.py
index 5ed63f1..e28a13f 100644
--- a/VMBuilder/plugins/ubuntu/hardy.py
+++ b/VMBuilder/plugins/ubuntu/hardy.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,6 +21,17 @@ from VMBuilder.plugins.ubuntu.gutsy import Gutsy
 
 class Hardy(Gutsy):
     virtio_net = True
+    ec2_kernel_info = { 'i386' : 'aki-6e709707', 'amd64' : 'aki-6f709706' }
+    ec2_ramdisk_info = { 'i386' : 'ari-6c709705', 'amd64' : 'ari-61709708' }
+
+    def install_ec2(self):
+        self.run_in_target('apt-get' ,'--force-yes', '-y', 'install', 'libc6-xen')
+        self.run_in_target('apt-get','--purge','--force-yes', '-y', 'remove', 'libc6-i686')
+        self.install_from_template('/etc/event.d/xvc0', 'upstart', { 'console' : 'xvc0' })
+        self.install_from_template('/etc/ld.so.conf.d/libc6-xen.conf', 'xen-ld-so-conf')
+        self.run_in_target('update-rc.d', '-f', 'hwclockfirst.sh', 'remove')
+        self.install_from_template('/etc/update-motd.d/51_update-motd', '51_update-motd-hardy')
+        self.run_in_target('chmod', '755', '/etc/update-motd.d/51_update-motd')
 
     def xen_kernel_path(self):
         return '/boot/vmlinuz-2.6.24-19-xen'
diff --git a/VMBuilder/plugins/ubuntu/intrepid.py b/VMBuilder/plugins/ubuntu/intrepid.py
index 99d9c82..e0b313a 100644
--- a/VMBuilder/plugins/ubuntu/intrepid.py
+++ b/VMBuilder/plugins/ubuntu/intrepid.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,7 +23,20 @@ from   VMBuilder.util import run_cmd
 from   VMBuilder.plugins.ubuntu.hardy import Hardy
 
 class Intrepid(Hardy):
-    xen_kernel_flavour = 'server'
+    valid_flavours = { 'i386' :  ['386', 'generic', 'server', 'virtual'],
+                       'amd64' : ['generic', 'server', 'virtual'],
+                       'lpia'  : ['lpia', 'lpiacompat'] }
+    default_flavour = { 'i386' : 'virtual', 'amd64' : 'virtual', 'lpia' : 'lpia' }
+    xen_kernel_flavour = 'virtual'
+    ec2_kernel_info = { 'i386' : 'aki-714daa18', 'amd64' : 'aki-4f4daa26' }
+    ec2_ramdisk_info = { 'i386': 'ari-7e4daa17', 'amd64' : 'ari-4c4daa25' }
+
+    def install_ec2(self):
+# workaround for policy bug on ubuntu-server. (see bug #275432)
+        self.run_in_target('apt-get', '--force-yes', '-y', 'install', 'policykit')
+        self.run_in_target('apt-get', '--force-yes', '-y', 'install', 'server^')
+        self.install_from_template('/etc/update-motd.d/51_update-motd', '51_update-motd')
+        self.run_in_target('chmod', '755', '/etc/update-motd.d/51_update-motd')
 
     def mangle_grub_menu_lst(self):
         bootdev = disk.bootpart(self.vm.disks)
diff --git a/VMBuilder/plugins/ubuntu/jaunty.py b/VMBuilder/plugins/ubuntu/jaunty.py
index ac9a544..5d1af35 100644
--- a/VMBuilder/plugins/ubuntu/jaunty.py
+++ b/VMBuilder/plugins/ubuntu/jaunty.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,9 +24,27 @@ from   VMBuilder.plugins.ubuntu.intrepid import Intrepid
 
 class Jaunty(Intrepid):
     xen_kernel_flavour = 'server'
+    ec2_kernel_info = { 'i386' : 'aki-c553b4ac', 'amd64' : 'aki-d653b4bf' }
+    ec2_ramdisk_info = { 'i386' : 'ari-c253b4ab', 'amd64' : 'ari-d753b4be' }
+
+    def install_ec2(self):
+        self.run_in_target('apt-get', '--force-yes', '-y', 'install', 'server^')
+        self.install_from_template('/etc/update-motd.d/51_update-motd', '51_update-motd')
+        self.run_in_target('chmod', '755', '/etc/update-motd.d/51_update-motd')
 
     def mangle_grub_menu_lst(self):
         bootdev = disk.bootpart(self.vm.disks)
         run_cmd('sed', '-ie', 's/^# kopt=root=\([^ ]*\)\(.*\)/# kopt=root=UUID=%s\\2/g' % bootdev.fs.uuid, '%s/boot/grub/menu.lst' % self.destdir)
         run_cmd('sed', '-ie', 's/^# groot.*/# groot=%s/g' % bootdev.fs.uuid, '%s/boot/grub/menu.lst' % self.destdir)
         run_cmd('sed', '-ie', '/^# kopt_2_6/ d', '%s/boot/grub/menu.lst' % self.destdir)
+
+    def update_passwords(self):
+        # Set the user password, using using defaults from /etc/login.defs (ie, no need to specify '-m')
+        self.run_in_target('chpasswd', stdin=('%s:%s\n' % (self.vm.user, getattr(self.vm, 'pass'))))
+
+        # Lock root account only if we didn't set the root password
+        if self.vm.rootpass:
+            self.run_in_target('chpasswd', stdin=('%s:%s\n' % ('root', self.vm.rootpass)))
+        else:
+            self.run_in_target('chpasswd', '-e', stdin='root:!\n')
+
diff --git a/VMBuilder/plugins/ubuntu/suite.py b/VMBuilder/plugins/ubuntu/suite.py
index 7cdbc20..51c8aaf 100644
--- a/VMBuilder/plugins/ubuntu/suite.py
+++ b/VMBuilder/plugins/ubuntu/suite.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,6 +26,7 @@ import sys
 class Suite(object):
     def __init__(self, vm):
         self.vm = vm
+        self.isodir = '/media/vmbuilder_inst_image'
         self.iso_mounted = False
 
     def check_arch_validity(self, arch):
diff --git a/VMBuilder/plugins/ubuntu/templates/51_update-motd-hardy.tmpl b/VMBuilder/plugins/ubuntu/templates/51_update-motd-hardy.tmpl
new file mode 100644
index 0000000..f51c547
--- /dev/null
+++ b/VMBuilder/plugins/ubuntu/templates/51_update-motd-hardy.tmpl
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+echo "---------------------------------------------------------------------"
+echo "At the moment, only the core of the system is installed. To tune the "
+echo "system to your needs, you can choose to install one or more          "
+echo "predefined collections of software by running the following          "
+echo "command:                                                             "
+echo "                                                                     "
+echo "   sudo tasksel                                                      "
+echo "---------------------------------------------------------------------"
diff --git a/VMBuilder/plugins/ubuntu/templates/51_update-motd.tmpl b/VMBuilder/plugins/ubuntu/templates/51_update-motd.tmpl
new file mode 100644
index 0000000..2a98f7d
--- /dev/null
+++ b/VMBuilder/plugins/ubuntu/templates/51_update-motd.tmpl
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+echo "---------------------------------------------------------------------"
+echo "At the moment, only the core of the system is installed. To tune the "
+echo "system to your needs, you can choose to install one or more          "
+echo "predefined collections of software by running the following          "
+echo "command:                                                             "
+echo "                                                                     "
+echo "   sudo tasksel --section server                                     "
+echo "---------------------------------------------------------------------"
diff --git a/VMBuilder/plugins/ec2/templates/upstart.tmpl b/VMBuilder/plugins/ubuntu/templates/upstart.tmpl
similarity index 60%
rename from VMBuilder/plugins/ec2/templates/upstart.tmpl
rename to VMBuilder/plugins/ubuntu/templates/upstart.tmpl
index 245efa1..b372c17 100644
--- a/VMBuilder/plugins/ec2/templates/upstart.tmpl
+++ b/VMBuilder/plugins/ubuntu/templates/upstart.tmpl
@@ -1,6 +1,6 @@
-# tty1 - getty
+# $console - getty
 #
-# This service maintains a getty on tty1 from the point the system is
+# This service maintains a getty on $console from the point the system is
 # started until it is shut down again.
 
 start on stopped rc2
@@ -13,4 +13,4 @@ stop on runlevel 1
 stop on runlevel 6
 
 respawn
-exec /sbin/getty 38400 xvc0
+exec /sbin/getty 38400 $console
diff --git a/VMBuilder/plugins/ubuntu/templates/xen-ld-so-conf.tmpl b/VMBuilder/plugins/ubuntu/templates/xen-ld-so-conf.tmpl
new file mode 100644
index 0000000..e5ce344
--- /dev/null
+++ b/VMBuilder/plugins/ubuntu/templates/xen-ld-so-conf.tmpl
@@ -0,0 +1 @@
+hwcap 0 nosegneg
diff --git a/VMBuilder/plugins/vmware/__init__.py b/VMBuilder/plugins/virtualbox/__init__.py
similarity index 71%
copy from VMBuilder/plugins/vmware/__init__.py
copy to VMBuilder/plugins/virtualbox/__init__.py
index e711f7a..04d4665 100644
--- a/VMBuilder/plugins/vmware/__init__.py
+++ b/VMBuilder/plugins/virtualbox/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl b/VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl
new file mode 100644
index 0000000..9c5137f
--- /dev/null
+++ b/VMBuilder/plugins/virtualbox/templates/vm_deploy_script.tmpl
@@ -0,0 +1,65 @@
+#raw
+#! /usr/bin/env bash
+###############################################################################
+#
+# This script is used to create und register a new VM
+# in VirtualBox
+#
+###############################################################################
+#end raw
+#import os
+#import os.path
+
+
+#if $os_type == "Ubuntu"
+os_type="Ubuntu"
+#else
+os_type="Other"
+#end if
+
+disk_path="#echo os.path.abspath(os.path.dirname($vm_disks[0]))#"
+
+
+VBoxManage createvm -name $vm_name -ostype \$os_type -register
+
+VBoxManage openmedium #slurp
+#set $i = 0
+#for $disk in $vm_disks
+    #set $i = $i + 1
+    #set $disk = os.path.basename(disk)
+disk \${disk_path}/$disk -type normal #slurp
+#end for
+
+VBoxManage modifyvm $vm_name -memory $memory -sata on #slurp
+#set $i = 0
+#for $disk in $vm_disks
+    #set $i = $i + 1
+    #set $disk = os.path.basename(disk)
+    #if $i >= 31
+    	#break
+    #end if
+    #if $i == 1
+    	-hda \${disk_path}/$disk #slurp
+    #else if $i == 2
+    	-hdb \${disk_path}/$disk #slurp
+    #else if $i == 3
+    	-hdd \${disk_path}/$disk #slurp
+    #else
+        -sataport${i} \${disk_path}/$disk #slurp
+    #end if
+#end for
+
+#if $mac
+VBoxManage modifyvm $vm_name -macaddress1 $mac
+#end if
+
+#if $ip
+#if $ip == "dhcp"
+VBoxManage modifyvm $vm_name -nic1 nat
+#else
+VBoxManage modifyvm $vm_name -nic1 intnet 
+#end if
+#end if
+
+#activating PAE support for the CPU because some OS (e.g. ubuntu server ) won't boot in a virtual machine without it
+VBoxManage modifyvm $vm_name -pae on
diff --git a/VMBuilder/plugins/virtualbox/vm.py b/VMBuilder/plugins/virtualbox/vm.py
new file mode 100644
index 0000000..2b940dc
--- /dev/null
+++ b/VMBuilder/plugins/virtualbox/vm.py
@@ -0,0 +1,56 @@
+#
+#    Uncomplicated VM Builder
+#    Copyright (C) 2007-2009 Canonical Ltd.
+#    
+#    See AUTHORS for list of contributors
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import os.path
+import stat
+import VMBuilder
+from   VMBuilder      import register_hypervisor, Hypervisor, VMBuilderUserError
+from   VMBuilder.disk import vbox_manager_path
+import VMBuilder.hypervisor
+
+class VirtualBox(Hypervisor):
+    preferred_storage = VMBuilder.hypervisor.STORAGE_DISK_IMAGE
+    needs_bootloader = True
+    name = 'VirtualBox'
+    arg = 'vbox'
+
+    def register_options(self):
+        group = self.vm.setting_group('VirtualBox options')
+        group.add_option('--vbox-disk-format', metavar='FORMAT', default='vdi', help='Desired disk format. Valid options are: vdi vmdk. [default: %default]')
+        self.vm.register_setting_group(group)
+
+    def finalize(self):
+        self.imgs = []
+        for disk in self.vm.disks:
+            img_path = disk.convert(self.vm.destdir, self.vm.vbox_disk_format)
+            self.imgs.append(img_path)
+            self.vm.result_files.append(img_path)
+
+    def deploy(self):
+        vm_deploy_script = VMBuilder.util.render_template('virtualbox', self.vm, 'vm_deploy_script', { 'os_type' : self.vm.distro.__class__.__name__, 'vm_name' : self.vm.hostname, 'vm_disks' : self.imgs, 'memory' : self.vm.mem })
+
+        script_file = '%s/deploy_%s.sh' % (self.vm.destdir, self.vm.hostname)
+        fp = open(script_file, 'w')
+        fp.write(vm_deploy_script)
+        fp.close()
+        os.chmod(script_file, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
+        self.vm.result_files.append(script_file)
+
+register_hypervisor(VirtualBox)
diff --git a/VMBuilder/plugins/vmware/__init__.py b/VMBuilder/plugins/vmware/__init__.py
index e711f7a..04d4665 100644
--- a/VMBuilder/plugins/vmware/__init__.py
+++ b/VMBuilder/plugins/vmware/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/vmware/templates/esxi.vmx.tmpl b/VMBuilder/plugins/vmware/templates/esxi.vmx.tmpl
index 0af8cbb..cb655c9 100644
--- a/VMBuilder/plugins/vmware/templates/esxi.vmx.tmpl
+++ b/VMBuilder/plugins/vmware/templates/esxi.vmx.tmpl
@@ -12,7 +12,7 @@ powerType.reset = "default"
 
 displayName = "$hostname $arch"
 
-numvcpus = "$cpu"
+numvcpus = "$cpus"
 scsi0.present = "true"
 scsi0.sharedBus = "none"
 scsi0.virtualDev = "lsilogic"
diff --git a/VMBuilder/plugins/vmware/templates/vmware.tmpl b/VMBuilder/plugins/vmware/templates/vmware.tmpl
index e79ce56..b76a8ea 100644
--- a/VMBuilder/plugins/vmware/templates/vmware.tmpl
+++ b/VMBuilder/plugins/vmware/templates/vmware.tmpl
@@ -3,6 +3,7 @@ virtualHW.version = "$vmhwversion"
 scsi0.present = "FALSE"
 scsi0.virtualDev = "lsilogic"
 memsize = "$mem"
+numvcpus = "$cpus"
 Ethernet0.virtualDev = "vlance"
 Ethernet0.present = "TRUE"
 Ethernet0.connectionType = "bridged"
diff --git a/VMBuilder/plugins/vmware/vm.py b/VMBuilder/plugins/vmware/vm.py
index 2afecb6..6f63995 100644
--- a/VMBuilder/plugins/vmware/vm.py
+++ b/VMBuilder/plugins/vmware/vm.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -43,7 +42,7 @@ class VMWare(Hypervisor):
         return self.vm.disks
 
     def deploy(self):
-        vmdesc = VMBuilder.util.render_template('vmware', self.vm, vmxtemplate, { 'disks' : self.disks(), 'vmhwversion' : self.vmhwversion, 'cpu' : self.vm.cpu, 'mem' : self.vm.mem, 'hostname' : self.vm.hostname, 'arch' : self.vm.arch, 'guestos' : (self.vm.arch == 'amd64' and 'ubuntu-64' or 'ubuntu') })
+        vmdesc = VMBuilder.util.render_template('vmware', self.vm, self.vmxtemplate, { 'disks' : self.disks(), 'vmhwversion' : self.vmhwversion, 'cpus' : self.vm.cpus, 'mem' : self.vm.mem, 'hostname' : self.vm.hostname, 'arch' : self.vm.arch, 'guestos' : (self.vm.arch == 'amd64' and 'ubuntu-64' or 'ubuntu') })
 
         vmx = '%s/%s.vmx' % (self.vm.destdir, self.vm.hostname)
         fp = open(vmx, 'w')
diff --git a/VMBuilder/plugins/xen/__init__.py b/VMBuilder/plugins/xen/__init__.py
index d18ead9..ec7acde 100644
--- a/VMBuilder/plugins/xen/__init__.py
+++ b/VMBuilder/plugins/xen/__init__.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/plugins/xen/vm.py b/VMBuilder/plugins/xen/vm.py
index 7fc545b..61a2695 100644
--- a/VMBuilder/plugins/xen/vm.py
+++ b/VMBuilder/plugins/xen/vm.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/VMBuilder/util.py b/VMBuilder/util.py
index 3e02c33..367e3fa 100644
--- a/VMBuilder/util.py
+++ b/VMBuilder/util.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -169,8 +168,8 @@ def render_template(plugin, vm, tmplname, context=None):
         searchList.append(context)
     searchList.append(vm)
 
-    tmpldirs = ['VMBuilder/plugins/%s/templates',
-                os.path.expanduser('~/.vmbuilder/%s'),
+    tmpldirs = [os.path.expanduser('~/.vmbuilder/%s'),
+                os.path.dirname(__file__) + '/plugins/%s/templates',
                 '/etc/vmbuilder/%s']
 
     if vm.templates:
diff --git a/VMBuilder/vm.py b/VMBuilder/vm.py
index c6d425b..09e5e39 100644
--- a/VMBuilder/vm.py
+++ b/VMBuilder/vm.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -29,6 +28,7 @@ import tempfile
 import textwrap
 import socket
 import struct
+import urllib
 import VMBuilder
 import VMBuilder.util      as util
 import VMBuilder.log       as log
@@ -75,7 +75,7 @@ class VM(object):
 
         self.fsmounted = False
 
-        self.optparser = _MyOptParser(epilog="ubuntu-vm-builder is Copyright (C) 2007-2008 Canonical Ltd. and written by Soren Hansen <soren at canonical.com>.", usage='%prog hypervisor distro [options]')
+        self.optparser = _MyOptParser(epilog="ubuntu-vm-builder is Copyright (C) 2007-2009 Canonical Ltd. and written by Soren Hansen <soren at canonical.com>.", usage='%prog hypervisor distro [options]')
         self.optparser.arg_help = (('hypervisor', self.hypervisor_help), ('distro', self.distro_help))
 
         self.confparser = ConfigParser.SafeConfigParser()
@@ -90,6 +90,15 @@ class VM(object):
 
         self._register_base_settings()
 
+        self.add_clean_cmd('rm', log.logfile)
+
+    def get_version_info(self):
+        import vcsversion
+        info = vcsversion.version_info
+        info['major'] = 0
+        info['minor'] = 10
+        return info
+       
     def cleanup(self):
         logging.info("Cleaning up")
         while len(self._cleanup_cbs) > 0:
@@ -137,10 +146,10 @@ class VM(object):
         self.register_setting('--in-place', action='store_true', default=False, help='Install directly into the filesystem images. This is needed if your $TMPDIR is nodev and/or nosuid, but will result in slightly larger file system images.')
         self.register_setting('--tmpfs', metavar="OPTS", help='Use a tmpfs as the working directory, specifying its size or "-" to use tmpfs default (suid,dev,size=1G).')
         self.register_setting('-m', '--mem', type='int', default=128, help='Assign MEM megabytes of memory to the guest vm. [default: %default]')
-        self.register_setting('--cpus', type='int', default=1, help='Number of virtual CPU's. [default: %default]')
+        self.register_setting('--cpus', type='int', default=1, help='Number of virtual CPU\'s. [default: %default]')
 
         group = self.setting_group('Network related options')
-        domainname = '.'.join(socket.gethostbyname_ex(socket.gethostname())[0].split('.')[1:])
+        domainname = '.'.join(socket.gethostbyname_ex(socket.gethostname())[0].split('.')[1:]) or "defaultdomain"
         group.add_option('--domain', metavar='DOMAIN', default=domainname, help='Set DOMAIN as the domain name of the guest [default: The domain of the machine running this script: %default].')
         group.add_option('--ip', metavar='ADDRESS', default='dhcp', help='IP address in dotted form [default: %default].')
         group.add_option('--mac', metavar='VALUE', help='MAC address of the guest [default: one will be automatically generated on first run].')
@@ -237,7 +246,7 @@ class VM(object):
         is called to give all the plugins and the distro and hypervisor plugin a chance to set
         some reasonable defaults, which the frontend then can inspect and present
         """
-
+        multiline_split = re.compile("\s*,\s*")
         if self.distro and self.hypervisor:
             for plugin in VMBuilder._plugins:
                 self.plugins.append(plugin(self))
@@ -250,7 +259,8 @@ class VM(object):
                 if confvalue:
                     if self.optparser.get_option('--%s' % k):
                         if self.optparser.get_option('--%s' % k).action == 'append':
-                            setattr(self, k, confvalue.split(', '))
+                            values = multiline_split.split(confvalue)
+                            setattr(self, k, values)
                         else:
                             setattr(self, k, confvalue)
                     else:
@@ -405,6 +415,8 @@ class VM(object):
             logging.info("Installing bootloader")
             self.distro.install_bootloader()
 
+        self.distro.install_vmbuilder_log(log.logfile, self.rootmnt)
+
     def preflight_check(self):
         for opt in sum([self.confparser.options(section) for section in self.confparser.sections()], []) + [k for (k,v) in self.confparser.defaults().iteritems()]:
             if '-' in opt:
@@ -413,6 +425,20 @@ class VM(object):
         self.ip_defaults()
         self.call_hooks('preflight_check')
 
+        # Check repository availability
+        if self.mirror:
+            testurl = self.mirror
+        else:
+            testurl = 'http://archive.ubuntu.com/'
+
+        try:
+            logging.debug('Testing access to %s' % testurl)
+            testnet = urllib.urlopen(testurl)
+        except IOError:
+            raise VMBuilderUserError('Could not connect to %s. Please check your connectivity and try again.' % testurl)
+
+        testnet.close()
+
     def install_file(self, path, contents=None, source=None, mode=None):
         fullpath = '%s%s' % (self.installdir, path)
         if source and not contents:
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index b3a892e..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,343 +0,0 @@
-vm-builder (0.9-0ubuntu6) UNRELEASED; urgency=low
-
-  [ Jamie Strandboge ]
-  * fix creation of Dapper VMs (LP: #305186) by moving existing
-    copy_settings() from plugins/ubuntu/dapper.py to plugins/ubuntu/edgy.py
-    and creating a Dapper specific copy_settings(). This was introduced in
-    fix for (LP: #292573).
-
-  [ Michael Vogt ]
-  * when --ssh-key is given, install openssh-server
-
- -- Jamie Strandboge <jamie at ubuntu.com>  Thu, 04 Dec 2008 08:48:39 -0600
-
-vm-builder (0.9-0ubuntu5) jaunty; urgency=low
-
-  * add Jaunty support 
-
- -- Jamie Strandboge <jamie at ubuntu.com>  Wed, 03 Dec 2008 17:41:12 -0600
-
-vm-builder (0.9-0ubuntu4) jaunty; urgency=low
-
-  [ Nicolas Barcet ]
-  * Integrate ec2 postinstall script
-  * Add --install-mirror to fix LP: #291639
-  * Implement --iso to fix LP: #291590
-  * Install openssh-server cleanly LP: #293039
-  * Xen kernel and ramdisk are now dynamically discovered rather than
-    hard coded
-  * Add --xen-kernel and --xen-ramdisk to override automatic discovery
-  * Add --net-virtio and --net-bridge option to libvirt plugin
-  * The libvirt plugin now errors out if used with something else than KVM, as
-    nothing else is supported yet.
-  * For FSIMAGE type file system, --part now accepts a third argument which
-    allows to specify the device the partition should be mapped to. If the
-    size is set to 0, it is considered a "dummy" partition that should not be
-    created, only added to fstab.
-  
-  [ Chuck Short ]
-  * Add retry option when uploading to Amazon
-  * Install server and standard seed by default
-  * Add ec2 examples for first login and first boot
-  
-  [ Eric Hammond ]
-  * Fix post_install bugs LP: #292888, LP: #292891 & LP: #292901
-  * Fix regression on locale settings LP: #292573
-
- -- Soren Hansen <soren at ubuntu.com>  Mon, 01 Dec 2008 10:31:35 +0100
-
-vm-builder (0.9-0ubuntu3.1) intrepid-security; urgency=low
-
-  * SECURITY UPDATE: vm-builder creates predictable root password when
-    creating virtual machines (LP: #296841)
-    - VMBuilder/plugins/ubuntu/dapper.py: invoke chpasswd with '-e'
-    - CVE-2008-XXXX (to be filled in)
-
- -- Jamie Strandboge <jamie at ubuntu.com>  Tue, 11 Nov 2008 16:05:56 -0600
-
-vm-builder (0.9-0ubuntu3) intrepid; urgency=low
-
-  [ Johan Euphrosine ]
-  * Fix exception when suite provided does not exist (LP: #281801) 
-    and provide unit test for it.
-
-  [ Chuck Short ]
-  * Added parameters required for EC2 plugin.
-  * Use ec2_name instead of hostname when submitting an AMI.
-  * Update xen_kernel_path and xen_ramdisk_path for intrepid.
-  * Default to amazon kernels/ramdisk pairs for now.
-  * Split out ec2 module into its own package. (LP: #284762)
-
-  [ Nicolas Barcet ]
-  * Error out if domain is undefined (LP: #280125)
-  * Fix --dest so that it is actually used now (LP: #280091)
-  * Fix -c handling, values are now used (LP: #279159)
-  * Create /var/run/network to fix bug LP: #276365
-  * Handle fsimage type vms (Xen) in fstab and (hopefully) libvirt  (LP: #282109)
-  * Components where not parsed correctly (LP: #283263)
-  * preflight_check() was called twice in a row in vm.py for no aparant
-    reasons
-  * Change default suite to intrepid
-  * Intrepid needs groot=uuid, else update-grub tries to outsmart us later on
-    and it won't boot as it cannot guess the uuid right.
-  * Couple fixes when calling devletters, which is a function
-  * Double parenthesis removed in devicemap.tmpl
-  * Added function isDomain to fix bug LP: #284746
-  * Documented unusual conf name value in help to fix bug LP: #284614
-  * Fixed a bug in set_defaults occuring on reading untyped value from the
-    configuration file
-  * Match ec2 vocabulary by adding option name and clarifying help 
-    (LP: #284765, LP: #285170, LP: #285165)
-  * Added a check for xen hypervisor when ec2 is selected (LP: #285191)
-  * Added checks for presence of bucket, access key and secret key for ec2 
-    (LP: #284757)
-  * Older suite need 128 bit inode for grub to recognize os. Thanks to Albert
-    Damen for the pointer (LP: #285093)
-  * The libvirt plugin now errors out if used with something else than KVM, as
-    nothing else is supported yet.
-  * Write out disk info in vmware's .vmx, converting it to use template while
-    at it (LP: #286487)
-  * Add 'config.version = "8"' to vmware.tmpl to fix LP: #286531
-
-  [ Mathias Gug ]
-  * Fix --templates option.
-
-  [ Soren Hansen ]
-  * Create /var/{run,lock} on the root filesystem, just like d-i.
-
- -- Soren Hansen <soren at ubuntu.com>  Fri, 24 Oct 2008 13:15:23 +0200
-
-vm-builder (0.9-0ubuntu2) intrepid; urgency=low
-
-  [ Nicolas Barcet ]
-  * Added hint for more help (LP: #269323)
-  * Added firstscripts plugin to fix regression on --firstboot and --firstlogin (LP: #268957)
-  * Added postinst plugin to fix regression on --exec and add --copy (LP: #268955) 
-  * Added man page.
-
-  [ Soren Hansen ]
-  * Include ubuntu-vm-builder package. (LP: #277272)
-  * Read additional config file given by '-c'. (LP: #276813)
-  * Fix regression from ubuntu-vm-builder: Make output from subprocess
-    non-buffered.
-  * Let --overwrite apply for libvirt as well. (LP: #276322)
-
- -- Soren Hansen <soren at ubuntu.com>  Fri, 03 Oct 2008 18:52:06 +0200
-
-vm-builder (0.9-0ubuntu1) intrepid; urgency=low
-
-  [Nicolas Barcet <nicolas.barcet at ubuntu.com>]
-  * Fixed regression on --ip and friends (LP: #268920)
-  * Added missing dependancy on dpkg-dev (LP: #270324)
-  * Fixed regression on --part (LP: #268718)
-  
- -- Soren Hansen <soren at ubuntu.com>  Wed, 24 Sep 2008 09:58:35 +0200
-
-vm-builder (0.8.1-0ubuntu3) intrepid; urgency=low
-
-  [Soren Hansen <soren at ubuntu.com>]
-  * Re-add VMWare support. (LP: #268140) 
-  * Fixed sources.list generation for Ubuntu. (LP: #268155)
-  * Added configuration file handling. (LP: #268170)
-  * Fix up Xen support (device and configuration file creation). (LP: #268142)
-
- -- Soren Hansen <soren at ubuntu.com>  Tue, 09 Sep 2008 17:01:02 +0200
-
-vm-builder (0.8.1-0ubuntu2) intrepid; urgency=low
-
-  * Apply patch to only conditionally import libvirt. Fixes FTBFS.
-
- -- Soren Hansen <soren at ubuntu.com>  Thu, 04 Sep 2008 09:50:27 +0200
-
-vm-builder (0.8.1-0ubuntu1) intrepid; urgency=low
-
-  * Added lots of inline documentation.
-  * Build documentation using epydoc.
-  * Moved libvirt support to a separate plugin. (LP: #264605)
-  * Deploy directly to libvirt (regression from ubuntu-vm-builder). (LP: #264604)
-  * Updated debian/{copyright,control} to reflect move on Launchpad.
-  * No longer a native package.
-
- -- Soren Hansen <soren at ubuntu.com>  Thu, 04 Sep 2008 09:33:29 +0200
-
-vm-builder (0.8) intrepid; urgency=low
-
-  * Rewrote the entire thing in Python.
-
- -- Soren Hansen <soren at ubuntu.com>  Sat, 05 Jul 2008 00:23:20 +0200
-
-ubuntu-vm-builder (0.7~ppa2) intrepid; urgency=low
-
-  [Thierry Carrez]
-  * Patch to fix lilo prompt (fix LP: #206763)
-  
-  [Loic Minier]
-  * Add support for "security mirror"; --security-mirror flag, SECURITY_MIRROR
-    config; defaults to security.u.c/ubuntu for official arches and to
-    ports.ubuntu.com/ubuntu-ports for lpia.
- 
-  [Nicolas Barcet]
-  * Merge --in-place option from Hardy.
-  * Fix case when domain is not defined on the host, thanks to Thierry Carrez
-    (LP: #237580)
-  * Fix console-setup the good way (by copying /etc/console-setup) thanks
-    again to Thierry Carrez (LP: #237616)
-  * Fix config-handler to not break with --arch option
-  * Change config handler to use default and etc configurations as well
-  * Make VMHOSTNAME more meaningfull by default
-
- -- Nicolas Barcet <nicolas.barcet at ubuntu.com>  Tue, 18 Jun 2008 18:59:18 +0200
-
-ubuntu-vm-builder (0.7~ppa1) intrepid; urgency=low
-
-  [Michael Vogt]
-  * Add Intrepid to the suites
-
-  [Loic Minier]
-  * Fix unchecked usage of $SUDO_USER which might be unset when creating the
-    configuration.
-  * Set LIBVIRT URL to the empty string if it isn't set in the env.
-
-  [Nick Barcet]
-  * Added -c option to specify an alternate configuration file
-
- -- Nicolas Barcet <nicolas.barcet at ubuntu.com>  Fri, 31 May 2008 00:14:00 +0200
-
-ubuntu-vm-builder (0.4-0ubuntu0.3) hardy-proposed; urgency=low
-
-  * Add --in-place option that will allow ubuntu-vm-builder to function when
-    $TMPDIR is nodev and/or nosuid. (LP: #228744)
-
- -- Soren Hansen <soren at ubuntu.com>  Tue, 03 Jun 2008 14:43:51 +0200
-
-ubuntu-vm-builder (0.6) intrepid; urgency=low
-
-  * Release into Ubuntu proper.
-
- -- Soren Hansen <soren at ubuntu.com>  Wed, 28 May 2008 11:36:02 +0200
-
-ubuntu-vm-builder (0.5ubuntu1~ppa4) intrepid; urgency=low
-
-  [Loic Minier]
-  * Call sh -c "$EXEC_SCRIPT" instead of "$EXEC_SCRIPT"; allows to pass
-    arguments to the script; also remove check that EXEC_SCRIPT exists.
-
-  [Nick Barcet]
-  * Adding an error handler to fix LP: #217950
-  * Lots of sanitization to allow for error handler
-  * Add an interrupt handler to cleanup if user interrupts script
-  * Stop on error in user script to fix LP: #228675
-  * --ssh-key adds key to root and --ssh-user-key adds key to user
-  * Added --raw option to install on raw devices/files.
-    WARNING: the variables used in template files for disk definition have been
-    modified.  Please insure that locally created templates are updated to
-    reflect this change. 
-  * Add --firstboot and --firstlogin options
-  * First login always execute "sudo dpkg-reconfigure console-setup" so
-    that the local keyboard setting is taken into account.
-  * Adding the --iso parameter to create image from an iso. This requires
-    suite and kernel-flavour parameters to match what is available on the iso,
-    obviously.
-  * Include hostname in default destination directory if defined
-  * Do not use a tmpfs by default anymore
-  * Place the working directory in the same directory as dest if using --tmp -
-  * Added --tmpfs option to specify usage of a tmpfs for the working directory 
-  * VM specific parameters do not need to be the last ones anymore
-  * Unknown parameters now return an error and prints usage
-  * Added --overwrite for overwriting of destination directory and libvirt
-    domain
-  * Added ~/.ubuntu-vm-builder config handling
-  * Man page improvements and reorganization
-
-  [Soren Hansen]
-  * Fix for LP: #234062 ssh root login broken
-
- -- Nicolas Barcet <nicolas.barcet at canonical.com>  Fri, 26 May 2008 00:01:00 +0200
-
-ubuntu-vm-builder (0.4ubuntu2~ppa7) hardy; urgency=low
-
-  [ Michael Vogt ]
-  * patch the way do_avoid_starting_daemons() to write a policy-rc.d file in
-    the same way as pbuilder does (LP: #228372)
-
-  [ Nick Barcet ]
-  * Added function do_copy_settings to fix bug LP: #221231
-  * Fix missing ipv6 entries in host file (LP: #230299)
-  * Fix issue with template arguments fetching (LP: #228268)
-  * Create the /etc/apt/sources.list properly (LP: #218195)
-  * Use a tmpfs for $WORKINGDIR to avoid case when file system is mounted
-    with no suid (LP: #228744)
-  * Unproper letters variable initialization (LP: #230312)
-  * Option --net failed other than for Class C (LP: #232361)
-
-  [ Loic Minier ]
-  * Fix v / --verbose getopt parsing. (LP: #230319)
-  * Compute the default ARCH with dpkg --print-architecture. (LP: #230323)
-  * Add support for lpia.
-    - Allow lpia arch, lpia and lpiacompat kernel flavours.
-    - Use http://ports.ubuntu.com/ubuntu-ports as default mirror for lpia.
-    - Update help/documentation.
-  * Check Release files against the archive keyring; depend on ubuntu-keyring.
-    (LP: #230334)
-
-  [ Soren Hansen ]
-  * Fix root ssh login. (LP: #234062)
-  * Fix network address handling. (LP: #232361) Thanks to Kevin Traas
-    for the patch.
-
- -- Soren Hansen <soren at ubuntu.com>  Fri, 23 May 2008 09:52:22 +0200
-
-ubuntu-vm-builder (0.4-0ubuntu0.1) hardy-security; urgency=low
-
-  * SECURITY UPDATE: adjust ubuntu-vm-builder to lock root account by default
-
- -- Nicolas Barcet <nicolas.barcet at canonical.com>  Mon, 28 Apr 2008 14:02:01 +0200
-
-ubuntu-vm-builder (0.4) hardy; urgency=low
-
-  [ Soren Hansen ]
-  * FFe reference: (LP: #208161)
-  * Replace start-stop-daemon for a while to fix problems with daemons
-    expecting to be able to listen on certaing ports, etc.
-  * Unmount volatile tmpfs from lrm.
-  * Make /opt opt-in.
-  * Make default rootsize 4096 (to match documentation).
-  * New grub installer code.
-  * Fix syntax error in kernel flavour check.
-  * Massive refactoring.
-  * Make more intelligent default choices based on chosen suite, architecture,
-    kernel flavour, etc.
-  * Further quieting of the process.
-
-  [ Nick Barcet ]
-  * Added template support for vmware and qemu/kvm.
-  * Fix a bug reported by soren where loop devices could accendentally be
-    overwritten.  Was also preventing concurrent runs of the script.
-  * Further quieting of the process.
-
- -- Soren Hansen <soren at ubuntu.com>  Wed, 02 Apr 2008 11:52:35 +0200
-
-ubuntu-vm-builder (0.3) hardy; urgency=low
-
-  * Fix perl locale warnings.
-  * Add missing --libvirt option. (LP: #194242)
-  * Add edgy to the list of supported distros (adding the appropriate quirks).
-  * Don't default to virtual kernel flavour when not installing i386. (LP:
-    #194240)
-  * Remove references to JeOS. (LP: #194233)
-  * Give more useful error messages when people pass unuseful options.
-  * Make the building process much less verbose (and hence less scary).
-
- -- Soren Hansen <soren at ubuntu.com>  Wed, 12 Mar 2008 01:01:35 +0100
-
-ubuntu-vm-builder (0.2) hardy; urgency=low
-
-  * New release.
-
- -- Soren Hansen <soren at ubuntu.com>  Thu, 21 Feb 2008 00:34:20 +0100
-
-ubuntu-vm-builder (0.1) hardy; urgency=low
-
-  * Initial upload to Ubuntu.
-
- -- Soren Hansen <soren at ubuntu.com>  Thu, 14 Feb 2008 15:41:51 +0100
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 8acd841..0000000
--- a/debian/control
+++ /dev/null
@@ -1,55 +0,0 @@
-Source: vm-builder
-Section: utils
-Priority: extra
-Maintainer: Soren Hansen <soren at ubuntu.com>
-Build-Depends: cdbs, debhelper (>= 5.0.38), python-all-dev (>= 2.3.5-11), python-central (>= 0.5.6), python-epydoc
-Standards-Version: 3.8.0
-XS-Python-Version: >= 2.5
-Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-virt/vmbuilder/trunk
-
-Package: python-vm-builder
-Architecture: all
-Depends: kvm (>= 1:69) | qemu, debootstrap (>= 1.0.9), parted, kpartx, ubuntu-keyring, ${python:Depends}, python-cheetah, devscripts
-Recommends: python-libvirt
-XB-Python-Version: ${python:Versions}
-Description: VM builder
- Script that automates the process of creating a ready to use Linux based VM.
- The currently supported hypervisors are:
- .
-  * KVM 
-  * Xen
-  * VMWare
- .
- The currently supported distros are:
- .
-  * Ubuntu Dapper, Gutsy, Hardy, Intrepid, and Jaunty.
- .
- You can pass command line options to add extra packages, remove packages,
- choose which version of Ubuntu, which mirror etc. On recent hardware
- with plenty of RAM, tmpdir in /dev/shm or using a tmpfs, and a local mirror,
- you can bootstrap a vm in less than a minute.
-
-Package: ubuntu-vm-builder
-Architecture: all
-Depends: python-vm-builder
-Description: Ubuntu VM builder
- Script which automates the process of creating a ready to use VM based on
- Ubuntu. You can pass command line options to add extra packages, remove
- packages, choose which version of Ubuntu, which mirror to use etc. 
- .
- On recent hardware with plenty of RAM, tmpdir in /dev/shm or using a tmpfs,
- and a local mirror, you can bootstrap a vm in less than a minute.
-
-Package: python-vm-builder-ec2
-Architecture: all
-Depends: python-vm-builder, ec2-ami-tools, python-boto
-XB-Python-Version: ${python:Versions}
-Description: EC2 Ubuntu VM builder
- Ubuntu vmbuilder module that automates the process of create a ready to use
- EC2 image (AMI) based on Ubuntu. You can pass command line options to add
- extra packages, remove packages, choose which version of Ubuntu, which
- mirror to use etc.
- .
- VMBuilder module to build, upload and register EC2 images. You will
- need to have an Amazon EC2 account in order to use this package.
-
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 5c3e6e7..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,28 +0,0 @@
-This package was debianized by Soren Hansen <soren at ubuntu.com> on
-Thu, 28 Aug 2008 05:14:27 +0200
-
-It lives at https://code.launchpad.net/vmbuilder
-
-Copyright:
-	Copyright (C) 2007-2008  Canonical Ltd.
-
-Authors:
-	Soren Hansen <soren at canonical.com>
-
-License:
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-For the full license, see '/usr/share/common-licenses/GPL-3'.
-
-The same license and copyright applies to the Debian packaging.
diff --git a/debian/python-vm-builder-ec2.docs b/debian/python-vm-builder-ec2.docs
deleted file mode 100644
index 1e107f5..0000000
--- a/debian/python-vm-builder-ec2.docs
+++ /dev/null
@@ -1 +0,0 @@
-examples
diff --git a/debian/python-vm-builder-ec2.install b/debian/python-vm-builder-ec2.install
deleted file mode 100644
index 4ffd32e..0000000
--- a/debian/python-vm-builder-ec2.install
+++ /dev/null
@@ -1 +0,0 @@
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/ec2
diff --git a/debian/python-vm-builder.docs b/debian/python-vm-builder.docs
deleted file mode 100644
index 1936cc1..0000000
--- a/debian/python-vm-builder.docs
+++ /dev/null
@@ -1 +0,0 @@
-html
diff --git a/debian/python-vm-builder.install b/debian/python-vm-builder.install
deleted file mode 100644
index 0898e77..0000000
--- a/debian/python-vm-builder.install
+++ /dev/null
@@ -1,12 +0,0 @@
-debian/tmp/etc
-debian/tmp/usr/bin/vmbuilder
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/*.py
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/*.py
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/cli
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/firstscripts
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/kvm
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/libvirt
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/postinst
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/ubuntu
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/xen
-debian/tmp/usr/lib/python2.5/site-packages/VMBuilder/plugins/vmware
diff --git a/debian/python-vm-builder.manpages b/debian/python-vm-builder.manpages
deleted file mode 100644
index b537ab7..0000000
--- a/debian/python-vm-builder.manpages
+++ /dev/null
@@ -1 +0,0 @@
-vmbuilder.1
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 90b5d70..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/make -f
-
-DEB_PYTHON_SYSTEM = pycentral
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/python-distutils.mk
-
-# For when we add the extra package
-#DEB_DH_INSTALL_SOURCEDIR = debian/tmp
-
-#makebuilddir/python-vm-builder::
-#	if test -d .bzr; then if ! bzr diff -q > /dev/null; then echo 'ERROR! Uncommitted changes!!!' ; /bin/false ; fi; fi
-
-build/python-vm-builder:: doc-stamp
-
-doc-stamp:
-	epydoc --no-private VMBuilder
-	touch $@
-
-cleanbuilddir/python-vm-builder::
-	rm -rf html doc-stamp
diff --git a/debian/ubuntu-vm-builder.install b/debian/ubuntu-vm-builder.install
deleted file mode 100644
index e4ba4a3..0000000
--- a/debian/ubuntu-vm-builder.install
+++ /dev/null
@@ -1 +0,0 @@
-ubuntu-vm-builder usr/bin
diff --git a/setup.py b/setup.py
index 475894e..662d822 100755
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,21 @@
 from distutils.core import setup
 import VMBuilder.plugins
 from glob import glob
+import os.path
+import subprocess
 
+if os.path.exists('.bzr'):
+    try:
+        o = subprocess.Popen(('bzr','version-info', '--python'), stdout=subprocess.PIPE).stdout
+        f = open('VMBuilder/vcsversion.py', 'w')
+        f.write(o.read())
+        f.close()
+        o.close()
+    except Exception, e:
+        print repr(e)
+    
 setup(name='VMBuilder',
-      version='0.9',
+      version='0.11',
       description='Uncomplicated VM Builder',
       author='Soren Hansen',
       author_email='soren at canonical.com',
diff --git a/tests.py b/tests.py
index 88305d5..7ae46f0 100644
--- a/tests.py
+++ b/tests.py
@@ -1,13 +1,12 @@
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -57,6 +56,16 @@ class TestUbuntuPlugin(unittest.TestCase):
         ubuntu = Ubuntu(vm)
         self.assertRaises(VMBuilderUserError, ubuntu.preflight_check)
 
+
+class TestUtils(unittest.TestCase):
+    def test_run_cmd(self):
+        import VMBuilder
+        from VMBuilder.util import run_cmd
+        self.assertTrue("foobarbaztest" in 
+                        run_cmd("env", env={'foobarbaztest' : 'bar' }))
+
+
+
 if __name__ == '__main__':
     unittest.main()
 
diff --git a/ubuntu-vm-builder b/ubuntu-vm-builder
index e06f3e4..2d5ea0b 100755
--- a/ubuntu-vm-builder
+++ b/ubuntu-vm-builder
@@ -1,14 +1,13 @@
 #!/usr/bin/python
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/ubuntu-vm-builder.1 b/ubuntu-vm-builder.1
new file mode 100644
index 0000000..484a4c0
--- /dev/null
+++ b/ubuntu-vm-builder.1
@@ -0,0 +1,7 @@
+.TH UBUNTU-VM-BUILDER 1 "Oct 2008"
+.SH NAME
+ubuntu-vm-builder \- builds virtual machines from the command line
+.SH DESCRIPTION
+ubuntu-vm-builder is now a wrapper to vmbuilder (part of the python-vm-builder package) and is only maintained for compatibility wih previous scripts.  Please see the vmbuilder man page for more information or run 
+.B vmbuilder <hypervisor> <distro> --help
+for a full list of options.
diff --git a/vmbuilder b/vmbuilder
index 4d962d5..58a1adc 100755
--- a/vmbuilder
+++ b/vmbuilder
@@ -1,13 +1,13 @@
 #!/usr/bin/python
 #
 #    Uncomplicated VM Builder
-#    Copyright (C) 2007-2008 Canonical Ltd.
+#    Copyright (C) 2007-2009 Canonical Ltd.
 #    
 #    See AUTHORS for list of contributors
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
+#    it under the terms of the GNU General Public License version 3, as
+#    published by the Free Software Foundation.
 #    (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,

-- 
Tool for creating VM images.



More information about the Pkg-escience-soc2009 mailing list