diff --git a/client-cli/pvc.py b/client-cli/pvc.py index 08245c6b..5cb91548 100755 --- a/client-cli/pvc.py +++ b/client-cli/pvc.py @@ -580,7 +580,11 @@ def vm_info(domain, long_output): '-n', '--node', 'node', default=None, help='Limit list to this node.' ) -def vm_list(node, limit): +@click.option( + '-r', '--raw', 'raw', is_flag=True, default=False, + help='Display the raw list of VM names.' +) +def vm_list(node, limit, raw): """ List all virtual machines in the cluster; optionally only match names matching regex LIMIT. @@ -588,7 +592,7 @@ def vm_list(node, limit): """ zk_conn = pvc_common.startZKConnection(zk_host) - retcode, retmsg = pvc_vm.get_list(zk_conn, node, limit) + retcode, retmsg = pvc_vm.get_list(zk_conn, node, limit, raw) cleanup(retcode, retmsg, zk_conn) ############################################################################### diff --git a/client-common/vm.py b/client-common/vm.py index 6bb21220..6bb29298 100644 --- a/client-common/vm.py +++ b/client-common/vm.py @@ -496,7 +496,7 @@ def get_info(zk_conn, domain, long_output): return True, '' -def get_list(zk_conn, node, limit): +def get_list(zk_conn, node, limit, raw): if node != None: # Verify node is valid common.verifyNode(zk_conn, node) @@ -552,6 +552,10 @@ def get_list(zk_conn, node, limit): if vm_node[vm] == node: vm_list.append(vm) + if raw: + click.echo('\n'.join(vm_list)) + return True, '' + # Gather information for printing for vm in vm_list: vm_state[vm] = zkhandler.readdata(zk_conn, '/domains/{}/state'.format(vm))