aboutsummaryrefslogtreecommitdiffstats
path: root/func/driver.py
diff options
context:
space:
mode:
Diffstat (limited to 'func/driver.py')
-rw-r--r--func/driver.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/func/driver.py b/func/driver.py
index ff40a4cc..88d673fa 100644
--- a/func/driver.py
+++ b/func/driver.py
@@ -7,8 +7,10 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
from utils import logger_utils
+from operator import add
from ansible_api import AnsibleApi
+
logger = logger_utils.QtipLogger('driver').get
@@ -65,7 +67,7 @@ class Driver:
ansible_api.execute_playbook('./data/hosts',
'./benchmarks/playbooks/{0}.yaml'.format(benchmark),
'./data/QtipKey', extra_vars)
- return ansible_api.get_detail_playbook_stats()
+ return self.get_ansible_result(extra_vars['role'], ansible_api.get_detail_playbook_stats())
def drive_bench(self, installer_type, pwd, benchmark, roles, benchmark_fname,
benchmark_detail=None, pip_dict=None, proxy_info=None):
@@ -73,8 +75,18 @@ class Driver:
pip_dict = sorted(pip_dict)
var_json = self.get_common_var_json(installer_type, pwd, benchmark_fname,
benchmark_detail, pip_dict, proxy_info)
- map(lambda role: self.run_ansible_playbook
- (benchmark, self.merge_two_dicts(var_json,
- self.get_special_var_json(role, roles,
- benchmark_detail,
- pip_dict))), roles)
+ result = map(lambda role: self.run_ansible_playbook
+ (benchmark, self.merge_two_dicts(var_json,
+ self.get_special_var_json(role, roles,
+ benchmark_detail,
+ pip_dict))), roles)
+ return reduce(self._merge_ansible_result, result)
+
+ def get_ansible_result(self, role, stats):
+ result = reduce(add, map(lambda x: x[1]['failures'] + x[1]['unreachable'], stats))
+ return {'result': result,
+ 'detail': {role: stats}}
+
+ def _merge_ansible_result(self, result_1, result_2):
+ return {'result': result_1['result'] + result_2['result'],
+ 'detail': self.merge_two_dicts(result_1['detail'], result_2['detail'])}