From f58784f7b5059d66283783ac580a22b9a16a3060 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Mon, 11 Jun 2018 20:25:22 -0400 Subject: [PATCH] Fix up the startup clobber in a more elegant way --- NodeInstance.py | 1 - VMInstance.py | 18 +++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/NodeInstance.py b/NodeInstance.py index 3918e50b..0eab2287 100644 --- a/NodeInstance.py +++ b/NodeInstance.py @@ -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': diff --git a/VMInstance.py b/VMInstance.py index 9bc55d2a..8695e257 100644 --- a/VMInstance.py +++ b/VMInstance.py @@ -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')