diff options
author | Huang Haibin <haibin.huang@intel.com> | 2018-10-15 14:20:05 +0800 |
---|---|---|
committer | Huang Haibin <haibin.huang@intel.com> | 2018-10-15 14:42:04 +0800 |
commit | 2ecc9776c622ffcf678da742d1dbc95aaa0bf322 (patch) | |
tree | 69d0b1173b5454d9e982ee3b7d7201b81b3a3313 | |
parent | 70d085921ab6ff1585c9a983a5716208919c41cb (diff) |
Upgrade proxy v1 for ocata
Change-Id: I97b5fb82ae54855dd334f6b82c55c903f33232d5
Issue-ID: MULTICLOUD-378
Signed-off-by: Huang Haibin <haibin.huang@intel.com>
-rw-r--r-- | ocata/ocata/proxy/urlsV1.py | 39 | ||||
-rw-r--r-- | ocata/ocata/proxy/views/identityV3.py | 2 | ||||
-rw-r--r-- | ocata/ocata/proxy/views/services.py | 98 | ||||
-rw-r--r-- | ocata/ocata/urls.py | 2 |
4 files changed, 140 insertions, 1 deletions
diff --git a/ocata/ocata/proxy/urlsV1.py b/ocata/ocata/proxy/urlsV1.py new file mode 100644 index 00000000..3c275c08 --- /dev/null +++ b/ocata/ocata/proxy/urlsV1.py @@ -0,0 +1,39 @@ +# Copyright (c) 2018 Intel Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from django.conf.urls import url +from rest_framework.urlpatterns import format_suffix_patterns + +from ocata.proxy.views import identityV3 +from ocata.proxy.views import services +from newton_base.proxy import dnsaasdelegate + +urlpatterns = [ + url(r'^identity/v3/auth/tokens/?$', + identityV3.APIv1Tokens.as_view()), + url(r'^identity/v3/?$', + identityV3.APIv1Tokens.as_view()), + url(r'^identity/v2.0/?$', + identityV3.APIv1TokensV2.as_view()), + url(r'^identity/v2.0/tokens/?$', + identityV3.APIv1TokensV2.as_view()), + url(r'^identity/v2.0/tenants/?$', + services.APIv1GetTenants.as_view()), + url(r'dns-delegate/(?P<requri>[0-9a-zA-Z./_-]*)$', + dnsaasdelegate.APIv1DnsaasDelegate.as_view()), + url(r'^(?P<servicetype>[0-9a-zA-Z_-]{,18})/(?P<requri>[0-9a-zA-Z./_-]*)$', + services.APIv1Services.as_view()), +] + +urlpatterns = format_suffix_patterns(urlpatterns) diff --git a/ocata/ocata/proxy/views/identityV3.py b/ocata/ocata/proxy/views/identityV3.py index ed0443dc..9a96f66e 100644 --- a/ocata/ocata/proxy/views/identityV3.py +++ b/ocata/ocata/proxy/views/identityV3.py @@ -16,6 +16,7 @@ import logging from django.conf import settings from newton_base.proxy import identityV3 as newton_identityV3 +from common.msapi import extsys logger = logging.getLogger(__name__) @@ -79,4 +80,3 @@ class APIv1TokensV2(TokensV2): vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) return super(APIv1TokensV2,self).post(request, vimid) - diff --git a/ocata/ocata/proxy/views/services.py b/ocata/ocata/proxy/views/services.py index d7c1dc05..032cefef 100644 --- a/ocata/ocata/proxy/views/services.py +++ b/ocata/ocata/proxy/views/services.py @@ -18,6 +18,7 @@ from rest_framework import status from django.conf import settings from newton_base.proxy import services as newton_services +from common.msapi import extsys logger = logging.getLogger(__name__) @@ -44,3 +45,100 @@ class GetTenants(newton_services.GetTenants): % (vimid, servicetype, requri)) return super(GetTenants,self).get(request, vimid, servicetype, requri) + +class APIv1Services(Services): + + def __init__(self): + super(APIv1Services, self).__init__() + # self._logger = logger + + def head(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + # self._logger.info("servicetype, requri> %s,%s" % (servicetype, requri)) + # self._logger.debug("META, data> %s , %s" % (request.META, request.data)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Services,self).head(request, vimid, servicetype, requri) + + def get(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Services,self).get(request, vimid, servicetype, requri) + + def post(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Services,self).post(request, vimid, servicetype, requri) + + def put(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Services,self).put(request, vimid, servicetype, requri) + + def patch(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Services,self).patch(request, vimid, servicetype, requri) + + def delete(self, request, cloud_owner="", cloud_region_id="", servicetype="", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1Services,self).delete(request, vimid, servicetype, requri) + + +class APIv1GetTenants(GetTenants): + ''' + Backward compatible API for /v2.0/tenants + ''' + + def __init__(self): + super(APIv1GetTenants, self).__init__() + # self._logger = logger + + def head(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + # self._logger.info("servicetype, requri> %s,%s" % (servicetype, requri)) + # self._logger.debug("META, data> %s , %s" % (request.META, request.data)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1GetTenants,self).head(request, vimid, servicetype, requri) + + def get(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri='v3/projects'): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + # self._logger.debug("with servicetype, requri> %s,%s" % (servicetype, requri)) + # self._logger.debug("with META> %s" % request.META) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1GetTenants,self).get(request, vimid, servicetype, requri) + + def post(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + # self._logger.debug("with servicetype, requri> %s,%s" % (servicetype, requri)) + # self._logger.debug("with META> %s" % request.META) + # self._logger.debug("with data> %s" % request.data) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1GetTenants,self).post(request, vimid, servicetype, requri) + + def put(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1GetTenants,self).put(request, vimid, servicetype, requri) + + def patch(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1GetTenants,self).patch(request, vimid, servicetype, requri) + + def delete(self, request, cloud_owner="", cloud_region_id="", servicetype="identity", requri=""): + self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner, cloud_region_id)) + + vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id) + return super(APIv1GetTenants,self).delete(request, vimid, servicetype, requri) diff --git a/ocata/ocata/urls.py b/ocata/ocata/urls.py index c5e2d973..ac6c8f2e 100644 --- a/ocata/ocata/urls.py +++ b/ocata/ocata/urls.py @@ -52,6 +52,8 @@ urlpatterns = [ registration.RegistryV1.as_view()), url(r'^api/multicloud-ocata/v1/(?P<vimid>[0-9a-zA-Z_-]+)/exten', include('ocata.extensions.urlsV1')), + url(r'^api/multicloud-ocata/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/', + include('ocata.proxy.urlsV1')), url(r'^api/multicloud-ocata/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/?$', infra_workload.APIv1InfraWorkload.as_view()), url(r'^api/multicloud-ocata/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/(?P<requri>[0-9a-zA-Z_-]*)/?$', |