Fix up the startup clobber in a more elegant way

This commit is contained in:
Joshua Boniface 2018-06-11 20:25:22 -04:00
parent f2f9d722db
commit f58784f7b5
2 changed files with 7 additions and 12 deletions

View File

@ -220,7 +220,6 @@ class NodeInstance():
self.domain_list.remove(domain)
except:
pass
instance.setnoclobber()
# toggle state management of this node
if self.domain_state == 'flush':

View File

@ -39,24 +39,24 @@ class VMInstance:
self.inshutdown = False
self.inmigrate = False
self.inreceive = False
# These stop a weird clobber at startup
self.noclobber = 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.noclobber == False:
self.noclobber = True
if self.ininit == False:
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.noclobber == False:
self.noclobber = True
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
@ -66,10 +66,6 @@ class VMInstance:
def gethypervisor(self):
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
def start_vm(self, xmlconfig):
ansiiprint.echo('Starting VM', '{}:'.format(self.domuuid), 'i')