From d5a120f490ffaed78bf2c5608749ef44053df055 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 22 Oct 2019 12:24:47 -0400 Subject: [PATCH] Add colour to the health status output --- client-common/cluster.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client-common/cluster.py b/client-common/cluster.py index 5fd13b09..7ec3feec 100644 --- a/client-common/cluster.py +++ b/client-common/cluster.py @@ -176,10 +176,15 @@ def format_info(cluster_information, oformat): return # Plain formatting, i.e. human-readable + if cluster_information['health'] == 'Optimal': + health_colour = ansiprint.green() + else: + health_colour = ansiprint.yellow() + ainformation = [] ainformation.append('{}PVC cluster status:{}'.format(ansiprint.bold(), ansiprint.end())) ainformation.append('') - ainformation.append('{}Cluster health:{} {}'.format(ansiprint.purple(), ansiprint.end(), cluster_information['health'])) + ainformation.append('{}Cluster health:{} {}{}{}'.format(ansiprint.purple(), ansiprint.end(), health_colour, cluster_information['health'], ansiprint.end())) 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'])) ainformation.append('')