summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Lynn <ethanlynnl@vmware.com>2018-08-27 13:33:24 +0800
committerEthan Lynn <ethanlynnl@vmware.com>2018-08-28 11:20:41 +0800
commit2957ef709fbcc0fdc2c302910f8004e2e1c74a10 (patch)
treee67fc707473eb06a7e7f26fca2fcdd384d907e2d
parentba872758c4ba674cc30c03e29a16840b8305b91e (diff)
Upgrade image api to v1
This patch update image api to v1, others will be updated by following patches Change-Id: I1ed03fce353a088a17e48c1fd00e491c65983075 Issue-ID: MULTICLOUD-339 Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
-rw-r--r--vio/vio/pub/utils/fileutil.py2
-rw-r--r--vio/vio/pub/vim/vimapi/keystone/auth.py2
-rw-r--r--vio/vio/swagger/urls.py24
-rw-r--r--vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py2
-rw-r--r--vio/vio/swagger/views/image/views.py32
5 files changed, 59 insertions, 3 deletions
diff --git a/vio/vio/pub/utils/fileutil.py b/vio/vio/pub/utils/fileutil.py
index 9adf807..094e71e 100644
--- a/vio/vio/pub/utils/fileutil.py
+++ b/vio/vio/pub/utils/fileutil.py
@@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
def make_dirs(path):
if not os.path.exists(path):
- os.makedirs(path, 0777)
+ os.makedirs(path, mode=0o777)
def delete_dirs(path):
diff --git a/vio/vio/pub/vim/vimapi/keystone/auth.py b/vio/vio/pub/vim/vimapi/keystone/auth.py
index 504fb4a..866df20 100644
--- a/vio/vio/pub/vim/vimapi/keystone/auth.py
+++ b/vio/vio/pub/vim/vimapi/keystone/auth.py
@@ -22,4 +22,4 @@ logger = logging.getLogger(__name__)
def login(data):
- print data
+ print(data)
diff --git a/vio/vio/swagger/urls.py b/vio/vio/swagger/urls.py
index c68c297..6e9b970 100644
--- a/vio/vio/swagger/urls.py
+++ b/vio/vio/swagger/urls.py
@@ -31,6 +31,12 @@ from vio.swagger.views.network.views import DeleteNetworkView
from vio.swagger.views.subnet.views import CreateSubnetView, DeleteSubnetView
from vio.swagger.views.port.views import CreatePortView, DeletePortView
+# V1 API
+from vio.swagger.views.image.views import CreateListImagesViewV1
+from vio.swagger.views.image.views import GetDeleteImageViewV1
+from vio.swagger.views.image.views import CreateImageFileViewV1
+from vio.swagger.views.image.views import GetImageFileViewV1
+
# proxy
from vio.swagger.views.proxyplugin.identity.views import TokenView
from vio.swagger.views.proxyplugin.identity.views import TokenV2View
@@ -161,6 +167,24 @@ urlpatterns = [
r'(?P<portid>[0-9a-zA-Z\-\_]+)$',
DeletePortView.as_view()),
+ # V1 urls
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/(?P<tenantid>[0-9a-zA-Z_-]+)/'
+ r'images$',
+ CreateListImagesViewV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/(?P<tenantid>[0-9a-zA-Z_-]+)/'
+ r'images/(?P<imageid>[0-9a-zA-Z_-]+)$',
+ GetDeleteImageViewV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/(?P<tenantid>[0-9a-zA-Z_-]+)/'
+ r'images/file$',
+ CreateImageFileViewV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/(?P<tenantid>[0-9a-zA-Z_-]+)/'
+ r'images/file/(?P<imageid>[0-9a-zA-Z_-]+)$',
+ GetImageFileViewV1.as_view()),
+
# fake urls
url(r'^api/multicloud-vio/v0/vmware_fake/identity/v3',
FakeToken.as_view()),
diff --git a/vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py b/vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py
index ff9c066..20362db 100644
--- a/vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py
+++ b/vio/vio/swagger/views/fakeplugin/fakeData/fakeResponse.py
@@ -1673,7 +1673,7 @@ def _serverStatus(serverid):
startTime = serverMapps[serverid]['turnStatusTime']
currentTime = datetime.now()
- print currentTime - startTime
+ print(currentTime - startTime)
if currentTime - startTime >= timedelta(seconds=10):
if serverMapps[serverid]['status'] == "SPAWNING" \
or serverMapps[serverid]['status'] == "BUILDING":
diff --git a/vio/vio/swagger/views/image/views.py b/vio/vio/swagger/views/image/views.py
index 9c6da70..6df6710 100644
--- a/vio/vio/swagger/views/image/views.py
+++ b/vio/vio/swagger/views/image/views.py
@@ -83,6 +83,16 @@ class GetDeleteImageView(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+class GetDeleteImageViewV1(GetDeleteImageView):
+ def get(self, request, cloud_owner, cloud_region, tenantid, imageid):
+ return super(GetDeleteImageViewV1, self).get(
+ request, cloud_owner + '_' + cloud_region, tenantid, imageid)
+
+ def delete(self, request, cloud_owner, cloud_region, tenantid, imageid):
+ return super(GetDeleteImageViewV1, self).delete(
+ request, cloud_owner + '_' + cloud_region, tenantid, imageid)
+
+
class CreateListImagesView(APIView):
def get(self, request, vimid, tenantid):
@@ -154,6 +164,16 @@ class CreateListImagesView(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+class CreateListImagesViewV1(CreateListImagesView):
+ def get(self, request, cloud_owner, cloud_region, tenantid):
+ return super(CreateListImagesViewV1, self).get(
+ request, cloud_owner + '_' + cloud_region, tenantid)
+
+ def post(self, request, cloud_owner, cloud_region, tenantid):
+ return super(CreateListImagesViewV1, self).post(
+ request, cloud_owner + '_' + cloud_region, tenantid)
+
+
class CreateImageFileView(APIView):
def post(self, request, vimid, tenantid):
@@ -209,6 +229,12 @@ class CreateImageFileView(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+class CreateImageFileViewV1(CreateImageFileView):
+ def post(self, request, cloud_owner, cloud_region, tenantid):
+ return super(CreateImageFileViewV1, self).post(
+ request, cloud_owner + '_' + cloud_region, tenantid)
+
+
class GetImageFileView(APIView):
def post(self, request, vimid, tenantid, imageid):
@@ -257,3 +283,9 @@ class GetImageFileView(APIView):
else:
return Response(data={'error': str(e)},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+
+class GetImageFileViewV1(GetImageFileView):
+ def post(self, request, cloud_owner, cloud_region, tenantid, imageid):
+ return super(GetImageFileViewV1, self).post(
+ request, cloud_owner + '_' + cloud_region, tenantid, imageid)