Fix status when connecting to old clusters
This commit is contained in:
parent
a49f3810d3
commit
93d89a2414
|
@ -125,11 +125,11 @@ def format_info(cluster_information, oformat):
|
||||||
return json.dumps(cluster_information, indent=4)
|
return json.dumps(cluster_information, indent=4)
|
||||||
|
|
||||||
# Plain formatting, i.e. human-readable
|
# Plain formatting, i.e. human-readable
|
||||||
if cluster_information["maintenance"] == "true":
|
if cluster_information.get("maintenance") == "true":
|
||||||
health_colour = ansiprint.blue()
|
health_colour = ansiprint.blue()
|
||||||
elif cluster_information["cluster_health"]["health"] > 90:
|
elif cluster_information.get("cluster_health", {}).get("health", 100) > 90:
|
||||||
health_colour = ansiprint.green()
|
health_colour = ansiprint.green()
|
||||||
elif cluster_information["cluster_health"]["health"] > 50:
|
elif cluster_information.get("cluster_health", {}).get("health", 100) > 50:
|
||||||
health_colour = ansiprint.yellow()
|
health_colour = ansiprint.yellow()
|
||||||
else:
|
else:
|
||||||
health_colour = ansiprint.red()
|
health_colour = ansiprint.red()
|
||||||
|
@ -142,7 +142,7 @@ def format_info(cluster_information, oformat):
|
||||||
ainformation.append("")
|
ainformation.append("")
|
||||||
|
|
||||||
health_text = f"{cluster_information['cluster_health']['health']}%"
|
health_text = f"{cluster_information['cluster_health']['health']}%"
|
||||||
if cluster_information["maintenance"] == "true":
|
if cluster_information.get("maintenance") == "true":
|
||||||
health_text += " (maintenance on)"
|
health_text += " (maintenance on)"
|
||||||
|
|
||||||
ainformation.append(
|
ainformation.append(
|
||||||
|
@ -154,7 +154,7 @@ def format_info(cluster_information, oformat):
|
||||||
ansiprint.end(),
|
ansiprint.end(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if cluster_information["cluster_health"]["messages"]:
|
if cluster_information.get("cluster_health", {}).get("messages"):
|
||||||
health_messages = "\n > ".join(
|
health_messages = "\n > ".join(
|
||||||
sorted(cluster_information["cluster_health"]["messages"])
|
sorted(cluster_information["cluster_health"]["messages"])
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue