Handle case where VM is deleted
This commit is contained in:
parent
176764f382
commit
f2db381969
|
@ -44,13 +44,19 @@ class VMInstance:
|
||||||
# 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')
|
||||||
def watch_hypervisor(data, stat, event=""):
|
def watch_hypervisor(data, stat, event=""):
|
||||||
|
try:
|
||||||
self.hypervisor = data.decode('ascii')
|
self.hypervisor = data.decode('ascii')
|
||||||
|
except:
|
||||||
|
return
|
||||||
self.manage_vm_state()
|
self.manage_vm_state()
|
||||||
|
|
||||||
# Watch for changes to the state field in Zookeeper
|
# Watch for changes to the state field in Zookeeper
|
||||||
@zk.DataWatch(self.zkey + '/state')
|
@zk.DataWatch(self.zkey + '/state')
|
||||||
def watch_state(data, stat, event=""):
|
def watch_state(data, stat, event=""):
|
||||||
|
try:
|
||||||
self.state = data.decode('ascii')
|
self.state = data.decode('ascii')
|
||||||
|
except:
|
||||||
|
return
|
||||||
self.manage_vm_state()
|
self.manage_vm_state()
|
||||||
|
|
||||||
# Get data functions
|
# Get data functions
|
||||||
|
@ -197,6 +203,7 @@ class VMInstance:
|
||||||
# Check the current state of the VM
|
# Check the current state of the VM
|
||||||
try:
|
try:
|
||||||
if self.dom != None:
|
if self.dom != None:
|
||||||
|
try:
|
||||||
running, reason = self.dom.state()
|
running, reason = self.dom.state()
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in New Issue