Fix status when connecting to old clusters

This commit is contained in:
Joshua Boniface 2023-02-23 10:16:29 -05:00
parent a49f3810d3
commit 93d89a2414
1 changed files with 5 additions and 5 deletions

View File

@ -125,11 +125,11 @@ def format_info(cluster_information, oformat):
return json.dumps(cluster_information, indent=4)
# Plain formatting, i.e. human-readable
if cluster_information["maintenance"] == "true":
if cluster_information.get("maintenance") == "true":
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()
elif cluster_information["cluster_health"]["health"] > 50:
elif cluster_information.get("cluster_health", {}).get("health", 100) > 50:
health_colour = ansiprint.yellow()
else:
health_colour = ansiprint.red()
@ -142,7 +142,7 @@ def format_info(cluster_information, oformat):
ainformation.append("")
health_text = f"{cluster_information['cluster_health']['health']}%"
if cluster_information["maintenance"] == "true":
if cluster_information.get("maintenance") == "true":
health_text += " (maintenance on)"
ainformation.append(
@ -154,7 +154,7 @@ def format_info(cluster_information, oformat):
ansiprint.end(),
)
)
if cluster_information["cluster_health"]["messages"]:
if cluster_information.get("cluster_health", {}).get("messages"):
health_messages = "\n > ".join(
sorted(cluster_information["cluster_health"]["messages"])
)