diff --git a/NodeInstance.py b/NodeInstance.py index a361d958..6010c51c 100644 --- a/NodeInstance.py +++ b/NodeInstance.py @@ -3,7 +3,7 @@ import os, socket, time, uuid, threading, libvirt, kazoo.client class NodeInstance(threading.Thread): - def __init__(self, name, node_list, zk): + def __init__(self, name, node_list, s_domain, zk): super(NodeInstance, self).__init__() # Passed-in variables on creation self.zkey = '/nodes/%s' % name @@ -12,6 +12,7 @@ class NodeInstance(threading.Thread): self.state = 'stop' self.stop_thread = threading.Event() self.node_list = node_list + self.s_domain = s_domain self.domain_list = [] # Zookeeper handlers for changed states @@ -47,6 +48,9 @@ class NodeInstance(threading.Thread): def updatenodelist(self, node_list): self.node_list = node_list + def updatedomainlist(self, s_domain): + self.s_domain = s_domain + # Shutdown the thread def stop(self): self.stop_thread.set() @@ -102,6 +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()) + # Set our information in zookeeper self.memfree = conn.getFreeMemory() self.cpuload = os.getloadavg()[0] diff --git a/VMInstance.py b/VMInstance.py index 8b53e97b..3f65c727 100644 --- a/VMInstance.py +++ b/VMInstance.py @@ -28,7 +28,17 @@ class VMInstance: if self.state != data.decode('ascii'): self.state = data.decode('ascii') self.manage_vm_state() - + + # Get data functions + def getdomuuid(): + return self.domuuid + + def getstate(): + return self.state + + def getdom(): + return self.dom + # Start up the VM def start_vm(self, conn, xmlconfig): print("Starting VM %s" % self.domuuid)