diff options
author | Julien Danjou <julien@danjou.info> | 2013-01-23 15:50:00 +0100 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2013-01-24 12:27:11 +0100 |
commit | 1f8a263fc49a7e9d2c926079f8fa106cf31bcf48 (patch) | |
tree | 14c089d1f0d532f0af830beca9804f5edb8c0f6e /keystoneclient/access.py | |
parent | 3dfb8437fc9135465f2b66b2c420bf20899fcf10 (diff) | |
download | python-keystoneclient-1f8a263fc49a7e9d2c926079f8fa106cf31bcf48.tar.gz |
Factorize endpoint retrieval in access
Change-Id: Iaace7020696b238e7829dbcae60f0bc7c74a79e4
Signed-off-by: Julien Danjou <julien@danjou.info>
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 3947b6f..b5c2eb0 100644 --- a/keystoneclient/access.py +++ b/keystoneclient/access.py @@ -134,6 +134,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 @@ -143,17 +154,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): @@ -163,14 +164,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') |