From f495e51cd523a3c7244e51d4dcb7562a3dbd1141 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Tue, 16 Oct 2018 16:32:26 +0800 Subject: Add infra_workload simulation API in vio plugin Add a simulated infra_workload API for testing. Change-Id: I2e87b249a1b2b670cec97af6c32cba353939df44 Issue-ID: MULTICLOUD-381 Signed-off-by: Ethan Lynn --- vio/vio/swagger/urls.py | 7 ++++++ vio/vio/swagger/views/fakeplugin/heat/views.py | 31 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/vio/vio/swagger/urls.py b/vio/vio/swagger/urls.py index c509a42..568b018 100644 --- a/vio/vio/swagger/urls.py +++ b/vio/vio/swagger/urls.py @@ -119,6 +119,8 @@ from vio.swagger.views.fakeplugin.neutron.views import FakeNeutronNetwork from vio.swagger.views.fakeplugin.heat.views import FakeHeatResources from vio.swagger.views.fakeplugin.heat.views import FakeHeatService from vio.swagger.views.fakeplugin.heat.views import FakeHeatServicePreview +from vio.swagger.views.fakeplugin.heat.views import FakeInfraWorkloadAPIGet +from vio.swagger.views.fakeplugin.heat.views import FakeInfraWorkloadAPIPost urlpatterns = [ @@ -215,6 +217,11 @@ urlpatterns = [ r'(?P[0-9a-z-A-Z\-\_]+)' r'/stacks/(?P[0-9a-z-A-Z\-\_]+)' r'/(?P[0-9a-z-A-Z\-\_]+)$', FakeHeatService.as_view()), + url(r'api/multicloud-vio/v[01]/vmware[_/]fake/infra_workload$', + FakeInfraWorkloadAPIPost.as_view()), + url(r'api/multicloud-vio/v[01]/vmware[_/]fake/infra_workload$' + r'/(?P[0-9a-z-A-Z\-\_]+)$', + FakeInfraWorkloadAPIGet.as_view()), # vio url(r'^api/multicloud-vio/v0/(?P[0-9a-zA-Z_-]+)/' diff --git a/vio/vio/swagger/views/fakeplugin/heat/views.py b/vio/vio/swagger/views/fakeplugin/heat/views.py index b662378..9fe00be 100644 --- a/vio/vio/swagger/views/fakeplugin/heat/views.py +++ b/vio/vio/swagger/views/fakeplugin/heat/views.py @@ -101,3 +101,34 @@ class FakeHeatService(APIView): status=data['error']['code']) return Response(data=data, status=status.HTTP_204_NO_CONTENT) + + +class FakeInfraWorkloadAPIGet(APIView): + + def get(self, request, workload_id): + if workload_id != "fdae10c6-664c-48e2-9e86-7bc2d7e42c26": + return Response(status=status.HTTP_404_NOT_FOUND) + + data = { + "template_type": "heat", + "workload_id": "fdae10c6-664c-48e2-9e86-7bc2d7e42c26", + } + + return Response(data=data, status=status.HTTP_200_OK) + + def delete(self, request, workload_id): + if workload_id != "fdae10c6-664c-48e2-9e86-7bc2d7e42c26": + return Response(status=status.HTTP_404_NOT_FOUND) + + return Response(status=status.HTTP_204_NO_CONTENT) + + +class FakeInfraWorkloadAPIPost(APIView): + + def post(self, request): + data = { + "template_type": "heat", + "workload_id": "fdae10c6-664c-48e2-9e86-7bc2d7e42c26", + } + + return Response(data=data, status=status.HTTP_200_OK) -- cgit 1.2.3-korg