From 0fcb64cbc5b279802a087a5477d3fad2b88f6649 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Thu, 30 Aug 2018 14:34:01 +0800 Subject: Update network API to V1 This patch updates network related API to V1. Change-Id: Ide84407151736ef8477e4653047bf9b0cf150060 Issue-ID: MULTICLOUD-349 Signed-off-by: Ethan Lynn --- vio/vio/swagger/urls.py | 39 +++++++++++++++++++++++++++++++++- vio/vio/swagger/views/network/views.py | 20 +++++++++++++++++ vio/vio/swagger/views/port/views.py | 20 +++++++++++++++++ vio/vio/swagger/views/service/views.py | 6 ++++++ vio/vio/swagger/views/subnet/views.py | 20 +++++++++++++++++ vio/vio/swagger/views/tenant/views.py | 6 ++++++ 6 files changed, 110 insertions(+), 1 deletion(-) (limited to 'vio') diff --git a/vio/vio/swagger/urls.py b/vio/vio/swagger/urls.py index 26f5e50..024e18e 100644 --- a/vio/vio/swagger/urls.py +++ b/vio/vio/swagger/urls.py @@ -42,6 +42,13 @@ from vio.swagger.views.server.views import ListServersViewV1, GetServerViewV1 from vio.swagger.views.flavor.views import FlavorsViewV1, FlavorViewV1 from vio.swagger.views.limits.views import LimitsViewV1 from vio.swagger.views.hypervisor.views import HostViewV1 +from vio.swagger.views.service.views import HostsViewV1 +from vio.swagger.views.network.views import CreateNetworkViewV1 +from vio.swagger.views.network.views import DeleteNetworkViewV1 +from vio.swagger.views.subnet.views import CreateSubnetViewV1 +from vio.swagger.views.subnet.views import DeleteSubnetViewV1 +from vio.swagger.views.port.views import CreatePortViewV1, DeletePortViewV1 +from vio.swagger.views.tenant.views import ListTenantsViewV1 # proxy from vio.swagger.views.proxyplugin.identity.views import TokenView @@ -174,6 +181,9 @@ urlpatterns = [ DeletePortView.as_view()), # V1 urls + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z_-]+)/' + r'(?P[0-9a-zA-Z_-]+)/tenants$', + ListTenantsViewV1.as_view()), url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z_-]+)/' r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z_-]+)/' r'images$', @@ -214,14 +224,41 @@ urlpatterns = [ r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z]+)/' r'flavors/(?P[0-9a-zA-Z_-]+)$', FlavorViewV1.as_view()), - url(r'^api/multicloud-vio/v0/(?P[0-9a-zA-Z_-]+)/' + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z_-]+)/' r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z]+)/' r'limits$', LimitsViewV1.as_view()), + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z_-]+)/' + r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z]+)/hosts$', + HostsViewV1.as_view()), url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z_-]+)/' r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z]+)/' r'hosts/(?P[0-9a-zA-Z_-]+)$', HostViewV1.as_view()), + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z\-\_]+)/' + r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z\-\_]+)/' + r'networks$', + CreateNetworkViewV1.as_view()), + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z\-\_]+)/' + r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z\-\_]+)/' + r'networks/(?P[0-9a-zA-Z\-\_]+)$', + DeleteNetworkViewV1.as_view()), + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z\-\_]+)/' + r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z\-\_]+)/' + r'subnets$', + CreateSubnetViewV1.as_view()), + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z\-\_]+)/' + r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z\-\_]+)/' + r'subnets/(?P[0-9a-zA-Z\-\_]+)$', + DeleteSubnetViewV1.as_view()), + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z\-\_]+)/' + r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z\-\_]+)/' + r'ports$', + CreatePortViewV1.as_view()), + url(r'^api/multicloud-vio/v1/(?P[0-9a-zA-Z\-\_]+)/' + r'(?P[0-9a-zA-Z_-]+)/(?P[0-9a-zA-Z\-\_]+)/' + r'ports/(?P[0-9a-zA-Z\-\_]+)$', + DeletePortViewV1.as_view()), # fake urls url(r'^api/multicloud-vio/v0/vmware_fake/identity/v3', diff --git a/vio/vio/swagger/views/network/views.py b/vio/vio/swagger/views/network/views.py index 27d0f3a..6d182e2 100644 --- a/vio/vio/swagger/views/network/views.py +++ b/vio/vio/swagger/views/network/views.py @@ -74,6 +74,16 @@ class CreateNetworkView(APIView): status=status.HTTP_500_INTERNAL_SERVER_ERROR) +class CreateNetworkViewV1(CreateNetworkView): + def post(self, request, cloud_owner, cloud_region, tenantid): + return super(CreateNetworkViewV1, self).post( + request, cloud_owner + "_" + cloud_region, tenantid) + + def get(self, request, cloud_owner, cloud_region, tenantid): + return super(CreateNetworkViewV1, self).get( + request, cloud_owner + "_" + cloud_region, tenantid) + + class DeleteNetworkView(APIView): def get(self, request, vimid, tenantid, networkid): @@ -119,3 +129,13 @@ class DeleteNetworkView(APIView): else: return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + + +class DeleteNetworkViewV1(DeleteNetworkView): + def get(self, request, cloud_owner, cloud_region, tenantid, networkid): + return super(DeleteNetworkViewV1, self).get( + request, cloud_owner + "_" + cloud_region, tenantid, networkid) + + def delete(self, request, cloud_owner, cloud_region, tenantid, networkid): + return super(DeleteNetworkViewV1, self).delete( + request, cloud_owner + "_" + cloud_region, tenantid, networkid) diff --git a/vio/vio/swagger/views/port/views.py b/vio/vio/swagger/views/port/views.py index 249e7c3..33d633d 100644 --- a/vio/vio/swagger/views/port/views.py +++ b/vio/vio/swagger/views/port/views.py @@ -75,6 +75,16 @@ class CreatePortView(APIView): status=status.HTTP_500_INTERNAL_SERVER_ERROR) +class CreatePortViewV1(CreatePortView): + def post(self, request, cloud_owner, cloud_region, tenantid): + return super(CreatePortViewV1, self).post( + request, cloud_owner + "_" + cloud_region, tenantid) + + def get(self, request, cloud_owner, cloud_region, tenantid): + return super(CreatePortViewV1, self).get( + request, cloud_owner + "_" + cloud_region, tenantid) + + class DeletePortView(APIView): def get(self, request, vimid, tenantid, portid): @@ -104,3 +114,13 @@ class DeletePortView(APIView): else: return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + + +class DeletePortViewV1(DeletePortView): + def get(self, request, cloud_owner, cloud_region, tenantid, portid): + return super(DeletePortViewV1, self).get( + request, cloud_owner + "_" + cloud_region, tenantid, portid) + + def delete(self, request, cloud_owner, cloud_region, tenantid, portid): + return super(DeletePortViewV1, self).delete( + request, cloud_owner + "_" + cloud_region, tenantid, portid) diff --git a/vio/vio/swagger/views/service/views.py b/vio/vio/swagger/views/service/views.py index b632370..239e795 100644 --- a/vio/vio/swagger/views/service/views.py +++ b/vio/vio/swagger/views/service/views.py @@ -53,3 +53,9 @@ class HostsView(APIView): 'hosts': hosts} return Response(data=rsp, status=status.HTTP_200_OK) + + +class HostsViewV1(HostsView): + def get(self, request, cloud_owner, cloud_region, tenantid): + return super(HostsViewV1, self).get( + request, cloud_owner + "_" + cloud_region, tenantid) diff --git a/vio/vio/swagger/views/subnet/views.py b/vio/vio/swagger/views/subnet/views.py index 4da8842..c8c412c 100644 --- a/vio/vio/swagger/views/subnet/views.py +++ b/vio/vio/swagger/views/subnet/views.py @@ -75,6 +75,16 @@ class CreateSubnetView(APIView): status=status.HTTP_500_INTERNAL_SERVER_ERROR) +class CreateSubnetViewV1(CreateSubnetView): + def post(self, request, cloud_owner, cloud_region, tenantid): + return super(CreateSubnetViewV1, self).post( + request, cloud_owner + "_" + cloud_region, tenantid) + + def get(self, request, cloud_owner, cloud_region, tenantid): + return super(CreateSubnetViewV1, self).get( + request, cloud_owner + "_" + cloud_region, tenantid) + + class DeleteSubnetView(APIView): def get(self, request, vimid, tenantid, subnetid): @@ -104,3 +114,13 @@ class DeleteSubnetView(APIView): else: return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + + +class DeleteSubnetViewV1(DeleteSubnetView): + def get(self, request, cloud_owner, cloud_region, tenantid, subnetid): + return super(DeleteSubnetViewV1, self).get( + request, cloud_owner + "_" + cloud_region, tenantid, subnetid) + + def delete(self, request, cloud_owner, cloud_region, tenantid, subnetid): + return super(DeleteSubnetViewV1, self).delete( + request, cloud_owner + "_" + cloud_region, tenantid, subnetid) diff --git a/vio/vio/swagger/views/tenant/views.py b/vio/vio/swagger/views/tenant/views.py index 004fbbf..0ee58df 100644 --- a/vio/vio/swagger/views/tenant/views.py +++ b/vio/vio/swagger/views/tenant/views.py @@ -60,3 +60,9 @@ class ListTenantsView(APIView): tenant['name'] = project.name rsp['tenants'].append(tenant) return Response(data=rsp, status=status.HTTP_200_OK) + + +class ListTenantsViewV1(ListTenantsView): + def get(self, request, cloud_owner, cloud_region): + return super(ListTenantsViewV1, self).get( + request, cloud_owner + "_" + cloud_region) -- cgit 1.2.3-korg