summaryrefslogtreecommitdiffstats
path: root/pike
diff options
context:
space:
mode:
authorHuang Haibin <haibin.huang@intel.com>2018-10-15 14:08:21 +0800
committerHuang Haibin <haibin.huang@intel.com>2018-10-15 14:08:21 +0800
commit70d085921ab6ff1585c9a983a5716208919c41cb (patch)
tree5a6639c9225bf2440bbaa1dfd7e8bbc7e81ee685 /pike
parentdd9d5031e3babd86ca25a2a06586dee1513269e5 (diff)
Upgrade proxy v1 for pike
Change-Id: I9c65c9cf3851cfbbf064b8955ff6fd6b0a35a875 Issue-ID: MULTICLOUD-377 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
Diffstat (limited to 'pike')
-rw-r--r--pike/pike/proxy/urlsV1.py39
-rw-r--r--pike/pike/proxy/views/identityV3.py50
-rw-r--r--pike/pike/proxy/views/services.py98
-rw-r--r--pike/pike/urls.py3
4 files changed, 190 insertions, 0 deletions
diff --git a/pike/pike/proxy/urlsV1.py b/pike/pike/proxy/urlsV1.py
new file mode 100644
index 00000000..481e473f
--- /dev/null
+++ b/pike/pike/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 pike.proxy.views import identityV3
+from pike.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/pike/pike/proxy/views/identityV3.py b/pike/pike/proxy/views/identityV3.py
index e87ea86e..891b4886 100644
--- a/pike/pike/proxy/views/identityV3.py
+++ b/pike/pike/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__)
@@ -32,3 +33,52 @@ class TokensV2(newton_identityV3.TokensV2):
def __init__(self):
self.proxy_prefix = settings.MULTICLOUD_PREFIX
self._logger = logger
+
+class APIv1Tokens(Tokens):
+ def __init__(self):
+ super(APIv1Tokens, self).__init__()
+ self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
+ # self._logger = logger
+
+
+ def get(self, request, cloud_owner="", cloud_region_id=""):
+ self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
+ #self._logger.debug("META> %s" % request.META)
+ #self._logger.debug("data> %s" % request.data)
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1Tokens,self).get(request, vimid)
+
+
+ def post(self, request, cloud_owner="", cloud_region_id=""):
+ self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
+ # self._logger.debug("META> %s" % request.META)
+ # self._logger.debug("data> %s" % request.data)
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1Tokens,self).post(request, vimid)
+
+
+class APIv1TokensV2(TokensV2):
+ def __init__(self):
+ super(APIv1TokensV2, self).__init__()
+ self.proxy_prefix = settings.MULTICLOUD_API_V1_PREFIX
+ # self._logger = logger
+
+
+ def get(self, request, cloud_owner="", cloud_region_id=""):
+ self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
+ # self._logger.debug("META> %s" % request.META)
+ # self._logger.debug("data> %s" % request.data)
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1TokensV2,self).get(request, vimid)
+
+
+ def post(self, request, cloud_owner="", cloud_region_id=""):
+ self._logger.info("cloud_owner,cloud_region_id: %s,%s" % (cloud_owner,cloud_region_id))
+ # self._logger.debug("META> %s" % request.META)
+ # self._logger.debug("data> %s" % request.data)
+
+ vimid = extsys.encode_vim_id(cloud_owner, cloud_region_id)
+ return super(APIv1TokensV2,self).post(request, vimid)
diff --git a/pike/pike/proxy/views/services.py b/pike/pike/proxy/views/services.py
index 358ac3d6..d1204700 100644
--- a/pike/pike/proxy/views/services.py
+++ b/pike/pike/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/pike/pike/urls.py b/pike/pike/urls.py
index 15948e45..47b2f647 100644
--- a/pike/pike/urls.py
+++ b/pike/pike/urls.py
@@ -42,6 +42,9 @@ urlpatterns = [
registration.RegistryV1.as_view()),
url(r'^api/multicloud-pike/v1/(?P<vimid>[0-9a-zA-Z_-]+)/exten',
include('pike.extensions.urlsV1')),
+ url(r'^api/multicloud-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/',
+ include('pike.proxy.urlsV1')),
+
url(r'^api/multicloud-pike/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-pike/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/(?P<requri>[0-9a-zA-Z_-]*)/?$',