Support raw VM listing
This commit is contained in:
parent
081d855a03
commit
c4a97f04a7
|
@ -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)
|
||||
|
||||
###############################################################################
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue