From fe93b1ed3cc75c805a4feabddcc2399d7b6dc649 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Thu, 19 Jul 2018 11:58:33 -0400 Subject: [PATCH] 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. --- pvc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pvc.py b/pvc.py index 05e29bf2..b43f36da 100755 --- a/pvc.py +++ b/pvc.py @@ -372,7 +372,11 @@ def findTargetHypervisor(zk_conn, search_field, dom_uuid): def getHypervisors(zk_conn, dom_uuid): valid_hypervisor_list = [] 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: daemon_state = zk_conn.get('/nodes/{}/daemonstate'.format(hypervisor))[0].decode('ascii')