Using correct keyword for region in v3

Keystone v3 and v2 have different keywords in endpoint
dictionary. This patch adds ability for keystone client for correct
work with old and new API.

Change-Id: I886b4c7ac3cbe08ac1b88f490e9ca92a90256961
Closes-Bug: #1364463
This commit is contained in:
Sergey Kraynev 2014-11-21 09:57:23 -05:00
parent f82f274f6b
commit b00c073679
2 changed files with 7 additions and 2 deletions

View File

@ -28,7 +28,8 @@ class _Service(dict):
def add_endpoint(self, interface, url, region=None):
data = {'interface': interface,
'url': url,
'region': region}
'region': region,
'region_id': region}
self.setdefault('endpoints', []).append(data)
return data

View File

@ -49,6 +49,9 @@ class ServiceCatalog(object):
# to calls made to the service_catalog. Provide appropriate warning.
return self._region_name
def _get_endpoint_region(self, endpoint):
return endpoint.get('region_id') or endpoint.get('region')
@abc.abstractmethod
def get_token(self):
"""Fetch token details from service catalog.
@ -130,7 +133,8 @@ class ServiceCatalog(object):
if (endpoint_type and not
self._is_endpoint_type_match(endpoint, endpoint_type)):
continue
if region_name and region_name != endpoint.get('region'):
if (region_name and
region_name != self._get_endpoint_region(endpoint)):
continue
sc[st].append(endpoint)