summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-07-19 10:19:13 +0000
committerJack Chan <chenjiankun1@huawei.com>2017-07-20 01:48:52 +0000
commitd2451a0232c9316b6d8d53c6b362fa6a840ff1e1 (patch)
treee9efb96a05d6c6a1da6eb85ebeedee8516e4c3c1 /api
parenta0b4e917f6f86945341825fe630ba532061992fa (diff)
Add API(v2) to add case to task
JIRA: YARDSTICK-739 API: /api/v2/yardstick/tasks/<task_id> METHOD: PUT PARAMS: { 'action': 'add_case', 'args': { 'case_name': 'opnfv_yardstick_tc002', 'case_content': case_content } } Change-Id: I53e71e3d662399b08029ed417b5873a4775ca32d Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api')
-rw-r--r--api/resources/v2/tasks.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/api/resources/v2/tasks.py b/api/resources/v2/tasks.py
index 2c4ff2c00..26da6715e 100644
--- a/api/resources/v2/tasks.py
+++ b/api/resources/v2/tasks.py
@@ -141,3 +141,26 @@ class V2Task(ApiResource):
task_handler.update_attr(task_id, {'environment_id': environment_id})
return result_handler(consts.API_SUCCESS, {'uuid': task_id})
+
+ def add_case(self, args):
+ task_id = args['task_id']
+ try:
+ name = args['case_name']
+ except KeyError:
+ return result_handler(consts.API_ERROR, 'case_name must be provided')
+
+ try:
+ content = args['case_content']
+ except KeyError:
+ return result_handler(consts.API_ERROR, 'case_content must be provided')
+
+ LOG.info('update case info in task')
+ task_handler = V2TaskHandler()
+ task_update_data = {
+ 'case_name': name,
+ 'content': content,
+ 'suite': False
+ }
+ task_handler.update_attr(task_id, task_update_data)
+
+ return result_handler(consts.API_SUCCESS, {'uuid': task_id})