Add s_domain elements and data from VM instances
This commit is contained in:
parent
f61be2c30b
commit
cbfd3a8a31
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue