From 4b47f130f31dc7a82e3dfa842acc169cd5d05a07 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Fri, 14 Jul 2017 03:39:06 +0000 Subject: Add API(v2) to get pod info JIRA: YARDSTICK-724 API: /api/v2/yardstick/pods/ METHOD: GET Change-Id: I49608eab1f1625cd4358732da052ce3745e28c24 Signed-off-by: chenjiankun --- api/resources/v2/pods.py | 19 +++++++++++++++++++ api/urls.py | 1 + 2 files changed, 20 insertions(+) diff --git a/api/resources/v2/pods.py b/api/resources/v2/pods.py index f5cdc3b7b..ffb8a6046 100644 --- a/api/resources/v2/pods.py +++ b/api/resources/v2/pods.py @@ -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}) diff --git a/api/urls.py b/api/urls.py index be453a651..82df17541 100644 --- a/api/urls.py +++ b/api/urls.py @@ -30,4 +30,5 @@ urlpatterns = [ Url('/api/v2/yardstick/environments/openrcs/', 'v2_openrc'), Url('/api/v2/yardstick/pods/action', 'v2_pods'), + Url('/api/v2/yardstick/pods/', 'v2_pod'), ] -- cgit 1.2.3-korg