summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2016-07-12 07:56:08 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-07-12 07:56:08 +0000
commit01c843df1684678072988283b3789e11a34b7499 (patch)
treea8101ef304c52a9fae93f6de362de53d068caa0a /func
parent3a4f1304b228c559536f7c0d7fa052d7e61b6a56 (diff)
parent01a9660cc42d9f5b03ca3049e0ba69e357508332 (diff)
Merge "Add some UT test cases and fix pep8 errors for driver"
Diffstat (limited to 'func')
-rw-r--r--func/driver.py38
1 files changed, 18 insertions, 20 deletions
diff --git a/func/driver.py b/func/driver.py
index 48c09c5d..33dbe320 100644
--- a/func/driver.py
+++ b/func/driver.py
@@ -6,13 +6,11 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-
-
import os
import json
from collections import defaultdict
+
class Driver:
def __init__(self):
@@ -21,8 +19,8 @@ class Driver:
print os.environ['PWD']
self.dic_json = defaultdict()
- def drive_bench(self, benchmark, roles, benchmark_fname, benchmark_detail = None, pip_dict = None, proxy_info = None):
- roles= sorted(roles)
+ def drive_bench(self, benchmark, roles, benchmark_fname, benchmark_detail=None, pip_dict=None, proxy_info=None):
+ roles = sorted(roles)
pip_dict = sorted(pip_dict)
result_dir = 'results'
benchmark_name = benchmark + '.yaml'
@@ -33,30 +31,30 @@ class Driver:
self.dic_json['workingdir'] = str(os.environ['PWD'])
self.dic_json['fname'] = str(benchmark_fname)
self.dic_json['username'] = str('root')
-
+
for key in proxy_info.keys():
self.dic_json[key] = proxy_info[key]
-
+
if os.environ['INSTALLER_TYPE'] == str('joid'):
- self.dic_json['username']=str('ubuntu')
+ self.dic_json['username'] = str('ubuntu')
if os.environ['INSTALLER_TYPE'] == str('apex'):
- self.dic_json['username']=str('heat-admin')
- for k,v in benchmark_detail:
- self.dic_json[k]=v
+ self.dic_json['username'] = str('heat-admin')
+ for k, v in benchmark_detail:
+ self.dic_json[k] = v
for k, v in roles:
- self.dic_json['role']=k
- index=1
- if benchmark_detail != None:
+ self.dic_json['role'] = k
+ index = 1
+ if benchmark_detail is not None:
for values in v:
- if k == '1-server':
+ if k == '1-server':
print values, 'saving IP'
- self.dic_json['ip'+str(index)]= str(values)
+ self.dic_json['ip' + str(index)] = str(values)
if pip_dict[0][1][0]:
- self.dic_json['privateip'+str(index)] = pip_dict[0][1]
+ self.dic_json['privateip' + str(index)] = pip_dict[0][1]
if not pip_dict[0][1][0]:
- self.dic_json['privateip'+str(index)] = 'NONE'
- index= index+1
+ self.dic_json['privateip' + str(index)] = 'NONE'
+ index = index + 1
dic_json = json.dumps(dict(self.dic_json.items()))
print dic_json
run_play = 'ansible-playbook ./benchmarks/playbooks/{0} --private-key=./data/QtipKey -i ./data/hosts --extra-vars \'{1}\''.format(benchmark_name, dic_json)
- status = os.system(run_play)
+ os.system(run_play)