Don't throw exception while defining new VM

This would throw an exception since we tried to find the current host of
a VM that did not exist yet. If this happens, just get None.
This commit is contained in:
Joshua Boniface 2019-12-19 11:30:13 -05:00
parent 8c252aeecc
commit 2d14fabe62
1 changed files with 4 additions and 1 deletions

View File

@ -334,7 +334,10 @@ def findTargetNode(zk_conn, dom_uuid):
def getNodes(zk_conn, node_limit, dom_uuid):
valid_node_list = []
full_node_list = zkhandler.listchildren(zk_conn, '/nodes')
current_node = zkhandler.readdata(zk_conn, '/domains/{}/node'.format(dom_uuid))
try:
current_node = zkhandler.readdata(zk_conn, '/domains/{}/node'.format(dom_uuid))
except kazoo.exceptions.NoNodeError:
current_node = None
for node in full_node_list:
if node_limit and node not in node_limit: