diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-02-07 11:41:04 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-02-07 14:34:42 +0000 |
commit | 794301e1e1ec1b35145ae7bdd9093909c6488478 (patch) | |
tree | 1ca39c748baebf5ba94d7c24d12c2d88aca1343f /morphlib/exts/virtualbox-ssh.write | |
parent | e3bb31154b259eb04019e7f63f1e0270d1606e06 (diff) | |
download | morph-794301e1e1ec1b35145ae7bdd9093909c6488478.tar.gz |
Refactor: Add WriteExtension.create_local_system method
This allows code sharing amongst all the places that create a
system in a raw disk image. This also adds the creation of
a factory-run subvolume, and fixes error messages for errors
that happen during a disk image creation.
Suggested-By: Richard Maw
Suggested-By: Sam Thursfield
Diffstat (limited to 'morphlib/exts/virtualbox-ssh.write')
-rwxr-xr-x | morphlib/exts/virtualbox-ssh.write | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/morphlib/exts/virtualbox-ssh.write b/morphlib/exts/virtualbox-ssh.write index dbfb90a7..5d118ec4 100755 --- a/morphlib/exts/virtualbox-ssh.write +++ b/morphlib/exts/virtualbox-ssh.write @@ -23,6 +23,7 @@ accessed over ssh. The machine gets created, but not started. ''' +import cliapp import os import re import time @@ -61,36 +62,16 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): temp_root, location = args ssh_host, vm_name, vdi_path = self.parse_location(location) - size = self.get_disk_size() - self.status(msg='Disk size is %(size)d bytes', size=size) - - raw_disk = tempfile.mkstemp() - self.create_raw_disk_image(raw_disk, size) - try: - self.mkfs_btrfs(raw_disk) - mp = self.mount(raw_disk) - except BaseException: - self.status('EEEK') - os.remove(raw_disk) - raise - try: - self.create_factory(mp, temp_root) - self.create_fstab(mp) - self.install_extlinux(mp) - except BaseException, e: - self.status(msg='EEK') - self.unmount(mp) - os.remove(raw_disk) - raise - else: - self.unmount(mp) + fd, raw_disk = tempfile.mkstemp() + os.close(fd) + self.create_local_system(temp_root) try: self.transfer_and_convert_to_vdi( raw_disk, size, ssh_host, vdi_path) self.create_virtualbox_guest(ssh_host, vm_name, vdi_path) except BaseException: - self.status('EEEK') + sys.stderr.write('Error deploying to VirtualBox') os.remove(raw_disk) raise else: |