summaryrefslogtreecommitdiffstats
path: root/qtip
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-05-13 21:52:37 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-05-16 11:52:29 +0800
commitab72f9c49cabd945d35c946dce4158ea8e228e2a (patch)
tree12a3ea3350db4c761bd90417bff6d900cbb87a7b /qtip
parent426ad7b517f20ff8c77ed69dcd056db7d5278f18 (diff)
Implement sunburst badge for QPI
Change-Id: Iccdec7b0ac223a38c846f73adc6bd0e53db3723b Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'qtip')
-rw-r--r--qtip/ansible_library/plugins/action/aggregate.py12
-rw-r--r--qtip/ansible_library/plugins/action/calculate.py30
2 files changed, 29 insertions, 13 deletions
diff --git a/qtip/ansible_library/plugins/action/aggregate.py b/qtip/ansible_library/plugins/action/aggregate.py
index f1451e06..36ea0ef1 100644
--- a/qtip/ansible_library/plugins/action/aggregate.py
+++ b/qtip/ansible_library/plugins/action/aggregate.py
@@ -42,9 +42,15 @@ class ActionModule(ActionBase):
# aggregate QPI results
@export_to_file
def aggregate(hosts, basepath, src):
- host_results = [{'host': host, 'result': json.load(open(os.path.join(basepath, host, src)))} for host in hosts]
- score = int(mean([r['result']['score'] for r in host_results]))
+ host_results = []
+ for host in hosts:
+ host_result = json.load(open(os.path.join(basepath, host, src)))
+ host_result['name'] = host
+ host_results.append(host_result)
+ score = int(mean([r['score'] for r in host_results]))
return {
'score': score,
- 'host_results': host_results
+ 'name': 'compute',
+ 'description': 'POD Compute QPI',
+ 'children': host_results
}
diff --git a/qtip/ansible_library/plugins/action/calculate.py b/qtip/ansible_library/plugins/action/calculate.py
index 8d5fa1f7..d50222fe 100644
--- a/qtip/ansible_library/plugins/action/calculate.py
+++ b/qtip/ansible_library/plugins/action/calculate.py
@@ -55,18 +55,22 @@ def calc_qpi(qpi_spec, metrics):
display.vvv("spec: {}".format(qpi_spec))
display.vvv("metrics: {}".format(metrics))
- section_results = [{'name': s['name'], 'result': calc_section(s, metrics)}
+ section_results = [calc_section(s, metrics)
for s in qpi_spec['sections']]
# TODO(yujunz): use formula in spec
standard_score = 2048
- qpi_score = int(mean([r['result']['score'] for r in section_results]) * standard_score)
+ qpi_score = int(mean([r['score'] for r in section_results]) * standard_score)
results = {
- 'spec': qpi_spec,
'score': qpi_score,
- 'section_results': section_results,
- 'metrics': metrics
+ 'name': qpi_spec['name'],
+ 'description': qpi_spec['description'],
+ 'children': section_results,
+ 'details': {
+ 'metrics': metrics,
+ 'spec': qpi_spec
+ }
}
return results
@@ -78,13 +82,15 @@ def calc_section(section_spec, metrics):
display.vvv("spec: {}".format(section_spec))
display.vvv("metrics: {}".format(metrics))
- metric_results = [{'name': m['name'], 'result': calc_metric(m, metrics[m['name']])}
+ metric_results = [calc_metric(m, metrics[m['name']])
for m in section_spec['metrics']]
# TODO(yujunz): use formula in spec
- section_score = mean([r['result']['score'] for r in metric_results])
+ section_score = mean([r['score'] for r in metric_results])
return {
'score': section_score,
- 'metric_results': metric_results
+ 'name': section_spec['name'],
+ 'description': section_spec.get('description', 'section'),
+ 'children': metric_results
}
@@ -95,12 +101,16 @@ def calc_metric(metric_spec, metrics):
display.vvv("metrics: {}".format(metrics))
# TODO(yujunz): use formula in spec
- workload_results = [{'name': w['name'], 'score': calc_score(metrics[w['name']], w['baseline'])}
+ workload_results = [{'name': w['name'],
+ 'description': 'workload',
+ 'score': calc_score(metrics[w['name']], w['baseline'])}
for w in metric_spec['workloads']]
metric_score = mean([r['score'] for r in workload_results])
return {
'score': metric_score,
- 'workload_results': workload_results
+ 'name': metric_spec['name'],
+ 'description': metric_spec.get('description', 'metric'),
+ 'children': workload_results
}