summaryrefslogtreecommitdiffstats
path: root/func/driver.py
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-09-03 16:30:42 +0800
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-09-04 08:10:13 +0800
commitcf0b4338abd0dc4f8a835440db7c662a37e92911 (patch)
tree982e82820dd437d8ae6a2f99b5cf1084eb185d37 /func/driver.py
parent222ebcd6c81c46420d861733b26068cb59fcebdc (diff)
Call ansible playbook by ansible api instead of os.system
JIRA:QTIP-99 Change-Id: Ife53a48d4af1fd3c60efc0673611321b3bc487a7 Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
Diffstat (limited to 'func/driver.py')
-rw-r--r--func/driver.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/func/driver.py b/func/driver.py
index 63a9c369..4ce402a4 100644
--- a/func/driver.py
+++ b/func/driver.py
@@ -7,8 +7,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import os
-import json
import logging
+from func.ansible_api import AnsibleApi
class Driver:
@@ -54,12 +54,12 @@ class Driver:
return special_json
def run_ansible_playbook(self, benchmark, extra_vars):
- extra_vars_json = json.dumps(dict(extra_vars.items()))
- logging.info(extra_vars_json)
- run_play = 'ansible-playbook ./benchmarks/playbooks/{0}.yaml' \
- ' --private-key=./data/QtipKey -i ./data/hosts --extra-vars \'{1}\'' \
- .format(benchmark, extra_vars_json)
- os.system(run_play)
+ logging.info(extra_vars)
+ ansible_api = AnsibleApi()
+ ansible_api.execute_playbook('./data/hosts',
+ './benchmarks/playbooks/{0}.yaml'.format(benchmark),
+ './data/QtipKey', extra_vars)
+ return ansible_api.get_detail_playbook_stats()
def drive_bench(self, benchmark, roles, benchmark_fname,
benchmark_detail=None, pip_dict=None, proxy_info=None):