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)
|
rc = execWithRedirect("virt-install", args)
|
||||||
if rc:
|
if rc:
|
||||||
raise Exception("Problem starting virtual install")
|
raise InstallError("Problem starting virtual install")
|
||||||
|
|
||||||
conn = libvirt.openReadOnly(None)
|
conn = libvirt.openReadOnly(None)
|
||||||
dom = conn.lookupByName(self.virt_name)
|
dom = conn.lookupByName(self.virt_name)
|
||||||
@ -726,16 +726,22 @@ def virt_install(opts, install_log, disk_img, disk_size):
|
|||||||
else:
|
else:
|
||||||
diskimg_path = disk_img
|
diskimg_path = disk_img
|
||||||
|
|
||||||
virt = VirtualInstall(iso_mount, opts.ks, diskimg_path, disk_size,
|
try:
|
||||||
kernel_args, opts.ram, opts.vnc, opts.arch,
|
virt = VirtualInstall(iso_mount, opts.ks, diskimg_path, disk_size,
|
||||||
log_check = log_monitor.server.log_check,
|
kernel_args, opts.ram, opts.vnc, opts.arch,
|
||||||
virtio_host = log_monitor.host,
|
log_check = log_monitor.server.log_check,
|
||||||
virtio_port = log_monitor.port,
|
virtio_host = log_monitor.host,
|
||||||
qcow2=opts.qcow2)
|
virtio_port = log_monitor.port,
|
||||||
|
qcow2=opts.qcow2)
|
||||||
|
|
||||||
virt.destroy()
|
virt.destroy()
|
||||||
log_monitor.shutdown()
|
log_monitor.shutdown()
|
||||||
iso_mount.umount()
|
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():
|
if log_monitor.server.log_check():
|
||||||
raise InstallError("virt_install failed")
|
raise InstallError("virt_install failed")
|
||||||
@ -812,7 +818,7 @@ def make_image(opts, ks):
|
|||||||
virt_install(opts, install_log, disk_img, disk_size)
|
virt_install(opts, install_log, disk_img, disk_size)
|
||||||
except InstallError as e:
|
except InstallError as e:
|
||||||
log.error("Install failed: {0}".format(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")
|
log.info("Removing bad disk image")
|
||||||
os.unlink(disk_img)
|
os.unlink(disk_img)
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user