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 | b447dfaaf133bf6ddd042515839aa85a16dc71cc (patch) | |
tree | bcef2930c7e81cd2bc588d806e19f4f612e4db5e /virtualbox-ssh.write | |
parent | 9832290e46a6684a30b4248bc726a38d3f3e4237 (diff) | |
download | definitions-b447dfaaf133bf6ddd042515839aa85a16dc71cc.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 'virtualbox-ssh.write')
-rwxr-xr-x | virtualbox-ssh.write | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/virtualbox-ssh.write b/virtualbox-ssh.write index dbfb90a7..5d118ec4 100755 --- a/virtualbox-ssh.write +++ b/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: |