aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2017-07-14 06:15:25 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-14 06:15:25 +0000
commit3f1a658fce4b3d81fa2b15ab1879fd37aad80760 (patch)
tree200121ce5c34a44e32ada6553714b8c56ee588c1 /api
parent74c3ca16d897abc6705eceefb0a737212dbe7f08 (diff)
parent886299ea745264d86b930fcbbb6c108594c76bd4 (diff)
Merge "Add API(v2) to delete openrc"
Diffstat (limited to 'api')
-rw-r--r--api/resources/v2/openrcs.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/api/resources/v2/openrcs.py b/api/resources/v2/openrcs.py
index afabcdec6..5f3b9382f 100644
--- a/api/resources/v2/openrcs.py
+++ b/api/resources/v2/openrcs.py
@@ -188,3 +188,24 @@ class V2Openrc(ApiResource):
content = jsonutils.loads(openrc.content)
return result_handler(consts.API_ERROR, {'openrc': content})
+
+ def delete(self, openrc_id):
+ try:
+ uuid.UUID(openrc_id)
+ except ValueError:
+ return result_handler(consts.API_ERROR, 'invalid openrc id')
+
+ LOG.info('Geting openrc: %s', openrc_id)
+ openrc_handler = V2OpenrcHandler()
+ try:
+ openrc = openrc_handler.get_by_uuid(openrc_id)
+ except ValueError:
+ return result_handler(consts.API_ERROR, 'no such openrc id')
+
+ LOG.info('update openrc in environment')
+ environment_handler = V2EnvironmentHandler()
+ environment_handler.update_attr(openrc.environment_id, {'openrc_id': None})
+
+ openrc_handler.delete_by_uuid(openrc_id)
+
+ return result_handler(consts.API_SUCCESS, {'openrc': openrc_id})