diff --git a/NodeInstance.py b/NodeInstance.py index c6797685..82afbe96 100644 --- a/NodeInstance.py +++ b/NodeInstance.py @@ -104,13 +104,13 @@ class NodeInstance(threading.Thread): # Remove any non-running VMs from our 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] if state != libvirt.VIR_DOMAIN_RUNNING: self.domain_list.remove(domain) - except: - self.domain_list.remove(domain) # Set our information in zookeeper self.memfree = conn.getFreeMemory() diff --git a/VMInstance.py b/VMInstance.py index 6d920c0b..d2db1c11 100644 --- a/VMInstance.py +++ b/VMInstance.py @@ -26,11 +26,8 @@ class VMInstance: print('>>> %s - Failed to open local libvirt connection.' % self.domuuid) exit(1) - try: - self.dom = pvcdomf.lookupByUUID(conn, self.domuuid) - conn.close() - except libvirt.libvirtError: - self.dom = None + self.dom = pvcdomf.lookupByUUID(conn, self.domuuid) + conn.close() # Watch for changes to the hypervisor field in Zookeeper @zk.DataWatch(self.zkey + '/hypervisor') @@ -151,9 +148,8 @@ class VMInstance: print('>>> %s - Receiving migration' % self.domuuid) self.inreceive = True while True: - try: - self.dom = pvcdomf.lookupByUUID(conn, self.domuuid) - except: + self.dom = pvcdomf.lookupByUUID(conn, self.domuuid) + if self.dom == None: time.sleep(0.2) continue