Add try block around cur hypervisor

On initial deploy this doesn't work since the value is empty; just
set the value to None in this case.
This commit is contained in:
Joshua Boniface 2018-07-19 11:58:33 -04:00
parent 962cc0f5b0
commit fe93b1ed3c
1 changed files with 5 additions and 1 deletions

6
pvc.py
View File

@ -372,7 +372,11 @@ def findTargetHypervisor(zk_conn, search_field, dom_uuid):
def getHypervisors(zk_conn, dom_uuid): def getHypervisors(zk_conn, dom_uuid):
valid_hypervisor_list = [] valid_hypervisor_list = []
full_hypervisor_list = zk_conn.get_children('/nodes') full_hypervisor_list = zk_conn.get_children('/nodes')
current_hypervisor = zk_conn.get('/domains/{}/hypervisor'.format(dom_uuid))[0].decode('ascii')
try:
current_hypervisor = zk_conn.get('/domains/{}/hypervisor'.format(dom_uuid))[0].decode('ascii')
except:
current_hypervisor = None
for hypervisor in full_hypervisor_list: for hypervisor in full_hypervisor_list:
daemon_state = zk_conn.get('/nodes/{}/daemonstate'.format(hypervisor))[0].decode('ascii') daemon_state = zk_conn.get('/nodes/{}/daemonstate'.format(hypervisor))[0].decode('ascii')