diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-07-14 03:54:06 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-07-14 08:45:31 +0000 |
commit | 616b30ebd0e6a95076f015bbe94e3071a28a6391 (patch) | |
tree | 72fe3c5a6f00605f583ef75ff434f6fb3ed0fa08 /api | |
parent | fb86be55d52f6cefd4e0de4b857ac76d00a9e681 (diff) |
Add API(v2) to delete pod
JIRA: YARDSTICK-725
API: /api/v2/yardstick/pods/<pod_id>
METHOD: DELETE
Change-Id: Ib9e9f9ced455c4ee3b6e1f63d773ea2e3ee906a6
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api')
-rw-r--r-- | api/resources/v2/pods.py | 21 |
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}) |