horizon ignores region for identity service
this change will attempt to use a identity service in the selected region when available. before the region for the identity service was always the first found Change-Id: Idc64a32128bcee561cdbba956722adad0ee1eaf2 Closes-Bug: #1339382
This commit is contained in:
parent
bd998fb609
commit
88371c6660
@ -235,9 +235,16 @@ ENDPOINT_TYPE_TO_INTERFACE = {
|
|||||||
|
|
||||||
def get_url_for_service(service, region, endpoint_type):
|
def get_url_for_service(service, region, endpoint_type):
|
||||||
identity_version = get_version_from_service(service)
|
identity_version = get_version_from_service(service)
|
||||||
for endpoint in service['endpoints']:
|
available_endpoints = [endpoint for endpoint in service['endpoints']
|
||||||
# ignore region for identity
|
if region == endpoint['region']]
|
||||||
if service['type'] == 'identity' or region == endpoint['region']:
|
"""if we are dealing with the identity service and there is no endpoint
|
||||||
|
in the current region, it is okay to use the first endpoint for any
|
||||||
|
identity service endpoints and we can assume that it is global
|
||||||
|
"""
|
||||||
|
if service['type'] == 'identity' and not available_endpoints:
|
||||||
|
available_endpoints = [endpoint for endpoint in service['endpoints']]
|
||||||
|
|
||||||
|
for endpoint in available_endpoints:
|
||||||
try:
|
try:
|
||||||
if identity_version < 3:
|
if identity_version < 3:
|
||||||
return endpoint[endpoint_type]
|
return endpoint[endpoint_type]
|
||||||
@ -247,7 +254,10 @@ def get_url_for_service(service, region, endpoint_type):
|
|||||||
if endpoint['interface'] == interface:
|
if endpoint['interface'] == interface:
|
||||||
return endpoint['url']
|
return endpoint['url']
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
return None
|
"""it could be that the current endpoint just doesn't match the
|
||||||
|
type, continue trying the next one
|
||||||
|
"""
|
||||||
|
pass
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user