diff options
author | zhifeng.jiang <jiang.zhifeng@zte.com.cn> | 2016-09-30 00:43:40 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-09-30 00:43:40 +0000 |
commit | b64891aa2fa0ef7db659831217328f3ce9e9fab4 (patch) | |
tree | a2ee42833673eec5f8b4d040e67e9700f714f2d3 /restful_server | |
parent | 5f07d28f5a90f7e19d0eddcbe04509e4246440fa (diff) | |
parent | 0d3fb3fb9aee914b425f3f8ed9c843d6052f7ada (diff) |
Merge "Start restful server auto in docker"
Diffstat (limited to 'restful_server')
-rw-r--r-- | restful_server/db.py | 11 | ||||
-rw-r--r-- | restful_server/qtip_server.py | 10 |
2 files changed, 15 insertions, 6 deletions
diff --git a/restful_server/db.py b/restful_server/db.py index 916fc031..cf6ebfbb 100644 --- a/restful_server/db.py +++ b/restful_server/db.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## from datetime import datetime +from operator import add import uuid jobs = {} @@ -28,7 +29,8 @@ def create_job(args): 'end_time': None, 'state': 'processing', 'state_detail': [], - 'result': []} + 'result': None, + 'result_detail': []} jobs[job['job_id']] = job return job['job_id'] @@ -54,6 +56,8 @@ def get_job_info(job_id): def finish_job(job_id): jobs[job_id]['end_time'] = str(datetime.now()) jobs[job_id]['state'] = 'finished' + jobs[job_id]['result'] = reduce(add, map(lambda x: x['result'], + jobs[job_id]['result_detail'])) del threads[job_id] @@ -61,8 +65,9 @@ def update_job_state_detail(job_id, state_detail): jobs[job_id]['state_detail'] = state_detail -def update_job_result(job_id, result): - jobs[job_id]['result'] = result +def update_job_result_detail(job_id, benchmark, result): + result['benchmark'] = benchmark + jobs[job_id]['result_detail'].append(result) def is_job_timeout(job_id): diff --git a/restful_server/qtip_server.py b/restful_server/qtip_server.py index b03c8f16..734a471c 100644 --- a/restful_server/qtip_server.py +++ b/restful_server/qtip_server.py @@ -163,8 +163,12 @@ default is 'compute' if db.is_job_timeout(job_id) or stop_event.is_set(): break db.update_benmark_state_in_state_detail(job_id, benchmark, 'processing') - args_handler.prepare_and_run_benchmark(installer_type, '/home', - args_handler.get_benchmark_path(pod_name, suite_name, benchmark)) + result = args_handler.prepare_and_run_benchmark(installer_type, + '/home', + args_handler.get_benchmark_path(pod_name, + suite_name, + benchmark)) + db.update_job_result_detail(job_id, benchmark, copy(result)) db.update_benmark_state_in_state_detail(job_id, benchmark, 'finished') db.finish_job(job_id) @@ -173,4 +177,4 @@ api.add_resource(JobList, '/api/v1.0/jobs') api.add_resource(Job, '/api/v1.0/jobs/<string:id>') if __name__ == "__main__": - app.run() + app.run(host='0.0.0.0') |