Don't listen twice in parallel, this seems doomed to failure; we only ever switch HVs by changing the state too

This commit is contained in:
Joshua Boniface 2018-06-11 21:35:37 -04:00
parent 202b8f41af
commit 78e61a759e
1 changed files with 9 additions and 11 deletions

View File

@ -39,25 +39,23 @@ class VMInstance:
self.inshutdown = False
self.inmigrate = False
self.inreceive = False
self.ininit = True
self.dom = self.lookupByUUID(self.domuuid)
# Watch for changes to the state field in Zookeeper
@zk.DataWatch('/domains/{}/state'.format(self.domuuid))
def watch_state(data, stat, event=""):
if self.ininit == False:
self.manage_vm_state()
self.manage_vm_state()
# Watch for changes to the hypervisor field in Zookeeper
@zk.DataWatch('/domains/{}/hypervisor'.format(self.domuuid))
def watch_hypervisor(data, stat, event=""):
if self.ininit == False:
self.manage_vm_state()
else:
# This case handles the very first init at startup to avoid it happening twice
self.ininit = False
self.manage_vm_state()
# @zk.DataWatch('/domains/{}/hypervisor'.format(self.domuuid))
# def watch_hypervisor(data, stat, event=""):
# if self.ininit == False:
# self.manage_vm_state()
# else:
# # This case handles the very first init at startup to avoid it happening twice
# self.ininit = False
# self.manage_vm_state()
# Get data functions
def getstate(self):