summaryrefslogtreecommitdiff
path: root/keystoneclient/access.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-01-24 22:16:12 +0000
committerGerrit Code Review <review@openstack.org>2013-01-24 22:16:12 +0000
commit9392732a3fa00febaa90b6ad64631e1d1613e18d (patch)
treed52782348dbb2a1c0feceda7f3478248dfe53a2a /keystoneclient/access.py
parent2e0ed7fe7ba761fad32be92804db1269375a4feb (diff)
parent1f8a263fc49a7e9d2c926079f8fa106cf31bcf48 (diff)
downloadpython-keystoneclient-9392732a3fa00febaa90b6ad64631e1d1613e18d.tar.gz
Merge "Factorize endpoint retrieval in access"
Diffstat (limited to 'keystoneclient/access.py')
-rw-r--r--keystoneclient/access.py35
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')