summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Sun <bins@vmware.com>2018-03-23 14:54:51 +0800
committerBin Sun <bins@vmware.com>2018-03-23 14:54:51 +0800
commit2a2f5024ea1e977b71e7215066da879120b8505d (patch)
treefd958bc2b099bc00fbc8fb8f0d8afdd073e8154f
parentab6e2ab948ac5a24fd0129def9849dd672257485 (diff)
Add delete method in api exposure framework
Change-Id: I47547c290e7485f9afd904d6ab1034a9f3969209 Issue-ID: MULTICLOUD-152 Signed-off-by: Bin Sun <bins@vmware.com>
-rw-r--r--vio/vio/api_v2/api_definition/networks.yaml2
-rw-r--r--vio/vio/api_v2/api_router/controller_builder.py13
2 files changed, 15 insertions, 0 deletions
diff --git a/vio/vio/api_v2/api_definition/networks.yaml b/vio/vio/api_v2/api_definition/networks.yaml
index 6e13493..2be9943 100644
--- a/vio/vio/api_v2/api_definition/networks.yaml
+++ b/vio/vio/api_v2/api_definition/networks.yaml
@@ -43,6 +43,8 @@
"200":
schema:
$ref: "#/definitions/network"
+ delete:
+ responses: "204"
vim_path: "/network/v2.0/networks"
definitions:
network:
diff --git a/vio/vio/api_v2/api_router/controller_builder.py b/vio/vio/api_v2/api_router/controller_builder.py
index f40bfd4..4e6d39d 100644
--- a/vio/vio/api_v2/api_router/controller_builder.py
+++ b/vio/vio/api_v2/api_router/controller_builder.py
@@ -195,6 +195,19 @@ def _build_api_controller(api_meta):
controller_meta["post"] = _post
+ if "delete" in path_meta:
+ # Add delete method to controller
+ @pecan.expose("json")
+ def _delete(self, vim_id, tenant_id, resource_id):
+ """ General DELETE """
+ session = _get_vim_auth_session(vim_id, tenant_id)
+ service = {'service_type': service_type,
+ 'interface': 'public'}
+ full_url = resource_url + "/%s" % resource_id
+ session.delete(full_url, endpoint_filter=service)
+
+ controller_meta["delete"] = _delete
+
return path, type(controller_name, (rest.RestController,), controller_meta)