Add try blocks around decode functions for when a new daemon is created

This commit is contained in:
Joshua Boniface 2018-06-06 01:24:28 -04:00
parent ec0dacb042
commit 34fb851c33
1 changed files with 13 additions and 3 deletions

View File

@ -21,7 +21,11 @@ class NodeInstance(threading.Thread):
# Zookeeper handlers for changed states # Zookeeper handlers for changed states
@zk.DataWatch(self.zkey + '/state') @zk.DataWatch(self.zkey + '/state')
def watch_hypervisor_state(data, stat, event=""): def watch_hypervisor_state(data, stat, event=""):
try:
self.state = data.decode('ascii') self.state = data.decode('ascii')
except AttributeError:
self.state = 'stop'
if self.state == 'flush': if self.state == 'flush':
self.flush() self.flush()
if self.state == 'unflush': if self.state == 'unflush':
@ -29,11 +33,17 @@ class NodeInstance(threading.Thread):
@zk.DataWatch(self.zkey + '/memfree') @zk.DataWatch(self.zkey + '/memfree')
def watch_hypervisor_memfree(data, stat, event=""): def watch_hypervisor_memfree(data, stat, event=""):
try:
self.memfree = data.decode('ascii') self.memfree = data.decode('ascii')
except AttributeError:
self.memfree = 0
@zk.DataWatch(self.zkey + '/runningdomains') @zk.DataWatch(self.zkey + '/runningdomains')
def watch_hypervisor_runningdomains(data, stat, event=""): def watch_hypervisor_runningdomains(data, stat, event=""):
try:
self.domain_list = data.decode('ascii').split() self.domain_list = data.decode('ascii').split()
except AttributeError:
self.domain_list = []
# Get value functions # Get value functions
def getfreemem(self): def getfreemem(self):