diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-11-17 17:41:03 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-11-17 17:42:26 +0000 |
commit | 197fbfc58a65ac224e1c8106899571614738c7bb (patch) | |
tree | 1fa30ca263262dbb63a75775a29518606b392875 | |
parent | 771b8bda2321de5d70b2ffcdbc1e4eaafc792fda (diff) | |
download | morph-197fbfc58a65ac224e1c8106899571614738c7bb.tar.gz |
Apply changes to all write extensions that uses create_local_systembaserock/pedroalvarez/rawdisk-to-device5
-rwxr-xr-x | morphlib/exts/kvm.write | 8 | ||||
-rwxr-xr-x | morphlib/exts/openstack.write | 20 | ||||
-rwxr-xr-x | morphlib/exts/virtualbox-ssh.write | 9 |
3 files changed, 25 insertions, 12 deletions
diff --git a/morphlib/exts/kvm.write b/morphlib/exts/kvm.write index 16f188b5..fa98dcdf 100755 --- a/morphlib/exts/kvm.write +++ b/morphlib/exts/kvm.write @@ -62,14 +62,16 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension): fd, raw_disk = tempfile.mkstemp() os.close(fd) - self.create_local_system(temp_root, raw_disk) - try: + self.create_filesytem(raw_disk) + self.format_btrfs(raw_disk) + self.create_system(temp_root, raw_disk) self.transfer(raw_disk, ssh_host, vm_path) self.create_libvirt_guest(ssh_host, vm_name, vm_path, autostart) except BaseException: sys.stderr.write('Error deploying to libvirt') - os.remove(raw_disk) + if os.path.exists(raw_disk): + os.remove(raw_disk) cliapp.ssh_runcmd(ssh_host, ['rm', '-f', vm_path]) raise else: diff --git a/morphlib/exts/openstack.write b/morphlib/exts/openstack.write index 516fe367..9513ee5d 100755 --- a/morphlib/exts/openstack.write +++ b/morphlib/exts/openstack.write @@ -68,13 +68,21 @@ class OpenStackWriteExtension(morphlib.writeexts.WriteExtension): fd, raw_disk = tempfile.mkstemp() os.close(fd) - self.create_local_system(temp_root, raw_disk) - self.status(msg='Temporary disk image has been created at %s' - % raw_disk) - self.set_extlinux_root_to_virtio(raw_disk) - - self.configure_openstack_image(raw_disk, location, os_params) + try: + self.create_filesytem(raw_disk) + self.format_btrfs(raw_disk) + self.create_system(temp_root, raw_disk) + self.status(msg='Temporary disk image has been created at %s' + % raw_disk) + + self.set_extlinux_root_to_virtio(raw_disk) + + self.configure_openstack_image(raw_disk, location, os_params) + except BaseException: + sys.stderr.write('Error deploying to OpenStack') + if os.path.exists(raw_disk): + os.remove(raw_disk) def set_extlinux_root_to_virtio(self, raw_disk): '''Re-configures extlinux to use virtio disks''' diff --git a/morphlib/exts/virtualbox-ssh.write b/morphlib/exts/virtualbox-ssh.write index 39ea8f86..e427fb14 100755 --- a/morphlib/exts/virtualbox-ssh.write +++ b/morphlib/exts/virtualbox-ssh.write @@ -68,16 +68,19 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension): fd, raw_disk = tempfile.mkstemp() os.close(fd) - self.create_local_system(temp_root, raw_disk) - try: + self.create_filesytem(raw_disk) + self.format_btrfs(raw_disk) + self.create_system(temp_root, raw_disk) + self.transfer_and_convert_to_vdi( raw_disk, ssh_host, vdi_path) self.create_virtualbox_guest(ssh_host, vm_name, vdi_path, autostart, vagrant) except BaseException: sys.stderr.write('Error deploying to VirtualBox') - os.remove(raw_disk) + if os.path.exists(raw_disk): + os.remove(raw_disk) cliapp.ssh_runcmd(ssh_host, ['rm', '-f', vdi_path]) raise else: |