Add API(v2) to get pod info 57/37457/2
authorchenjiankun <chenjiankun1@huawei.com>
Fri, 14 Jul 2017 03:39:06 +0000 (03:39 +0000)
committerchenjiankun <chenjiankun1@huawei.com>
Fri, 14 Jul 2017 06:26:46 +0000 (06:26 +0000)
JIRA: YARDSTICK-724

API: /api/v2/yardstick/pods/<pod_id>
METHOD: GET

Change-Id: I49608eab1f1625cd4358732da052ce3745e28c24
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
api/resources/v2/pods.py
api/urls.py

index f5cdc3b..ffb8a60 100644 (file)
@@ -58,3 +58,22 @@ class V2Pods(ApiResource):
         environment_handler.update_attr(environment_id, {'pod_id': pod_id})
 
         return result_handler(consts.API_SUCCESS, {'uuid': pod_id, 'pod': data})
+
+
+class V2Pod(ApiResource):
+
+    def get(self, pod_id):
+        try:
+            uuid.UUID(pod_id)
+        except ValueError:
+            return result_handler(consts.API_ERROR, 'invalid pod id')
+
+        pod_handler = V2PodHandler()
+        try:
+            pod = pod_handler.get_by_uuid(pod_id)
+        except ValueError:
+            return result_handler(consts.API_ERROR, 'no such pod')
+
+        content = jsonutils.loads(pod.content)
+
+        return result_handler(consts.API_SUCCESS, {'pod': content})
index be453a6..82df175 100644 (file)
@@ -30,4 +30,5 @@ urlpatterns = [
     Url('/api/v2/yardstick/environments/openrcs/<openrc_id>', 'v2_openrc'),
 
     Url('/api/v2/yardstick/pods/action', 'v2_pods'),
+    Url('/api/v2/yardstick/pods/<pod_id>', 'v2_pod'),
 ]