diff options
author | 2018-03-29 08:05:46 +0000 | |
---|---|---|
committer | 2018-03-29 08:05:46 +0000 | |
commit | 3c7c09897acdb4d155754e2f16c314c597727220 (patch) | |
tree | d28424126fbae8685bdb5c13f950c3cf6abca396 /vio | |
parent | 9106c9d87c02ce6907ea82fa5bec0aadd1d04d5c (diff) | |
parent | d6b5df80397716b3a1eab5aa222f03508958a527 (diff) |
Merge "Add fake API for image service"
Diffstat (limited to 'vio')
-rw-r--r-- | vio/vio/swagger/urls.py | 7 | ||||
-rw-r--r-- | vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py | 27 | ||||
-rw-r--r-- | vio/vio/swagger/views/fakeplugin/image/views.py | 18 |
3 files changed, 52 insertions, 0 deletions
diff --git a/vio/vio/swagger/urls.py b/vio/vio/swagger/urls.py index 3871599..e0195fc 100644 --- a/vio/vio/swagger/urls.py +++ b/vio/vio/swagger/urls.py @@ -65,6 +65,8 @@ from vio.swagger.views.fakeplugin.image.views import FakeImage from vio.swagger.views.fakeplugin.image.views import FakeImageVersion from vio.swagger.views.fakeplugin.image.views import FakeImageDetail from vio.swagger.views.fakeplugin.image.views import FakeImageSchema +from vio.swagger.views.fakeplugin.image.views import FakeImageDownload +from vio.swagger.views.fakeplugin.image.views import FakeImageUpload from vio.swagger.views.fakeplugin.nova.views import FakeNovaServer from vio.swagger.views.fakeplugin.nova.views import FakeNovaHypervisors from vio.swagger.views.fakeplugin.nova.views import FakeNovaAggregate @@ -210,6 +212,11 @@ urlpatterns = [ FakeImageDetail.as_view()), url(r'^api/multicloud-vio/v0/vmware_fake/glance/v2/images', FakeImage.as_view()), + url(r'^api/multicloud-vio/v0/vmware_fake/glance/v2/image/file/' + r'(?P<imageid>[0-9a-z-A-Z\-\_]+)$', + FakeImageDownload.as_view()), + url(r'^api/multicloud-vio/v0/vmware_fake/glance/v2/image/file$', + FakeImageUpload.as_view()), url(r'^api/multicloud-vio/v0/vmware_fake/glance/version', FakeImageVersion.as_view()), url(r'^api/multicloud-vio/v0/vmware_fake/neutron$', diff --git a/vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py b/vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py index 0368f02..c23a1b2 100644 --- a/vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py +++ b/vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py @@ -1854,6 +1854,33 @@ def image_detail(): return data +def upload_image(req): + + data = { + "status": "active", + "name": req.get('name'), + "tags": [], + "container_format": req.get('container_format'), + "created_at": "2014-05-05T17:15:10Z", + "disk_format": req.get('disk_format'), + "updated_at": "2014-05-05T17:15:11Z", + "visibility": req.get('visibility'), + "self": "/v2/images/1bea47ed-f6a9-463b-b423-14b9cca9ad27", + "min_disk": 0, + "protected": "false", + "id": Imageid, + "file": "/v2/images/1bea47ed-f6a9-463b-b423-14b9cca9ad27/file", + "checksum": "64d7c1cd2b6f60c92c14662941cb7913", + "owner": "5ef70662f8b34079a6eddb8da9d75fe8", + "size": 13167616, + "min_ram": 0, + "schema": req.get('schema'), + "virtual_size": "null" + } + + return data + + def list_image(): data = { diff --git a/vio/vio/swagger/views/fakeplugin/image/views.py b/vio/vio/swagger/views/fakeplugin/image/views.py index 6d6e242..74d7467 100644 --- a/vio/vio/swagger/views/fakeplugin/image/views.py +++ b/vio/vio/swagger/views/fakeplugin/image/views.py @@ -2,11 +2,13 @@ from rest_framework import status from rest_framework.views import APIView from rest_framework.response import Response +import json from vio.swagger.views.fakeplugin.fakeData.fakeResponse import image_detail from vio.swagger.views.fakeplugin.fakeData.fakeResponse import list_image from vio.swagger.views.fakeplugin.fakeData.fakeResponse import image_schema from vio.swagger.views.fakeplugin.fakeData.fakeResponse import image_version +from vio.swagger.views.fakeplugin.fakeData.fakeResponse import upload_image false = "false" null = "null" @@ -42,3 +44,19 @@ class FakeImageVersion(APIView): data = image_version() return Response(data=data, status=status.HTTP_200_OK) + + +class FakeImageDownload(APIView): + + def get(self, request, imageid): + + data = image_detail() + return Response(data=data, status=status.HTTP_200_OK) + + +class FakeImageUpload(APIView): + + def post(self, request): + req = json.loads(request.body) + data = upload_image(dict(req)) + return Response(data=data, status=status.HTTP_201_CREATED) |