Merge "horizon ignores region for identity service" into stable/icehouse

This commit is contained in:
Jenkins 2015-06-12 03:35:22 +00:00 committed by Gerrit Code Review
commit 3f6e9b577a
1 changed files with 23 additions and 13 deletions

View File

@ -231,19 +231,29 @@ 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
try: in the current region, it is okay to use the first endpoint for any
if identity_version < 3: identity service endpoints and we can assume that it is global
return endpoint[endpoint_type] """
else: if service['type'] == 'identity' and not available_endpoints:
interface = \ available_endpoints = [endpoint for endpoint in service['endpoints']]
ENDPOINT_TYPE_TO_INTERFACE.get(endpoint_type, '')
if endpoint['interface'] == interface: for endpoint in available_endpoints:
return endpoint['url'] try:
except (IndexError, KeyError): if identity_version < 3:
return None return endpoint[endpoint_type]
else:
interface = \
ENDPOINT_TYPE_TO_INTERFACE.get(endpoint_type, '')
if endpoint['interface'] == interface:
return endpoint['url']
except (IndexError, KeyError):
"""it could be that the current endpoint just doesn't match the
type, continue trying the next one
"""
pass
return None return None