diff options
author | zhihui wu <wu.zhihui1@zte.com.cn> | 2017-06-02 16:07:24 +0800 |
---|---|---|
committer | zhihui wu <wu.zhihui1@zte.com.cn> | 2017-06-06 16:05:36 +0800 |
commit | 26c2a8f2d556a8777d443b02d931e7df7fec8f6c (patch) | |
tree | d93397cd1e3f01a1bbaa5d6b91c4140ec1a6f974 /qtip/ansible_library | |
parent | 995656837a0950ccadab7d2b87eded85072ba70e (diff) |
add system_info and condition to qpi report
According to the part "system_info" and "condition" in spec, gather
these data and add them to qpi report.
Change-Id: I5efc996c2bfb34452e9aa323d8288c1dd2d8d276
Signed-off-by: zhihui wu <wu.zhihui1@zte.com.cn>
Diffstat (limited to 'qtip/ansible_library')
-rw-r--r-- | qtip/ansible_library/plugins/action/calculate.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/qtip/ansible_library/plugins/action/calculate.py b/qtip/ansible_library/plugins/action/calculate.py index 383be580..0c3ab7db 100644 --- a/qtip/ansible_library/plugins/action/calculate.py +++ b/qtip/ansible_library/plugins/action/calculate.py @@ -43,21 +43,26 @@ class ActionModule(ActionBase): for metric, filename in metrics_files.items(): with open(filename) as f: metrics[metric] = json.load(f) + + with open(self._task.args.get('sysinfo')) as f: + data = json.load(f) + sysinfo = dict([(k['name'], data[k['name']][0]) for k in spec['system_info']]) + dest = self._task.args.get('dest') baseline_file = self._task.args.get('baseline') if baseline_file is not None: with open(baseline_file) as f: baseline = json.load(f) - return calc_qpi(spec, metrics, baseline, dest=dest) + return calc_qpi(spec, metrics, baseline, sysinfo, dest=dest) else: - return save_as_baseline(spec, metrics, dest=dest) + return save_as_baseline(spec, metrics, sysinfo, dest=dest) # TODO(wuzhihui): It is more reasonable to put this function into collect.py. # For now metrics data is not easy to be collected from collect.py. @export_to_file -def save_as_baseline(qpi_spec, metrics): +def save_as_baseline(qpi_spec, metrics, sysinfo): display.vv("save {} metrics as baseline".format(qpi_spec['name'])) display.vvv("spec: {}".format(qpi_spec)) display.vvv("metrics: {}".format(metrics)) @@ -66,6 +71,7 @@ def save_as_baseline(qpi_spec, metrics): 'name': qpi_spec['name'], 'score': 2048, 'description': qpi_spec['description'], + 'system_info': sysinfo, 'details': { 'metrics': metrics, 'spec': "https://git.opnfv.org/qtip/tree/resources/QPI/compute.yaml", @@ -75,7 +81,7 @@ def save_as_baseline(qpi_spec, metrics): @export_to_file -def calc_qpi(qpi_spec, metrics, qpi_baseline): +def calc_qpi(qpi_spec, metrics, qpi_baseline, sysinfo): display.vv("calculate QPI {}".format(qpi_spec['name'])) display.vvv("spec: {}".format(qpi_spec)) display.vvv("metrics: {}".format(metrics)) @@ -95,6 +101,7 @@ def calc_qpi(qpi_spec, metrics, qpi_baseline): 'score': qpi_score, 'name': qpi_spec['name'], 'description': qpi_spec['description'], + 'system_info': sysinfo, 'children': section_results, 'details': { 'metrics': metrics, @@ -146,6 +153,7 @@ def calc_metric(metric_spec, metrics, metric_basline): }) metric_score = mean([r['score'] for r in workload_results]) + return { 'score': metric_score, 'name': metric_spec['name'], |