Add ability to update nodelists

This commit is contained in:
Joshua Boniface 2018-05-31 23:01:22 -04:00
parent 16613d900e
commit 77c5c2ccf7
2 changed files with 14 additions and 6 deletions

View File

@ -23,6 +23,10 @@ class NodeInstance(threading.Thread):
def getname(): def getname():
return self.name return self.name
# Update value functions
def updatenodelist(node_list):
self.node_list = node_list
# Shutdown the thread # Shutdown the thread
def stop(self): def stop(self):
self.stop_thread.set() self.stop_thread.set()
@ -71,6 +75,7 @@ class NodeInstance(threading.Thread):
self.zk.set(self.zkey + '/memfree', str(self.memfree).encode('ascii')) self.zk.set(self.zkey + '/memfree', str(self.memfree).encode('ascii'))
self.zk.set(self.zkey + '/cpuload', str(self.cpuload).encode('ascii')) self.zk.set(self.zkey + '/cpuload', str(self.cpuload).encode('ascii'))
print("Free memory: %s | Load: %s" % ( self.memfree, self.cpuload )) print("Free memory: %s | Load: %s" % ( self.memfree, self.cpuload ))
print("Node list: %s" % self.node_list)
print("Active domains: %s" % self.domainlist) print("Active domains: %s" % self.domainlist)
for x in range(0,50): for x in range(0,50):
time.sleep(0.1) time.sleep(0.1)

15
pvcd.py
View File

@ -59,8 +59,16 @@ if not zk.exists('%s' + mynodestring):
time.sleep(1) time.sleep(1)
def updatenodes():
node_list = zk.get_children('/nodes')
print(node_list)
for node in node_list:
if t_node[node] is None:
t_node[node] = NodeInstance.NodeInstance(node, node_list, zk);
else:
t_node[node].updatenodelist(node_list)
node_list = zk.get_children('/nodes') node_list = zk.get_children('/nodes')
print(node_list)
domain_list = zk.get_children('/domains') domain_list = zk.get_children('/domains')
print(domain_list) print(domain_list)
@ -68,11 +76,6 @@ print(domain_list)
t_node = dict() t_node = dict()
s_domain = dict() s_domain = dict()
for node in node_list:
t_node[node] = NodeInstance.NodeInstance(node, node_list, zk);
if t_node[node].name == myhostname:
t_node[node].start()
time.sleep(1) time.sleep(1)
for domain in domain_list: for domain in domain_list: