This commit is contained in:
Joshua Boniface 2018-06-01 01:02:45 -04:00
parent 0a8faac2aa
commit 3b319fa498
1 changed files with 21 additions and 21 deletions

View File

@ -14,6 +14,27 @@ class NodeInstance(threading.Thread):
self.node_list = node_list
self.domainlist = []
@zk.DataWatch(self.zkey + '/state')
def watch_state(data, stat):
self.state = data.decode('ascii')
print("Version: %s, data: %s" % (stat.version, self.state))
@zk.DataWatch(self.zkey + '/cpucount')
def watch_cpucount(data, stat):
self.cpucount = data.decode('ascii')
print("Version: %s, data: %s" % (stat.version, self.cpucount))
@zk.DataWatch(self.zkey + '/cpuload')
def watch_cpuload(data, stat):
self.cpuload = data.decode('ascii')
print("Version: %s, data: %s" % (stat.version, self.cpuload))
@zk.DataWatch(self.zkey + '/memfree')
def watch_memfree(data, stat):
self.memfree = data.decode('ascii')
print("Version: %s, data: %s" % (stat.version, self.memfree))
# Get value functions
def getfreemem(self):
return self.memfree
@ -57,27 +78,6 @@ class NodeInstance(threading.Thread):
else:
self.setup_remote_node()
@zk.DataWatch(self.zkey + '/state')
def watch_state(data, stat):
self.state = data.decode('ascii')
print("Version: %s, data: %s" % (stat.version, self.state))
@zk.DataWatch(self.zkey + '/cpucount')
def watch_cpucount(data, stat):
self.cpucount = data.decode('ascii')
print("Version: %s, data: %s" % (stat.version, self.cpucount))
@zk.DataWatch(self.zkey + '/cpuload')
def watch_cpuload(data, stat):
self.cpuload = data.decode('ascii')
print("Version: %s, data: %s" % (stat.version, self.cpuload))
@zk.DataWatch(self.zkey + '/memfree')
def watch_memfree(data, stat):
self.memfree = data.decode('ascii')
print("Version: %s, data: %s" % (stat.version, self.memfree))
def setup_local_node(self):
# Connect to libvirt
libvirt_name = "qemu:///system"