summaryrefslogtreecommitdiffstats
path: root/share/newton_base
diff options
context:
space:
mode:
authorXiaohua Zhang <xiaohua.zhang@windriver.com>2018-09-20 04:53:04 +0000
committerXiaohua Zhang <xiaohua.zhang@windriver.com>2018-09-20 04:53:04 +0000
commitd6d8cbf451a596aa7cbaa240fbcafb288a3494bc (patch)
treee2ccc49af7370ba9dac76dc51f873bd0b01c045b /share/newton_base
parentd6279df2157d37978895cb246b2e52cb992c3d1f (diff)
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 <xiaohua.zhang@windriver.com>
Diffstat (limited to 'share/newton_base')
-rw-r--r--share/newton_base/openoapi/flavor.py6
-rw-r--r--share/newton_base/openoapi/hosts.py2
-rwxr-xr-xshare/newton_base/openoapi/hypervisor.py2
-rw-r--r--share/newton_base/openoapi/image.py8
-rw-r--r--share/newton_base/openoapi/limits.py6
-rw-r--r--share/newton_base/openoapi/network.py6
-rw-r--r--share/newton_base/openoapi/server.py14
-rw-r--r--share/newton_base/openoapi/subnet.py6
-rw-r--r--share/newton_base/openoapi/tenants.py2
-rw-r--r--share/newton_base/openoapi/volume.py6
-rw-r--r--share/newton_base/openoapi/vport.py4
-rw-r--r--share/newton_base/proxy/dnsaasdelegate.py2
-rw-r--r--share/newton_base/proxy/identityV3.py2
-rw-r--r--share/newton_base/proxy/proxy_utils.py13
-rw-r--r--share/newton_base/proxy/services.py11
-rw-r--r--share/newton_base/registration/registration.py6
16 files changed, 48 insertions, 48 deletions
diff --git a/share/newton_base/openoapi/flavor.py b/share/newton_base/openoapi/flavor.py
index 18a13987..b0a6bf6c 100644
--- a/share/newton_base/openoapi/flavor.py
+++ b/share/newton_base/openoapi/flavor.py
@@ -64,7 +64,7 @@ class Flavors(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -192,7 +192,7 @@ class Flavors(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -338,7 +338,7 @@ class Flavors(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/hosts.py b/share/newton_base/openoapi/hosts.py
index 7a311b38..e136c400 100644
--- a/share/newton_base/openoapi/hosts.py
+++ b/share/newton_base/openoapi/hosts.py
@@ -52,7 +52,7 @@ class Hosts(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/hypervisor.py b/share/newton_base/openoapi/hypervisor.py
index bfde0f51..455bad68 100755
--- a/share/newton_base/openoapi/hypervisor.py
+++ b/share/newton_base/openoapi/hypervisor.py
@@ -72,7 +72,7 @@ class Hypervisors(APIView):
vim["domain"] = "Default"
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/image.py b/share/newton_base/openoapi/image.py
index 85615275..e40980d6 100644
--- a/share/newton_base/openoapi/image.py
+++ b/share/newton_base/openoapi/image.py
@@ -58,7 +58,7 @@ class imageThread (threading.Thread):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id']\
+ self.service['region_name'] = vim['openstack_region_id']\
if vim.get('openstack_region_id')\
else vim['cloud_region_id']
@@ -117,7 +117,7 @@ class Images(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -194,7 +194,7 @@ class Images(APIView):
#req_body = json.JSONEncoder().encode({"image": image})
req_body = json.JSONEncoder().encode(image)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -251,7 +251,7 @@ class Images(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/limits.py b/share/newton_base/openoapi/limits.py
index d260ab76..4404972e 100644
--- a/share/newton_base/openoapi/limits.py
+++ b/share/newton_base/openoapi/limits.py
@@ -49,7 +49,7 @@ class Limits(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -72,7 +72,7 @@ class Limits(APIView):
# prepare request resource to vim instance
req_resouce = "/v2.0/quotas/%s" % tenantid
- self.service_network['region_id'] = vim['openstack_region_id'] \
+ self.service_network['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -86,7 +86,7 @@ class Limits(APIView):
# prepare request resource to vim instance
req_resouce = "/limits"
- self.service_volume['region_id'] = vim['openstack_region_id'] \
+ self.service_volume['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/network.py b/share/newton_base/openoapi/network.py
index 9475ee2c..2206143a 100644
--- a/share/newton_base/openoapi/network.py
+++ b/share/newton_base/openoapi/network.py
@@ -74,7 +74,7 @@ class Networks(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -140,7 +140,7 @@ class Networks(APIView):
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"network": network})
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -187,7 +187,7 @@ class Networks(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/server.py b/share/newton_base/openoapi/server.py
index 0dd813c4..57f76196 100644
--- a/share/newton_base/openoapi/server.py
+++ b/share/newton_base/openoapi/server.py
@@ -63,7 +63,7 @@ class ServerVolumeAttachThread (threading.Thread):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -113,7 +113,7 @@ class ServerVolumeAttachThread (threading.Thread):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -167,7 +167,7 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -247,7 +247,7 @@ class Servers(APIView):
sess = VimDriverUtils.get_session(vim, tenantid)
req_resouce = "servers/%s/os-interface" % serverid
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -276,7 +276,7 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -415,7 +415,7 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -477,7 +477,7 @@ class Servers(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/subnet.py b/share/newton_base/openoapi/subnet.py
index 1d4f761b..a5cef9c7 100644
--- a/share/newton_base/openoapi/subnet.py
+++ b/share/newton_base/openoapi/subnet.py
@@ -76,7 +76,7 @@ class Subnets(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -142,7 +142,7 @@ class Subnets(APIView):
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"subnet": subnet})
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -191,7 +191,7 @@ class Subnets(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/tenants.py b/share/newton_base/openoapi/tenants.py
index a8b97464..71439411 100644
--- a/share/newton_base/openoapi/tenants.py
+++ b/share/newton_base/openoapi/tenants.py
@@ -53,7 +53,7 @@ class Tenants(APIView):
sess = VimDriverUtils.get_session(vim)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/volume.py b/share/newton_base/openoapi/volume.py
index 100d2392..70b786b1 100644
--- a/share/newton_base/openoapi/volume.py
+++ b/share/newton_base/openoapi/volume.py
@@ -77,7 +77,7 @@ class Volumes(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -143,7 +143,7 @@ class Volumes(APIView):
self.keys_mapping, True)
req_body = json.JSONEncoder().encode({"volume": volume})
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -190,7 +190,7 @@ class Volumes(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
diff --git a/share/newton_base/openoapi/vport.py b/share/newton_base/openoapi/vport.py
index 195b820b..5a799262 100644
--- a/share/newton_base/openoapi/vport.py
+++ b/share/newton_base/openoapi/vport.py
@@ -78,7 +78,7 @@ class Vports(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
@@ -219,7 +219,7 @@ class Vports(APIView):
vim = VimDriverUtils.get_vim_info(vimid)
sess = VimDriverUtils.get_session(vim, tenantid)
- self.service['region_id'] = vim['openstack_region_id'] \
+ self.service['region_name'] = vim['openstack_region_id'] \
if vim.get('openstack_region_id') \
else vim['cloud_region_id']
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))
diff --git a/share/newton_base/registration/registration.py b/share/newton_base/registration/registration.py
index 01748f8a..d5b75cf6 100644
--- a/share/newton_base/registration/registration.py
+++ b/share/newton_base/registration/registration.py
@@ -42,7 +42,7 @@ class Registry(APIView):
vimid, content_key):
service = {'service_type': service_type,
'interface': 'public',
- 'region_id': viminfo['openstack_region_id']
+ 'region_name': viminfo['openstack_region_id']
if viminfo.get('openstack_region_id')
else viminfo['cloud_region_id']}
@@ -591,7 +591,7 @@ class Registry(APIView):
req_resource = schema
service = {'service_type': "image",
'interface': 'public',
- 'region_id': viminfo['openstack_region_id']
+ 'region_name': viminfo['openstack_region_id']
if viminfo.get('openstack_region_id')
else viminfo['cloud_region_id']
}
@@ -638,7 +638,7 @@ class Registry(APIView):
req_resource = "/os-hypervisors/detail?hypervisor_hostname_pattern=%s" % k
service = {'service_type': "compute",
'interface': 'public',
- 'region_id': viminfo['openstack_region_id']
+ 'region_name': viminfo['openstack_region_id']
if viminfo.get('openstack_region_id')
else viminfo['cloud_region_id']
}