Use new info detail output instead of new lists
Avoids multiple additional ZK calls by using data that is now in the status detail output.
This commit is contained in:
parent
5d53a3e529
commit
44a4f0e1f7
|
@ -136,21 +136,10 @@ def cluster_metrics(zkhandler):
|
||||||
if not status_retflag:
|
if not status_retflag:
|
||||||
return "Error: Status data threw error", 400
|
return "Error: Status data threw error", 400
|
||||||
|
|
||||||
faults_retflag, faults_data = pvc_faults.get_list(zkhandler)
|
faults_data = status_data["detail"]["faults"]
|
||||||
if not faults_retflag:
|
node_data = status_data["detail"]["node"]
|
||||||
return "Error: Faults data threw error", 400
|
vm_data = status_data["detail"]["vm"]
|
||||||
|
osd_data = status_data["detail"]["osd"]
|
||||||
node_retflag, node_data = pvc_node.get_list(zkhandler)
|
|
||||||
if not node_retflag:
|
|
||||||
return "Error: Node data threw error", 400
|
|
||||||
|
|
||||||
vm_retflag, vm_data = pvc_vm.get_list(zkhandler)
|
|
||||||
if not vm_retflag:
|
|
||||||
return "Error: VM data threw error", 400
|
|
||||||
|
|
||||||
osd_retflag, osd_data = pvc_ceph.get_list_osd(zkhandler)
|
|
||||||
if not osd_retflag:
|
|
||||||
return "Error: OSD data threw error", 400
|
|
||||||
|
|
||||||
output_lines = list()
|
output_lines = list()
|
||||||
|
|
||||||
|
@ -237,7 +226,7 @@ def cluster_metrics(zkhandler):
|
||||||
for state in set([s.split(",")[0] for s in pvc_common.ceph_osd_state_combinations]):
|
for state in set([s.split(",")[0] for s in pvc_common.ceph_osd_state_combinations]):
|
||||||
osd_up_state_map[state] = 0
|
osd_up_state_map[state] = 0
|
||||||
for osd in osd_data:
|
for osd in osd_data:
|
||||||
if osd["stats"]["up"] > 0:
|
if osd["up"] == "up":
|
||||||
osd_up_state_map["up"] += 1
|
osd_up_state_map["up"] += 1
|
||||||
else:
|
else:
|
||||||
osd_up_state_map["down"] += 1
|
osd_up_state_map["down"] += 1
|
||||||
|
@ -252,7 +241,7 @@ def cluster_metrics(zkhandler):
|
||||||
for state in set([s.split(",")[1] for s in pvc_common.ceph_osd_state_combinations]):
|
for state in set([s.split(",")[1] for s in pvc_common.ceph_osd_state_combinations]):
|
||||||
osd_in_state_map[state] = 0
|
osd_in_state_map[state] = 0
|
||||||
for osd in osd_data:
|
for osd in osd_data:
|
||||||
if osd["stats"]["in"] > 0:
|
if osd["in"] == "in":
|
||||||
osd_in_state_map["in"] += 1
|
osd_in_state_map["in"] += 1
|
||||||
else:
|
else:
|
||||||
osd_in_state_map["out"] += 1
|
osd_in_state_map["out"] += 1
|
||||||
|
|
|
@ -353,8 +353,8 @@ def getClusterInformation(zkhandler):
|
||||||
# We have to load this JSON object and get our up/in states from it
|
# We have to load this JSON object and get our up/in states from it
|
||||||
osd_stats = loads(_osd_stats)
|
osd_stats = loads(_osd_stats)
|
||||||
# Get our states
|
# Get our states
|
||||||
osd_up = up_texts[osd_stats['up']]
|
osd_up = up_texts[osd_stats["up"]]
|
||||||
osd_in = in_texts[osd_stats['in']]
|
osd_in = in_texts[osd_stats["in"]]
|
||||||
osd_data.append(
|
osd_data.append(
|
||||||
{
|
{
|
||||||
"id": osd,
|
"id": osd,
|
||||||
|
@ -409,7 +409,7 @@ def getClusterInformation(zkhandler):
|
||||||
"vm": vm_data,
|
"vm": vm_data,
|
||||||
"osd": osd_data,
|
"osd": osd_data,
|
||||||
"faults": faults_data,
|
"faults": faults_data,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return cluster_information
|
return cluster_information
|
||||||
|
|
Loading…
Reference in New Issue