aboutsummaryrefslogtreecommitdiffstats
path: root/api/resources/v2/environments.py
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2017-07-14 03:59:18 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-14 03:59:18 +0000
commite3c5c4969edef49faf129303fca813f333dae6ef (patch)
tree1ec5c0aaca3047c280d87800a256560cd8f9bb71 /api/resources/v2/environments.py
parent6acd5d156ba25d1eed49763fb220a117a43d5ef8 (diff)
parent2b2cfebd2383e38fc375eb308c3f96ef20d75881 (diff)
Merge "Add API to get single environment info"
Diffstat (limited to 'api/resources/v2/environments.py')
-rw-r--r--api/resources/v2/environments.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/api/resources/v2/environments.py b/api/resources/v2/environments.py
index 4b27c45b8..f83c0a941 100644
--- a/api/resources/v2/environments.py
+++ b/api/resources/v2/environments.py
@@ -49,3 +49,23 @@ class V2Environments(ApiResource):
environment_handler.insert(env_init_data)
return result_handler(consts.API_SUCCESS, {'uuid': env_id})
+
+
+class V2Environment(ApiResource):
+
+ def get(self, environment_id):
+ try:
+ uuid.UUID(environment_id)
+ except ValueError:
+ return result_handler(consts.API_ERROR, 'invalid environment id')
+
+ environment_handler = V2EnvironmentHandler()
+ try:
+ environment = environment_handler.get_by_uuid(environment_id)
+ except ValueError:
+ return result_handler(consts.API_ERROR, 'no such environment id')
+
+ environment = change_obj_to_dict(environment)
+ container_id = environment['container_id']
+ environment['container_id'] = jsonutils.loads(container_id) if container_id else {}
+ return result_handler(consts.API_SUCCESS, {'environment': environment})