Use same fault formatting for short and long

This commit is contained in:
Joshua Boniface 2023-12-06 15:35:35 -05:00
parent 1416f9edc0
commit 0945b3faf3
1 changed files with 24 additions and 4 deletions

View File

@ -136,7 +136,7 @@ def cli_cluster_status_format_pretty(CLI_CONFIG, data):
) )
messages = "\n ".join(message_list) messages = "\n ".join(message_list)
output.append(f"{ansii['purple']}New Faults:{ansii['end']} {messages}") output.append(f"{ansii['purple']}Active Faults:{ansii['end']} {messages}")
output.append("") output.append("")
@ -270,12 +270,32 @@ def cli_cluster_status_format_short(CLI_CONFIG, data):
health = f"{health} (maintenance on)" health = f"{health} (maintenance on)"
output.append( output.append(
f"{ansii['purple']}Health:{ansii['end']} {health_colour}{health}{ansii['end']}" f"{ansii['purple']}Health:{ansii['end']} {health_colour}{health}{ansii['end']}"
) )
if messages is not None and len(messages) > 0: if messages is not None and len(messages) > 0:
messages = "\n ".join(messages["text"]) message_list = list()
output.append(f"{ansii['purple']}Faults:{ansii['end']} {messages}") for message in messages:
if message["health_delta"] >= 50:
message_colour = ansii["red"]
elif message["health_delta"] >= 10:
message_colour = ansii["yellow"]
else:
message_colour = ansii["green"]
message_delta = (
f"({message_colour}-{message['health_delta']}%{ansii['end']})"
)
message_list.append(
# 15 length due to ANSI colour sequences
"{id} {delta:<15} {text}".format(
id=message["id"],
delta=message_delta,
text=message["text"],
)
)
messages = "\n ".join(message_list)
output.append(f"{ansii['purple']}Active Faults:{ansii['end']} {messages}")
output.append("") output.append("")