livemedia-creator: Handle virt-install failure cleanup
Unmount the iso and remove the disk, if it exists.
This commit is contained in:
parent
d79222e8ea
commit
b22a7df476
@ -359,7 +359,7 @@ class VirtualInstall(object):
|
||||
|
||||
rc = execWithRedirect("virt-install", args)
|
||||
if rc:
|
||||
raise Exception("Problem starting virtual install")
|
||||
raise InstallError("Problem starting virtual install")
|
||||
|
||||
conn = libvirt.openReadOnly(None)
|
||||
dom = conn.lookupByName(self.virt_name)
|
||||
@ -726,6 +726,7 @@ def virt_install(opts, install_log, disk_img, disk_size):
|
||||
else:
|
||||
diskimg_path = disk_img
|
||||
|
||||
try:
|
||||
virt = VirtualInstall(iso_mount, opts.ks, diskimg_path, disk_size,
|
||||
kernel_args, opts.ram, opts.vnc, opts.arch,
|
||||
log_check = log_monitor.server.log_check,
|
||||
@ -735,6 +736,11 @@ def virt_install(opts, install_log, disk_img, disk_size):
|
||||
|
||||
virt.destroy()
|
||||
log_monitor.shutdown()
|
||||
except InstallError as e:
|
||||
log.error("VirtualInstall failed: %s", e)
|
||||
raise
|
||||
finally:
|
||||
log.info("unmounting the iso")
|
||||
iso_mount.umount()
|
||||
|
||||
if log_monitor.server.log_check():
|
||||
@ -812,7 +818,7 @@ def make_image(opts, ks):
|
||||
virt_install(opts, install_log, disk_img, disk_size)
|
||||
except InstallError as e:
|
||||
log.error("Install failed: {0}".format(e))
|
||||
if not opts.keep_image:
|
||||
if not opts.keep_image and os.path.exists(disk_img):
|
||||
log.info("Removing bad disk image")
|
||||
os.unlink(disk_img)
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user