@ -82,7 +82,7 @@ def node_info(config, node):
|
||||
else:
|
||||
return False, response.json()['message']
|
||||
|
||||
def node_list(config, limit):
|
||||
def node_list(config, limit, target_daemon_state, target_coordinator_state, target_domain_state):
|
||||
"""
|
||||
Get list information about nodes (limited by {limit})
|
||||
|
||||
@ -93,6 +93,12 @@ def node_list(config, limit):
|
||||
params = dict()
|
||||
if limit:
|
||||
params['limit'] = limit
|
||||
if target_daemon_state:
|
||||
params['daemon_state'] = target_daemon_state
|
||||
if target_coordinator_state:
|
||||
params['coordinator_state'] = target_coordinator_state
|
||||
if target_domain_state:
|
||||
params['domain_state'] = target_domain_state
|
||||
|
||||
response = call_api(config, 'get', '/node', params=params)
|
||||
|
||||
@ -161,11 +167,17 @@ def format_info(node_information, long_output):
|
||||
ainformation.append('')
|
||||
return '\n'.join(ainformation)
|
||||
|
||||
def format_list(node_list):
|
||||
def format_list(node_list, raw):
|
||||
# Handle single-element lists
|
||||
if not isinstance(node_list, list):
|
||||
node_list = [ node_list ]
|
||||
|
||||
if raw:
|
||||
ainformation = list()
|
||||
for node in sorted(item['name'] for item in node_list):
|
||||
ainformation.append(node)
|
||||
return '\n'.join(ainformation)
|
||||
|
||||
node_list_output = []
|
||||
|
||||
# Determine optimal column widths
|
||||
|
@ -525,15 +525,31 @@ def node_info(node, long_output):
|
||||
@click.argument(
|
||||
'limit', default=None, required=False
|
||||
)
|
||||
@click.option(
|
||||
'-ds', '--daemon-state', 'target_daemon_state', default=None,
|
||||
help='Limit list to nodes in the specified daemon state.'
|
||||
)
|
||||
@click.option(
|
||||
'-cs', '--coordinator-state', 'target_coordinator_state', default=None,
|
||||
help='Limit list to nodes in the specified coordinator state.'
|
||||
)
|
||||
@click.option(
|
||||
'-vs', '--domain-state', 'target_domain_state', default=None,
|
||||
help='Limit list to nodes in the specified domain state.'
|
||||
)
|
||||
@click.option(
|
||||
'-r', '--raw', 'raw', is_flag=True, default=False,
|
||||
help='Display the raw list of node names only.'
|
||||
)
|
||||
@cluster_req
|
||||
def node_list(limit):
|
||||
def node_list(limit, target_daemon_state, target_coordinator_state, target_domain_state, raw):
|
||||
"""
|
||||
List all nodes; optionally only match names matching regex LIMIT.
|
||||
"""
|
||||
|
||||
retcode, retdata = pvc_node.node_list(config, limit)
|
||||
retcode, retdata = pvc_node.node_list(config, limit, target_daemon_state, target_coordinator_state, target_domain_state)
|
||||
if retcode:
|
||||
retdata = pvc_node.format_list(retdata)
|
||||
retdata = pvc_node.format_list(retdata, raw)
|
||||
cleanup(retcode, retdata)
|
||||
|
||||
###############################################################################
|
||||
|
Reference in New Issue
Block a user