summaryrefslogtreecommitdiffstats
path: root/func/driver.py
diff options
context:
space:
mode:
Diffstat (limited to 'func/driver.py')
-rw-r--r--func/driver.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/func/driver.py b/func/driver.py
index 45ec3fa2..83e64a80 100644
--- a/func/driver.py
+++ b/func/driver.py
@@ -10,20 +10,41 @@
import os
-
+import json
+from collections import defaultdict
class Driver:
def __init__(self):
+
print "Class driver initialized\n"
+ self.dic_json = defaultdict()
- def drive_bench(self, benchmark, roles):
- result_dir = '$PWD/results'
+ def drive_bench(self, benchmark, roles, benchmark_detail= None, pip_dict = None):
+ roles= sorted(roles)
+ pip_dict = sorted(pip_dict)
+ result_dir = 'results'
benchmark_name = benchmark + '.yaml'
- print roles
+ self.dic_json['Dest_dir'] = str(result_dir)
+ self.dic_json['ip1']=''
+ self.dic_json['ip2']=''
+
+ for k,v in benchmark_detail:
+ self.dic_json[k]=v
for k, v in roles:
- print k
- run_play = 'ansible-playbook -s $PWD/benchmarks/playbooks/{0} --extra-vars "Dest_dir={1} role={2}" -vvv'.format(
- benchmark_name, result_dir, k)
-
+ self.dic_json['role']=k
+ index=1
+ if benchmark_detail != None:
+ for values in v:
+ if k == '1-server':
+ print values, 'saving IP'
+ self.dic_json['ip'+str(index)]= str(values)
+ self.dic_json['privateip'+str(index)] = pip_dict[0][1]
+ index= index+1
+ dic_json = json.dumps(dict(self.dic_json.items()))
+ print dic_json
+ run_play = 'ansible-playbook -s ./benchmarks/playbooks/{0} --extra-vars \'{1}\' -vvv'.format(benchmark_name, dic_json)
+# run_play = 'ansible-playbook -s $PWD/benchmarks/playbooks/{0} --extra-vars "Dest_dir={1} role={2}" -vvv'.format(
+# benchmark_name, result_dir, k)
status = os.system(run_play)
+