1
0
mirror of https://pagure.io/fedora-qa/createhdds.git synced 2024-11-21 15:03:07 +00:00

Get the domain again before cleaning it up, catch errors

Whoops, that last commit just wasn't very good. We need to
re-open the libvirt connection and re-get the domain object,
and also we should catch errors while destroying and undefining
the domain...

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2017-08-31 17:28:04 -04:00
parent ba1dd56896
commit 12e3a050b7

View File

@ -305,8 +305,18 @@ class VirtInstallImage(object):
ret = subprocess.call(args, timeout=3600)
except subprocess.TimeoutExpired:
logger.warning("Image creation timed out!")
dom.destroy()
dom.undefine()
# clean up the domain again
conn = libvirt.open()
dom = conn.lookupByName('createhdds')
try:
dom.destroy()
except libvirt.libvirtError:
# maybe it died already
pass
try:
dom.undefine()
except libvirt.libvirtError:
pass
conn.close()
if os.path.isfile(tmpfile):
os.remove(tmpfile)