Add short pretty health output
This commit is contained in:
parent
9a36fedcab
commit
7c520ec00c
|
@ -104,6 +104,20 @@ def format_info(cluster_information, oformat):
|
|||
storage_health_colour = ansiprint.yellow()
|
||||
|
||||
ainformation = []
|
||||
|
||||
if oformat == 'short':
|
||||
ainformation.append('{}PVC cluster status:{}'.format(ansiprint.bold(), ansiprint.end()))
|
||||
ainformation.append('{}Cluster health:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), health_colour, cluster_information['health'], ansiprint.end()))
|
||||
if cluster_information['health_msg']:
|
||||
for line in cluster_information['health_msg']:
|
||||
ainformation.append(' > {}'.format(line))
|
||||
ainformation.append('{}Storage health:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), storage_health_colour, cluster_information['storage_health'], ansiprint.end()))
|
||||
if cluster_information['storage_health_msg']:
|
||||
for line in cluster_information['storage_health_msg']:
|
||||
ainformation.append(' > {}'.format(line))
|
||||
|
||||
return '\n'.join(ainformation)
|
||||
|
||||
ainformation.append('{}PVC cluster status:{}'.format(ansiprint.bold(), ansiprint.end()))
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Cluster health:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), health_colour, cluster_information['health'], ansiprint.end()))
|
||||
|
@ -114,6 +128,7 @@ def format_info(cluster_information, oformat):
|
|||
if cluster_information['storage_health_msg']:
|
||||
for line in cluster_information['storage_health_msg']:
|
||||
ainformation.append(' > {}'.format(line))
|
||||
|
||||
ainformation.append('')
|
||||
ainformation.append('{}Primary node:{} {}'.format(ansiprint.purple(), ansiprint.end(), cluster_information['primary_node']))
|
||||
ainformation.append('{}Cluster upstream IP:{} {}'.format(ansiprint.purple(), ansiprint.end(), cluster_information['upstream_ip']))
|
||||
|
|
|
@ -4057,13 +4057,19 @@ def maintenance_off():
|
|||
@click.command(name='status', short_help='Show current cluster status.')
|
||||
@click.option(
|
||||
'-f', '--format', 'oformat', default='plain', show_default=True,
|
||||
type=click.Choice(['plain', 'json', 'json-pretty']),
|
||||
type=click.Choice(['plain', 'short', 'json', 'json-pretty']),
|
||||
help='Output format of cluster status information.'
|
||||
)
|
||||
@cluster_req
|
||||
def status_cluster(oformat):
|
||||
"""
|
||||
Show basic information and health for the active PVC cluster.
|
||||
|
||||
Output formats:
|
||||
plain: Full text, full colour output for human-readability.
|
||||
short: Health-only, full colour output for human-readability.
|
||||
json: Compact JSON representation for machine parsing.
|
||||
json-pretty: Pretty-printed JSON representation for machine parsing or human-readability.
|
||||
"""
|
||||
|
||||
retcode, retdata = pvc_cluster.get_info(config)
|
||||
|
|
Loading…
Reference in New Issue