Fix race condition and such
This commit is contained in:
parent
b3169758ff
commit
b24d8afc77
|
@ -47,22 +47,24 @@ class VMInstance:
|
||||||
def watch_hypervisor(data, stat, event=""):
|
def watch_hypervisor(data, stat, event=""):
|
||||||
print(data.decode('ascii'))
|
print(data.decode('ascii'))
|
||||||
try:
|
try:
|
||||||
|
if self.hypervisor != data.decode('ascii'):
|
||||||
self.hypervisor = data.decode('ascii')
|
self.hypervisor = data.decode('ascii')
|
||||||
self.state = self.zk.get('/domains/{}/state'.format(self.domuuid))
|
self.state = self.zk.get('/domains/{}/state'.format(self.domuuid))[0].decode('ascii')
|
||||||
self.manage_vm_state()
|
self.manage_vm_state()
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
print(e)
|
||||||
|
|
||||||
# Watch for changes to the state field in Zookeeper
|
# Watch for changes to the state field in Zookeeper
|
||||||
@zk.DataWatch('/domains/{}/state'.format(self.domuuid))
|
@zk.DataWatch('/domains/{}/state'.format(self.domuuid))
|
||||||
def watch_state(data, stat, event=""):
|
def watch_state(data, stat, event=""):
|
||||||
print(data.decode('ascii'))
|
print(data.decode('ascii'))
|
||||||
try:
|
try:
|
||||||
|
if self.state != data.decode('ascii'):
|
||||||
self.state = data.decode('ascii')
|
self.state = data.decode('ascii')
|
||||||
self.hypervisor = self.zk.get('/domains/{}/hypervisor'.format(self.domuuid))
|
self.hypervisor = self.zk.get('/domains/{}/hypervisor'.format(self.domuuid))[0].decode('ascii')
|
||||||
self.manage_vm_state()
|
self.manage_vm_state()
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
print(e)
|
||||||
|
|
||||||
# Get data functions
|
# Get data functions
|
||||||
def getstate(self):
|
def getstate(self):
|
||||||
|
|
Loading…
Reference in New Issue