Merge "Take region_name into account when calling url_for"

This commit is contained in:
Jenkins 2013-01-30 00:49:36 +00:00 committed by Gerrit Code Review
commit 67a6622243
1 changed files with 5 additions and 1 deletions

View File

@ -23,8 +23,9 @@ from keystoneclient import exceptions
class ServiceCatalog(object):
"""Helper methods for dealing with a Keystone Service Catalog."""
def __init__(self, resource_dict):
def __init__(self, resource_dict, region_name=None):
self.catalog = resource_dict
self.region_name = region_name
def get_token(self):
"""Fetch token details from service catalog.
@ -70,6 +71,9 @@ class ServiceCatalog(object):
endpoints = service['endpoints']
for endpoint in endpoints:
if self.region_name and \
endpoint.get('region') != self.region_name:
continue
if not filter_value or endpoint.get(attr) == filter_value:
return endpoint[endpoint_type]