diff --git a/NodeInstance.py b/NodeInstance.py index 31bd9d5a..f9a7200e 100644 --- a/NodeInstance.py +++ b/NodeInstance.py @@ -23,6 +23,10 @@ class NodeInstance(threading.Thread): def getname(): return self.name + # Update value functions + def updatenodelist(node_list): + self.node_list = node_list + # Shutdown the thread def stop(self): 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 + '/cpuload', str(self.cpuload).encode('ascii')) print("Free memory: %s | Load: %s" % ( self.memfree, self.cpuload )) + print("Node list: %s" % self.node_list) print("Active domains: %s" % self.domainlist) for x in range(0,50): time.sleep(0.1) diff --git a/pvcd.py b/pvcd.py index b7c74d4f..dd607fe6 100755 --- a/pvcd.py +++ b/pvcd.py @@ -59,8 +59,16 @@ if not zk.exists('%s' + mynodestring): 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') -print(node_list) domain_list = zk.get_children('/domains') print(domain_list) @@ -68,11 +76,6 @@ print(domain_list) t_node = 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) for domain in domain_list: