From beef743dd63b43061c3b356f0524b99f19580caa Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sat, 2 Jun 2018 15:19:29 -0400 Subject: [PATCH] Fix up state toggles --- NodeInstance.py | 7 ++++--- VMInstance.py | 9 +++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/NodeInstance.py b/NodeInstance.py index 6010c51c..9c373689 100644 --- a/NodeInstance.py +++ b/NodeInstance.py @@ -106,9 +106,10 @@ class NodeInstance(threading.Thread): except: self.domain_list.remove(domain) - # Start any VMs which should be running - for domain in self.s_domain: - print(domain.getdomuuid()) + # Toggle state management of all VMs to start any that are failed + for domain, instance in self.s_domain.items(): + if instance.gethypervisor() == self.name and ( instance.getstate() == 'start' or instance.getstate() == 'migrate' ): + instance.manage_vm_state() # Set our information in zookeeper self.memfree = conn.getFreeMemory() diff --git a/VMInstance.py b/VMInstance.py index 3f65c727..7c97017a 100644 --- a/VMInstance.py +++ b/VMInstance.py @@ -30,14 +30,11 @@ class VMInstance: self.manage_vm_state() # Get data functions - def getdomuuid(): - return self.domuuid - - def getstate(): + def getstate(self): return self.state - def getdom(): - return self.dom + def gethypervisor(self): + return self.hypervisor # Start up the VM def start_vm(self, conn, xmlconfig):