summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Firth <dan.firth@codethink.co.uk>2013-10-15 11:59:34 +0100
committerDaniel Firth <dan.firth@codethink.co.uk>2013-10-15 11:59:34 +0100
commit7a11ffef90359abf7907fbe6d6afd153fb4ed745 (patch)
treeeb98988c2b44b732aa7288b1b3e2be57f85a475e
parent3a88533d4adb3fe94ae4c09ba0693d2ab761d8e0 (diff)
parenta146142f6ae7f4b20d76f68b8317eae89c4213ab (diff)
downloadmorph-7a11ffef90359abf7907fbe6d6afd153fb4ed745.tar.gz
Merge branch 'danielfirth/S9121'
Reviewed by Lars Wirzenius Reviewed by Richard Maw
-rwxr-xr-xmorphlib/exts/kvm.write1
-rwxr-xr-xmorphlib/exts/rawdisk.write10
-rwxr-xr-xmorphlib/exts/virtualbox-ssh.write2
3 files changed, 10 insertions, 3 deletions
diff --git a/morphlib/exts/kvm.write b/morphlib/exts/kvm.write
index 9a6be135..4f877c22 100755
--- a/morphlib/exts/kvm.write
+++ b/morphlib/exts/kvm.write
@@ -68,6 +68,7 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
except BaseException:
sys.stderr.write('Error deploying to libvirt')
os.remove(raw_disk)
+ cliapp.ssh_runcmd(ssh_host, ['rm', '-f', vm_path])
raise
else:
os.remove(raw_disk)
diff --git a/morphlib/exts/rawdisk.write b/morphlib/exts/rawdisk.write
index a74d6905..8723ac0c 100755
--- a/morphlib/exts/rawdisk.write
+++ b/morphlib/exts/rawdisk.write
@@ -46,8 +46,14 @@ class RawDiskWriteExtension(morphlib.writeexts.WriteExtension):
if os.path.isfile(location):
self.upgrade_local_system(location, temp_root)
else:
- self.create_local_system(temp_root, location)
- self.status(msg='Disk image has been created at %s' % location)
+ try:
+ self.create_local_system(temp_root, location)
+ self.status(msg='Disk image has been created at %s' % location)
+ except Exception:
+ os.remove(location)
+ self.status(msg='Failure to create disk image at %s' %
+ location)
+ raise
def upgrade_local_system(self, raw_disk, temp_root):
mp = self.mount(raw_disk)
diff --git a/morphlib/exts/virtualbox-ssh.write b/morphlib/exts/virtualbox-ssh.write
index 2374db31..f18ef804 100755
--- a/morphlib/exts/virtualbox-ssh.write
+++ b/morphlib/exts/virtualbox-ssh.write
@@ -76,10 +76,10 @@ class VirtualBoxPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
except BaseException:
sys.stderr.write('Error deploying to VirtualBox')
os.remove(raw_disk)
+ cliapp.ssh_runcmd(ssh_host, ['rm', '-f', vdi_path])
raise
else:
os.remove(raw_disk)
-
self.status(
msg='Virtual machine %(vm_name)s has been created',
vm_name=vm_name)