livemedia-creator: Handle virt-install failure cleanup
This commit is contained in:
parent
4b86677485
commit
280f36dad7
@ -311,7 +311,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)
|
||||
@ -625,14 +625,20 @@ def virt_install(opts, install_log, disk_img, disk_size):
|
||||
if opts.proxy:
|
||||
kernel_args += " proxy="+opts.proxy
|
||||
|
||||
virt = VirtualInstall(iso_mount, opts.ks, disk_img, disk_size,
|
||||
kernel_args, opts.ram, opts.vnc, opts.arch,
|
||||
log_check = log_monitor.server.log_check,
|
||||
virtio_host = log_monitor.host,
|
||||
virtio_port = log_monitor.port)
|
||||
virt.destroy()
|
||||
log_monitor.shutdown()
|
||||
iso_mount.umount()
|
||||
try:
|
||||
virt = VirtualInstall(iso_mount, opts.ks, disk_img, disk_size,
|
||||
kernel_args, opts.ram, opts.vnc, opts.arch,
|
||||
log_check = log_monitor.server.log_check,
|
||||
virtio_host = log_monitor.host,
|
||||
virtio_port = log_monitor.port)
|
||||
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():
|
||||
raise InstallError("virt_install failed")
|
||||
@ -682,7 +688,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