From 869d5fdb0b7a6070a78b4ec21d6b6c1cba14da6c Mon Sep 17 00:00:00 2001
From: chenjiankun <chenjiankun1@huawei.com>
Date: Fri, 21 Jul 2017 03:18:02 +0000
Subject: Add API(v2) to get all task info

JIRA: YARDSTICK-754

API: /api/v2/yardstick/tasks
METHOD: GET

Change-Id: I556b0880674d78d67e0a556c4d95f902131cd027
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
---
 api/resources/v2/tasks.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'api/resources/v2')

diff --git a/api/resources/v2/tasks.py b/api/resources/v2/tasks.py
index 0eb95773a..9790d7640 100644
--- a/api/resources/v2/tasks.py
+++ b/api/resources/v2/tasks.py
@@ -21,6 +21,16 @@ LOG.setLevel(logging.DEBUG)
 
 class V2Tasks(ApiResource):
 
+    def get(self):
+        task_handler = V2TaskHandler()
+        tasks = [change_obj_to_dict(t) for t in task_handler.list_all()]
+
+        for t in tasks:
+            result = t['result']
+            t['result'] = jsonutils.loads(result) if result else None
+
+        return result_handler(consts.API_SUCCESS, {'tasks': tasks})
+
     def post(self):
         return self._dispatch_post()
 
-- 
cgit