summaryrefslogtreecommitdiffstats
path: root/api/resources
diff options
context:
space:
mode:
authorJing Lu <lvjing5@huawei.com>2017-07-19 08:17:25 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-19 08:17:26 +0000
commitc59b4b03550abf847959b5575ba81acf72d6fe5c (patch)
tree66644aedd282a67399f9d6a84dc1fff6b6dc82ce /api/resources
parent77ac1aa890964b40aaf12b43301d37575ae753d3 (diff)
parent616b30ebd0e6a95076f015bbe94e3071a28a6391 (diff)
Merge "Add API(v2) to delete pod"
Diffstat (limited to 'api/resources')
-rw-r--r--api/resources/v2/pods.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/api/resources/v2/pods.py b/api/resources/v2/pods.py
index ffb8a6046..ebc1312da 100644
--- a/api/resources/v2/pods.py
+++ b/api/resources/v2/pods.py
@@ -77,3 +77,24 @@ class V2Pod(ApiResource):
content = jsonutils.loads(pod.content)
return result_handler(consts.API_SUCCESS, {'pod': content})
+
+ def delete(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')
+
+ LOG.info('update pod in environment')
+ environment_handler = V2EnvironmentHandler()
+ environment_handler.update_attr(pod.environment_id, {'pod_id': None})
+
+ LOG.info('delete pod in database')
+ pod_handler.delete_by_uuid(pod_id)
+
+ return result_handler(consts.API_SUCCESS, {'pod': pod_id})