diff --git a/cli-client/pvc.py b/cli-client/pvc.py index 7f57c12a..33d6ae8d 100755 --- a/cli-client/pvc.py +++ b/cli-client/pvc.py @@ -72,8 +72,8 @@ def node_flush(node, wait): """ zk_conn = pvc_common.startZKConnection(zk_host) - retstate, retmsg = pvc_node.flush_node(zk_conn, node, wait) - cleanup(retstate, retmsg, zk_conn) + retcode, retmsg = pvc_node.flush_node(zk_conn, node, wait) + cleanup(retcode, retmsg, zk_conn) ############################################################################### # pvc node ready/unflush @@ -88,8 +88,8 @@ def node_ready(node): """ zk_conn = pvc_common.startZKConnection(zk_host) - retstate, retmsg = pvc_node.ready_node(zk_conn, node) - cleanup(retstate, retcode, zk_conn) + retcode, retmsg = pvc_node.ready_node(zk_conn, node) + cleanup(retcode, retmsg, zk_conn) @click.command(name='unflush', short_help='Restore node to service.') @click.argument( @@ -101,8 +101,8 @@ def node_unflush(node): """ zk_conn = pvc_common.startZKConnection(zk_host) - retstate, retmsg = pvc_node.ready_node(zk_conn, node) - cleanup(retstate, retcode, zk_conn) + retcode, retmsg = pvc_node.ready_node(zk_conn, node) + cleanup(retcode, retmsg, zk_conn) ############################################################################### # pvc node info diff --git a/client-common/client_lib/common.py b/client-common/client_lib/common.py index 0067b05a..94404019 100644 --- a/client-common/client_lib/common.py +++ b/client-common/client_lib/common.py @@ -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 diff --git a/client-common/client_lib/node.py b/client-common/client_lib/node.py index 92a19124..b1fb4aa3 100644 --- a/client-common/client_lib/node.py +++ b/client-common/client_lib/node.py @@ -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)