diff options
author | Bin Yang <bin.yang@windriver.com> | 2017-10-26 18:14:52 +0800 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2017-10-26 18:14:52 +0800 |
commit | 3b927f98f161e317da2448b19cfc8f00e34b246e (patch) | |
tree | 5d12082c20c39230c1b4fb78f896e7ad2950e7f5 /newton | |
parent | 40c6920a33499b3f3bca3fcba17f7b3966e7da5b (diff) |
Set the default auth url to be v2.0
Change-Id: I34afca5b5388299d5fe6a0962fb4e850275dfefa
Issue-Id: MULTICLOUD-119
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'newton')
-rw-r--r-- | newton/newton/proxy/views/dnsaasdelegate.py | 8 | ||||
-rw-r--r-- | newton/newton/proxy/views/proxy_utils.py | 19 | ||||
-rw-r--r-- | newton/newton/proxy/views/services.py | 15 | ||||
-rw-r--r-- | newton/newton/registration/views/registration.py | 2 |
4 files changed, 34 insertions, 10 deletions
diff --git a/newton/newton/proxy/views/dnsaasdelegate.py b/newton/newton/proxy/views/dnsaasdelegate.py index bce24dff..0d2c97e1 100644 --- a/newton/newton/proxy/views/dnsaasdelegate.py +++ b/newton/newton/proxy/views/dnsaasdelegate.py @@ -62,6 +62,7 @@ class DnsaasDelegate(Services): status=status.HTTP_404_NOT_FOUND) tenant_name = auth_state['body']['token']['project']['name'] + #tenant_id = auth_state['body']['token']['project']['id'] #find out the delegated DNSaaS provider viminfo = VimDriverUtils.get_vim_info(vim_id) @@ -135,9 +136,12 @@ class DnsaasDelegate(Services): 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_dnsaas_project_id(content, tenant_id) 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: diff --git a/newton/newton/proxy/views/proxy_utils.py b/newton/newton/proxy/views/proxy_utils.py index 68182d4a..150cb217 100644 --- a/newton/newton/proxy/views/proxy_utils.py +++ b/newton/newton/proxy/views/proxy_utils.py @@ -174,3 +174,22 @@ class ProxyUtils(object): logger.error(traceback.format_exc()) return catalog + +# @staticmethod +# def update_dnsaas_project_id(content, new_project_id): +# ''' +# update project id in DNSaaS delegate content +# ''' +# try: +# if content: +# # filter the resp content and replace all endpoint prefix +# tmp_content = json.dumps(content) +# tmp_pattern = re.compile(r'(^.*)"project_id"\s*:\s*"' + r'[\w-]+'+r'"(.*$)') +# part1 = tmp_pattern.sub(r'\1', tmp_content) +# part2 = tmp_pattern.sub(r'"project_id":"'+new_project_id +r'"\2', tmp_content) +# #logger.debug("jsonstr:%s,part1:%s,part2:%s"%(tmp_content,part1,part2)) +# content = json.loads(part1+part2) +# return content +# except Exception as e: +# logger.error(traceback.format_exc()) +# return content diff --git a/newton/newton/proxy/views/services.py b/newton/newton/proxy/views/services.py index 7115d4d8..34f39128 100644 --- a/newton/newton/proxy/views/services.py +++ b/newton/newton/proxy/views/services.py @@ -35,6 +35,7 @@ DEBUG=True class HasValidToken(BasePermission): def has_permission(self, request, view): + logger.debug("HasValidToken--has_permission::META> %s" % request.META) token = request.META.get('HTTP_X_AUTH_TOKEN', None) if token: state, metadata = VimDriverUtils.get_token_cache(token) @@ -151,7 +152,7 @@ class Services(APIView): status=status.HTTP_500_INTERNAL_SERVER_ERROR) def head(self, request, vimid="", servicetype="", requri=""): - self._logger.debug("Services--head::META> %s" % request.META) + #self._logger.debug("Services--head::META> %s" % request.META) self._logger.debug("Services--head::data> %s" % request.data) self._logger.debug("Services--head::vimid, servicetype, requri> %s,%s,%s" % (vimid, servicetype, requri)) @@ -190,14 +191,14 @@ class Services(APIView): status=status.HTTP_500_INTERNAL_SERVER_ERROR) def get(self, request, vimid="", servicetype="", requri=""): - self._logger.debug("Services--get::META> %s" % request.META) + #self._logger.debug("Services--get::META> %s" % request.META) self._logger.debug("Services--get::data> %s" % request.data) self._logger.debug("Services--get::vimid, servicetype, requri> %s,%s,%s" % (vimid, servicetype, requri)) return self._do_action("get", request, vimid, servicetype, requri) def post(self, request, vimid="", servicetype="", requri=""): - self._logger.debug("Services--post::META> %s" % request.META) + #self._logger.debug("Services--post::META> %s" % request.META) self._logger.debug("Services--post::data> %s" % request.data) self._logger.debug("Services--post::vimid, servicetype, requri> %s,%s,%s" % (vimid, servicetype, requri)) @@ -205,21 +206,21 @@ class Services(APIView): return self._do_action("post", request, vimid, servicetype, requri) def put(self, request, vimid="", servicetype="", requri=""): - self._logger.debug("Services--put::META> %s" % request.META) + #self._logger.debug("Services--put::META> %s" % request.META) self._logger.debug("Services--put::data> %s" % request.data) self._logger.debug("Services--put::vimid, servicetype, requri> %s,%s,%s" % (vimid, servicetype, requri)) return self._do_action("put", request, vimid, servicetype, requri) def patch(self, request, vimid="", servicetype="", requri=""): - self._logger.debug("Services--patch::META> %s" % request.META) + #self._logger.debug("Services--patch::META> %s" % request.META) self._logger.debug("Services--patch::data> %s" % request.data) self._logger.debug("Services--patch::vimid, servicetype, requri> %s,%s,%s" % (vimid, servicetype, requri)) return self._do_action("patch", request, vimid, servicetype, requri) def delete(self, request, vimid="", servicetype="", requri=""): - self._logger.debug("Services--delete::META> %s" % request.META) + #self._logger.debug("Services--delete::META> %s" % request.META) self._logger.debug("Services--delete::data> %s" % request.data) self._logger.debug("Services--delete::vimid, servicetype, requri> %s,%s,%s" % (vimid, servicetype, requri)) @@ -235,7 +236,7 @@ class GetTenants(Services): self._logger = logger def get(self, request, vimid="", servicetype="identity", requri='projects'): - self._logger.debug("GetTenants--get::META> %s" % request.META) + #self._logger.debug("GetTenants--get::META> %s" % request.META) self._logger.debug("GetTenants--get::data> %s" % request.data) self._logger.debug("GetTenants--get::vimid, servicetype, requri> %s,%s,%s" % (vimid, servicetype, requri)) diff --git a/newton/newton/registration/views/registration.py b/newton/newton/registration/views/registration.py index 0a9f7f8e..5a1d2e9d 100644 --- a/newton/newton/registration/views/registration.py +++ b/newton/newton/registration/views/registration.py @@ -600,7 +600,7 @@ class Registry(APIView): if retcode == 0 and content: viminfo = json.JSONDecoder().decode(content) # cloud_epa_caps["resource-version"] = content["resource-version"] - viminfo['identity-url'] = self.proxy_prefix + "/%s/identity/v3" % vimid + viminfo['identity-url'] = self.proxy_prefix + "/%s/identity/v2.0" % vimid retcode, content, status_code = \ restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s" |