Fix up the logic and remove our extra try's around UUID lookups

This commit is contained in:
Joshua Boniface 2018-06-04 01:13:48 -04:00
parent 8904e25beb
commit ad4a9d8ea6
2 changed files with 8 additions and 12 deletions

View File

@ -104,13 +104,13 @@ class NodeInstance(threading.Thread):
# Remove any non-running VMs from our list # Remove any non-running VMs from our list
for domain in self.domain_list: for domain in self.domain_list:
try:
dom = pvcdomf.lookupByUUID(conn, domain) dom = pvcdomf.lookupByUUID(conn, domain)
if dom == None:
self.domain_list.remove(domain)
else:
state = dom.state()[0] state = dom.state()[0]
if state != libvirt.VIR_DOMAIN_RUNNING: if state != libvirt.VIR_DOMAIN_RUNNING:
self.domain_list.remove(domain) self.domain_list.remove(domain)
except:
self.domain_list.remove(domain)
# Set our information in zookeeper # Set our information in zookeeper
self.memfree = conn.getFreeMemory() self.memfree = conn.getFreeMemory()

View File

@ -26,11 +26,8 @@ class VMInstance:
print('>>> %s - Failed to open local libvirt connection.' % self.domuuid) print('>>> %s - Failed to open local libvirt connection.' % self.domuuid)
exit(1) exit(1)
try:
self.dom = pvcdomf.lookupByUUID(conn, self.domuuid) self.dom = pvcdomf.lookupByUUID(conn, self.domuuid)
conn.close() conn.close()
except libvirt.libvirtError:
self.dom = None
# Watch for changes to the hypervisor field in Zookeeper # Watch for changes to the hypervisor field in Zookeeper
@zk.DataWatch(self.zkey + '/hypervisor') @zk.DataWatch(self.zkey + '/hypervisor')
@ -151,9 +148,8 @@ class VMInstance:
print('>>> %s - Receiving migration' % self.domuuid) print('>>> %s - Receiving migration' % self.domuuid)
self.inreceive = True self.inreceive = True
while True: while True:
try:
self.dom = pvcdomf.lookupByUUID(conn, self.domuuid) self.dom = pvcdomf.lookupByUUID(conn, self.domuuid)
except: if self.dom == None:
time.sleep(0.2) time.sleep(0.2)
continue continue