Fix up the startup clobber in a more elegant way
This commit is contained in:
parent
f2f9d722db
commit
f58784f7b5
|
@ -220,7 +220,6 @@ class NodeInstance():
|
||||||
self.domain_list.remove(domain)
|
self.domain_list.remove(domain)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
instance.setnoclobber()
|
|
||||||
|
|
||||||
# toggle state management of this node
|
# toggle state management of this node
|
||||||
if self.domain_state == 'flush':
|
if self.domain_state == 'flush':
|
||||||
|
|
|
@ -39,24 +39,24 @@ class VMInstance:
|
||||||
self.inshutdown = False
|
self.inshutdown = False
|
||||||
self.inmigrate = False
|
self.inmigrate = False
|
||||||
self.inreceive = False
|
self.inreceive = False
|
||||||
|
self.ininit = True
|
||||||
# These stop a weird clobber at startup
|
|
||||||
self.noclobber = False
|
|
||||||
|
|
||||||
self.dom = self.lookupByUUID(self.domuuid)
|
self.dom = self.lookupByUUID(self.domuuid)
|
||||||
|
|
||||||
# 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=""):
|
||||||
if self.noclobber == False:
|
if self.ininit == False:
|
||||||
self.noclobber = True
|
|
||||||
self.manage_vm_state()
|
self.manage_vm_state()
|
||||||
|
|
||||||
# Watch for changes to the hypervisor field in Zookeeper
|
# Watch for changes to the hypervisor field in Zookeeper
|
||||||
@zk.DataWatch('/domains/{}/hypervisor'.format(self.domuuid))
|
@zk.DataWatch('/domains/{}/hypervisor'.format(self.domuuid))
|
||||||
def watch_hypervisor(data, stat, event=""):
|
def watch_hypervisor(data, stat, event=""):
|
||||||
if self.noclobber == False:
|
if self.ininit == False:
|
||||||
self.noclobber = True
|
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()
|
self.manage_vm_state()
|
||||||
|
|
||||||
# Get data functions
|
# Get data functions
|
||||||
|
@ -66,10 +66,6 @@ class VMInstance:
|
||||||
def gethypervisor(self):
|
def gethypervisor(self):
|
||||||
return self.hypervisor
|
return self.hypervisor
|
||||||
|
|
||||||
# Allow the node to set the noclobber status once it performs its first keepalive
|
|
||||||
def setnoclobber(self):
|
|
||||||
self.noclobber = False
|
|
||||||
|
|
||||||
# Start up the VM
|
# Start up the VM
|
||||||
def start_vm(self, xmlconfig):
|
def start_vm(self, xmlconfig):
|
||||||
ansiiprint.echo('Starting VM', '{}:'.format(self.domuuid), 'i')
|
ansiiprint.echo('Starting VM', '{}:'.format(self.domuuid), 'i')
|
||||||
|
|
Loading…
Reference in New Issue