diff options
author | Dan Firth <dan.firth@codethink.co.uk> | 2013-10-10 16:07:37 +0000 |
---|---|---|
committer | Dan Firth <dan.firth@codethink.co.uk> | 2013-10-14 12:00:27 +0000 |
commit | 1e57089d8aa73ffc49ef80622206d43e1bd15bf0 (patch) | |
tree | 493c8ec041a89afbb713869d9c89563e37745b5e | |
parent | dc3d9cd1de7fcc4d0fed2ff4d958c73817415d9c (diff) | |
download | definitions-1e57089d8aa73ffc49ef80622206d43e1bd15bf0.tar.gz |
Deployment failures will now remove the disk image
-rwxr-xr-x | kvm.write | 1 | ||||
-rwxr-xr-x | rawdisk.write | 10 | ||||
-rwxr-xr-x | virtualbox-ssh.write | 2 |
3 files changed, 10 insertions, 3 deletions
@@ -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/rawdisk.write b/rawdisk.write index a74d6905..8723ac0c 100755 --- a/rawdisk.write +++ b/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/virtualbox-ssh.write b/virtualbox-ssh.write index 2374db31..f18ef804 100755 --- a/virtualbox-ssh.write +++ b/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) |