From 7482041fefa0f892a5d76d9cd6bc003d172a43ce Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Wed, 25 Oct 2017 15:10:15 +0800 Subject: Update identity conversion for API v2.0 support parameter tenantId Change-Id: I11d94db0c6fc4d7ea40d66110bb90d2976cd6f3e Issue-Id: MULTICLOUD-119 Signed-off-by: Bin Yang --- newton/newton/proxy/urls.py | 2 ++ newton/newton/proxy/views/identityV3.py | 26 ++++++++++++++++++++++++-- newton/newton/proxy/views/services.py | 10 ++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/newton/newton/proxy/urls.py b/newton/newton/proxy/urls.py index 0e0ca52a..3a4be2f4 100644 --- a/newton/newton/proxy/urls.py +++ b/newton/newton/proxy/urls.py @@ -24,6 +24,8 @@ urlpatterns = [ # identityV2.Tokens.as_view()), url(r'^identity/v3/auth/tokens$', identityV3.Tokens.as_view()), + url(r'^identity/v3/?$', + identityV3.Tokens.as_view()), url(r'^identity/v2.0/?$', identityV3.TokensV2.as_view()), url(r'^identity/v2.0/tokens/?$', diff --git a/newton/newton/proxy/views/identityV3.py b/newton/newton/proxy/views/identityV3.py index 7395fac8..d12e24ce 100644 --- a/newton/newton/proxy/views/identityV3.py +++ b/newton/newton/proxy/views/identityV3.py @@ -33,6 +33,22 @@ logger = logging.getLogger(__name__) DEBUG=True +v3_version_detail = { + "version": { + "status": "stable", + "updated": "2014-04-17T00:00:00Z", + "media-types": [ + { + "base": "application/json", + "type": "application/vnd.openstack.identity-v3+json" + } + ], + "id": "v3", + "links": [ + ] + } +} + class Tokens(APIView): service = {'service_type': 'identity', 'interface': 'public'} @@ -41,6 +57,11 @@ class Tokens(APIView): self.proxy_prefix = config.MULTICLOUD_PREFIX self._logger = logger + def get(self, request, vimid=""): + self._logger.debug("identityV3--get::META> %s" % request.META) + + return Response(data=v3_version_detail, status=status.HTTP_200_OK) + def post(self, request, vimid=""): self._logger.debug("identityV3--post::META> %s" % request.META) self._logger.debug("identityV3--post::data> %s" % request.data) @@ -55,6 +76,7 @@ class Tokens(APIView): #backward support for keystone v2.0 API if not tenant_name and request.data.get("auth"): tenant_name = request.data["auth"].get("tenantName") + tenant_id = request.data["auth"].get("tenantId") #keystone v3 API if not tenant_name and request.data.get("auth") \ @@ -104,7 +126,7 @@ class Tokens(APIView): return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) -version_detail = { +v2_version_detail = { "version": { "status": "stable", "updated": "2014-04-17T00:00:00Z", @@ -132,7 +154,7 @@ class TokensV2(Tokens): def get(self, request, vimid=""): self._logger.debug("TokensV2--get::META> %s" % request.META) - return Response(data=version_detail, status=status.HTTP_200_OK) + return Response(data=v2_version_detail, status=status.HTTP_200_OK) def post(self, request, vimid=""): self._logger.debug("TokensV2--post::META> %s" % request.META) diff --git a/newton/newton/proxy/views/services.py b/newton/newton/proxy/views/services.py index d86b0e8c..7115d4d8 100644 --- a/newton/newton/proxy/views/services.py +++ b/newton/newton/proxy/views/services.py @@ -130,10 +130,16 @@ class Services(APIView): content = resp.json() if resp.content else None self._logger.debug("service " + action + " response: %s, %s" % (resp.status_code, content)) - if (action != "delete"): + if (action == "delete"): + return Response(headers={'X-Subject-Token': tmp_auth_token}, status=resp.status_code) + else: content = ProxyUtils.update_prefix(metadata_catalog, content) + if (action == "get"): + if requri == '/v3/auth/catalog' and content and content.get("catalog"): + content['catalog'] = ProxyUtils.update_catalog_dnsaas( + vim_id, content['catalog'], self.proxy_prefix, vim) return Response(headers={'X-Subject-Token': tmp_auth_token}, data=content, status=resp.status_code) - return Response(headers={'X-Subject-Token': tmp_auth_token}, status=resp.status_code) + except VimDriverNewtonException as e: return Response(data={'error': e.content}, status=e.status_code) except HttpError as e: -- cgit 1.2.3-korg