diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-01-24 22:16:12 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-01-24 22:16:12 +0000 |
commit | 9392732a3fa00febaa90b6ad64631e1d1613e18d (patch) | |
tree | d52782348dbb2a1c0feceda7f3478248dfe53a2a /keystoneclient/access.py | |
parent | 2e0ed7fe7ba761fad32be92804db1269375a4feb (diff) | |
parent | 1f8a263fc49a7e9d2c926079f8fa106cf31bcf48 (diff) | |
download | python-keystoneclient-9392732a3fa00febaa90b6ad64631e1d1613e18d.tar.gz |
Merge "Factorize endpoint retrieval in access"
Diffstat (limited to 'keystoneclient/access.py')
-rw-r--r-- | keystoneclient/access.py | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/keystoneclient/access.py b/keystoneclient/access.py index c17ee2e..8346358 100644 --- a/keystoneclient/access.py +++ b/keystoneclient/access.py @@ -131,6 +131,17 @@ class AccessInfo(dict): """ Synonym for project_id """ return self.tenant_id + def _get_identity_endpoint(self, endpoint_type): + if not self.get('serviceCatalog'): + return + + identity_services = [x for x in self['serviceCatalog'] + if x['type'] == 'identity'] + return tuple(endpoint[endpoint_type] + for svc in identity_services + for endpoint in svc['endpoints'] + if endpoint_type in endpoint) + @property def auth_url(self): """ Returns a tuple of URLs from publicURL and adminURL for the service @@ -140,17 +151,7 @@ class AccessInfo(dict): :returns: tuple of urls """ - return_list = [] - if 'serviceCatalog' in self and self['serviceCatalog']: - identity_services = [x for x in self['serviceCatalog'] - if x['type'] == 'identity'] - for svc in identity_services: - for endpoint in svc['endpoints']: - if 'publicURL' in endpoint: - return_list.append(endpoint['publicURL']) - if len(return_list) > 0: - return tuple(return_list) - return None + return self._get_identity_endpoint('publicURL') @property def management_url(self): @@ -160,14 +161,4 @@ class AccessInfo(dict): :returns: tuple of urls """ - return_list = [] - if 'serviceCatalog' in self and self['serviceCatalog']: - identity_services = [x for x in self['serviceCatalog'] - if x['type'] == 'identity'] - for svc in identity_services: - for endpoint in svc['endpoints']: - if 'adminURL' in endpoint: - return_list.append(endpoint['adminURL']) - if len(return_list) > 0: - return tuple(return_list) - return None + return self._get_identity_endpoint('adminURL') |