From d2451a0232c9316b6d8d53c6b362fa6a840ff1e1 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Wed, 19 Jul 2017 10:19:13 +0000 Subject: Add API(v2) to add case to task JIRA: YARDSTICK-739 API: /api/v2/yardstick/tasks/ METHOD: PUT PARAMS: { 'action': 'add_case', 'args': { 'case_name': 'opnfv_yardstick_tc002', 'case_content': case_content } } Change-Id: I53e71e3d662399b08029ed417b5873a4775ca32d Signed-off-by: chenjiankun --- api/resources/v2/tasks.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'api') 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}) -- cgit 1.2.3-korg