From d6d8cbf451a596aa7cbaa240fbcafb288a3494bc Mon Sep 17 00:00:00 2001 From: Xiaohua Zhang Date: Thu, 20 Sep 2018 04:53:04 +0000 Subject: Filter endpoint filter mismatch with keystoneauth1 keystoneauth1 accept region_name as endpoint filter, which will match either region_id or region of the endpoint catalog Change-Id: I7ba1f7904e4b3004565d826f4ea3cd345ce45f62 Issue-ID: MULTICLOUD-364 Signed-off-by: Xiaohua Zhang --- share/newton_base/proxy/dnsaasdelegate.py | 2 +- share/newton_base/proxy/identityV3.py | 2 +- share/newton_base/proxy/proxy_utils.py | 13 +++++++------ share/newton_base/proxy/services.py | 11 +++++------ 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'share/newton_base/proxy') diff --git a/share/newton_base/proxy/dnsaasdelegate.py b/share/newton_base/proxy/dnsaasdelegate.py index 07ba1b51..74806330 100644 --- a/share/newton_base/proxy/dnsaasdelegate.py +++ b/share/newton_base/proxy/dnsaasdelegate.py @@ -128,7 +128,7 @@ class DnsaasDelegate(Services): service = { 'service_type': servicetype, 'interface': interface, - 'region_id': vim['openstack_region_id'] + 'region_name': vim['openstack_region_id'] if vim.get('openstack_region_id') else vim['cloud_region_id'] } diff --git a/share/newton_base/proxy/identityV3.py b/share/newton_base/proxy/identityV3.py index 0b51a1dc..7932b8e3 100644 --- a/share/newton_base/proxy/identityV3.py +++ b/share/newton_base/proxy/identityV3.py @@ -195,7 +195,7 @@ class TokensV2(Tokens): v2_catalog1_endpoints = { "id": v3_endpoint['id'], "region":v3_endpoint['region'], - "region_id": v3_endpoint['region_id'], + "region_name": v3_endpoint['region_id'], 'interface':v3_endpoint['interface'] } if v3_endpoint['interface'] == 'public': diff --git a/share/newton_base/proxy/proxy_utils.py b/share/newton_base/proxy/proxy_utils.py index 28f5f3af..e82b4291 100644 --- a/share/newton_base/proxy/proxy_utils.py +++ b/share/newton_base/proxy/proxy_utils.py @@ -36,17 +36,18 @@ class ProxyUtils(object): if not content: return content + content_str = json.dumps(content) + for (servicetype, service_metadata) in metadata_catalog.items(): - real_prefix = service_metadata['prefix'] - proxy_prefix = service_metadata['proxy_prefix'] + real_prefix = service_metadata.get('prefix', None) + proxy_prefix = service_metadata.get('proxy_prefix', None) - if content: + if real_prefix and proxy_prefix: # filter the resp content and replace all endpoint prefix - tmp_content = json.dumps(content) tmp_pattern = re.compile(real_prefix+r'([^:])') - tmp_content = tmp_pattern.sub(proxy_prefix+r'\1', tmp_content) - content = json.loads(tmp_content) + content_str = tmp_pattern.sub(proxy_prefix+r'\1', content_str) + content = json.loads(content_str) return content @staticmethod diff --git a/share/newton_base/proxy/services.py b/share/newton_base/proxy/services.py index 36ae9840..631ee359 100644 --- a/share/newton_base/proxy/services.py +++ b/share/newton_base/proxy/services.py @@ -103,9 +103,8 @@ class Services(APIView): service = { 'service_type': servicetype, 'interface': interface, - 'region_id': vim['openstack_region_id'] - if vim.get('openstack_region_id') - else vim['cloud_region_id'] + 'region_name': vim['openstack_region_id'] + if vim.get('openstack_region_id') else vim['cloud_region_id'] } @@ -113,7 +112,7 @@ class Services(APIView): if querystr: req_resource += "?" + querystr - self._logger.info("service " + action + " request with uri %s" % (req_resource)) + self._logger.info("service " + action + " request with uri %s,%s" % (req_resource, service)) if(action == "get"): resp = sess.get(req_resource, endpoint_filter=service, headers={"Content-Type": "application/json", @@ -186,13 +185,13 @@ class Services(APIView): interface = 'public' service = {'service_type': servicetype, 'interface': interface, - 'region_id': vim['openstack_region_id'] + 'region_name': vim['openstack_region_id'] if vim.get('openstack_region_id') else vim['cloud_region_id'] } - self._logger.info("service head request with uri %s" % (req_resource)) + self._logger.info("service head request with uri %s, %s" % (req_resource, service)) resp = sess.head(req_resource, endpoint_filter=service) self._logger.info("service head response status %s" % (resp.status_code)) -- cgit 1.2.3-korg