summaryrefslogtreecommitdiffstats
path: root/api/resources/v2/tasks.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2018-03-08 12:18:27 +0000
committerchenjiankun <chenjiankun1@huawei.com>2018-03-08 12:18:27 +0000
commit1d2acc900a695bee5c1d83d7631725e4d8b18df0 (patch)
tree249fcd77d191eaca713d7dc5f3c309e8322c6546 /api/resources/v2/tasks.py
parent58dd0e8514518e4c266713c1d54ba735b400a5d8 (diff)
Supporting user config task parameters in GUI
JIRA: YARDSTICK-981 We need to add function to enable user to config task parameters in GUI. The way to config must be more friendly. Change-Id: I8746149084f1d554b48ed392f2fef4748e279dfb Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/resources/v2/tasks.py')
-rw-r--r--api/resources/v2/tasks.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/api/resources/v2/tasks.py b/api/resources/v2/tasks.py
index 25a9cf109..17241ed63 100644
--- a/api/resources/v2/tasks.py
+++ b/api/resources/v2/tasks.py
@@ -38,6 +38,8 @@ class V2Tasks(ApiResource):
for t in tasks:
result = t['result']
t['result'] = jsonutils.loads(result) if result else None
+ params = t['params']
+ t['params'] = jsonutils.loads(params) if params else None
return result_handler(consts.API_SUCCESS, {'tasks': tasks})
@@ -94,6 +96,9 @@ class V2Task(ApiResource):
result = task_info['result']
task_info['result'] = jsonutils.loads(result) if result else None
+ params = task_info['params']
+ task_info['params'] = jsonutils.loads(params) if params else None
+
return result_handler(consts.API_SUCCESS, {'task': task_info})
def delete(self, task_id):
@@ -127,7 +132,6 @@ class V2Task(ApiResource):
return result_handler(consts.API_SUCCESS, {'task': task_id})
def put(self, task_id):
-
try:
uuid.UUID(task_id)
except ValueError:
@@ -166,6 +170,21 @@ class V2Task(ApiResource):
return result_handler(consts.API_SUCCESS, {'uuid': task_id})
+ def add_params(self, args):
+ task_id = args['task_id']
+ try:
+ params = args['params']
+ except KeyError:
+ return result_handler(consts.API_ERROR, 'params must be provided')
+
+ LOG.info('update params info in task')
+
+ task_handler = V2TaskHandler()
+ task_update_data = {'params': jsonutils.dumps(params)}
+ task_handler.update_attr(task_id, task_update_data)
+
+ return result_handler(consts.API_SUCCESS, {'uuid': task_id})
+
def add_case(self, args):
task_id = args['task_id']
try:
@@ -243,7 +262,8 @@ class V2Task(ApiResource):
data = {
'inputfile': ['/tmp/{}.yaml'.format(task.case_name)],
- 'task_id': task_id
+ 'task_id': task_id,
+ 'task-args': task.params
}
if task.suite:
data.update({'suite': True})