Add s_domain elements and data from VM instances

This commit is contained in:
2018-06-02 15:03:44 -04:00
parent f61be2c30b
commit cbfd3a8a31
2 changed files with 20 additions and 2 deletions

View File

@ -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]