Fix some bugs

This commit is contained in:
2018-09-23 01:05:54 -04:00
parent 6dfb9d8539
commit 85d6e02ed2
3 changed files with 14 additions and 11 deletions

View File

@ -170,9 +170,9 @@ def getDomainControllers(parsed_xml):
def verifyNode(zk_conn, node):
try:
zk_conn.get('/nodes/{}'.format(node))
return True
except:
click.echo('ERROR: No node named "{}" is present in the cluster.'.format(node))
exit(1)
return False
#
# Get the list of valid target hypervisors

View File

@ -106,7 +106,8 @@ def getInformationFromNode(zk_conn, node_name, long_output):
#
def flush_node(zk_conn, node, wait):
# Verify node is valid
common.verifyNode(zk_conn, node)
if not common.verifyNode(zk_conn, node):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
click.echo('Flushing hypervisor {} of running VMs.'.format(node))
@ -126,7 +127,8 @@ def flush_node(zk_conn, node, wait):
def ready_node(zk_conn, node):
# Verify node is valid
common.verifyNode(zk_conn, node)
if not common.verifyNode(zk_conn, node):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
click.echo('Restoring hypervisor {} to active service.'.format(node))
@ -139,7 +141,8 @@ def ready_node(zk_conn, node):
def get_info(zk_conn, node, long_output):
# Verify node is valid
common.verifyNode(zk_conn, node)
if not common.verifyNode(zk_conn, node):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
# Get information about node in a pretty format
information = getInformationFromNode(zk_conn, node, long_output)