From fd717b702dd2028e0df3c31a2d4b00b1a4b725b9 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 9 Dec 2023 12:51:41 -0500 Subject: [PATCH] Use external list of fault states --- api-daemon/pvcapid/helper.py | 7 +++---- daemon-common/common.py | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api-daemon/pvcapid/helper.py b/api-daemon/pvcapid/helper.py index ad5ae095..4ff2fa74 100755 --- a/api-daemon/pvcapid/helper.py +++ b/api-daemon/pvcapid/helper.py @@ -161,10 +161,9 @@ def cluster_metrics(zkhandler): output_lines.append("# HELP pvc_cluster_faults PVC cluster new faults") output_lines.append("# TYPE pvc_cluster_faults gauge") - fault_map = { - "new": 0, - "ack": 0, - } + fault_map = dict() + for fault_type in pvc_common.fault_state_combinations: + fault_map[fault_type] = 0 for fault in faults_data: fault_map[fault["status"]] += 1 for fault_type in fault_map: diff --git a/daemon-common/common.py b/daemon-common/common.py index 2b440ea4..1119d8dd 100644 --- a/daemon-common/common.py +++ b/daemon-common/common.py @@ -40,6 +40,10 @@ from functools import wraps # State lists +fault_state_combinations = [ + "new", + "ack", +] node_state_combinations = [ "run,ready", "run,flush",