summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-06-12 03:35:22 +0000
committerGerrit Code Review <review@openstack.org>2015-06-12 03:35:22 +0000
commit3f6e9b577aa3253a3114ff0eb7c49f83e45154ae (patch)
tree14148fe5b30bad2ffbebfe8aad46f59d4a5e8c91
parent78b6f5ed6145dcb2e9ce2caed0c87d159c12697b (diff)
parent4ff165c90b42b522b884382152d296b00473a99c (diff)
downloadhorizon-stable/icehouse.tar.gz
Merge "horizon ignores region for identity service" into stable/icehouseicehouse-eol2014.1.5stable/icehouse
-rw-r--r--openstack_dashboard/api/base.py36
1 files changed, 23 insertions, 13 deletions
diff --git a/openstack_dashboard/api/base.py b/openstack_dashboard/api/base.py
index e1d034815..6a836df69 100644
--- a/openstack_dashboard/api/base.py
+++ b/openstack_dashboard/api/base.py
@@ -231,19 +231,29 @@ ENDPOINT_TYPE_TO_INTERFACE = {
def get_url_for_service(service, region, endpoint_type):
identity_version = get_version_from_service(service)
- for endpoint in service['endpoints']:
- # ignore region for identity
- if service['type'] == 'identity' or region == endpoint['region']:
- try:
- if identity_version < 3:
- return endpoint[endpoint_type]
- else:
- interface = \
- ENDPOINT_TYPE_TO_INTERFACE.get(endpoint_type, '')
- if endpoint['interface'] == interface:
- return endpoint['url']
- except (IndexError, KeyError):
- return None
+ available_endpoints = [endpoint for endpoint in service['endpoints']
+ if 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:
+ if identity_version < 3:
+ 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