diff options
author | Adam Young <ayoung@redhat.com> | 2014-07-11 20:20:50 -0500 |
---|---|---|
committer | ayoung <ayoung@redhat.com> | 2014-09-23 13:47:35 +0000 |
commit | a82d4a69219036781a276da4523bbbc242d7a50f (patch) | |
tree | 96412425ecc5a95fa222cb2e1756dc473f023a69 /keystoneclient/base.py | |
parent | 79d1eec35aad874a7c08ff22c39260884a5524ba (diff) | |
download | python-keystoneclient-a82d4a69219036781a276da4523bbbc242d7a50f.tar.gz |
Enumerate Projects with Unscoped Tokens
Creating a client with a session using an Unscoped tokens now sets auth
info in client. This Auth Info is necessary in order to enumerate
projects. This is the standard login path for Horizon.
Change-Id: I688a27cd0e7c98e7cf899ac65bb593a85171813f
Diffstat (limited to 'keystoneclient/base.py')
-rw-r--r-- | keystoneclient/base.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/keystoneclient/base.py b/keystoneclient/base.py index f94c16b..a0618f9 100644 --- a/keystoneclient/base.py +++ b/keystoneclient/base.py @@ -25,6 +25,7 @@ import functools import six from six.moves import urllib +from keystoneclient import auth from keystoneclient import exceptions from keystoneclient.openstack.common.apiclient import base @@ -337,19 +338,26 @@ class CrudManager(Manager): return self._head(self.build_url(dict_args_in_out=kwargs)) @filter_kwargs - def list(self, **kwargs): + def list(self, fallback_to_auth=False, **kwargs): url = self.build_url(dict_args_in_out=kwargs) - if kwargs: - query = '?%s' % urllib.parse.urlencode(kwargs) - else: - query = '' - return self._list( - '%(url)s%(query)s' % { - 'url': url, - 'query': query, - }, - self.collection_key) + try: + if kwargs: + query = '?%s' % urllib.parse.urlencode(kwargs) + else: + query = '' + url_query = '%(url)s%(query)s' % {'url': url, 'query': query} + return self._list( + url_query, + self.collection_key) + except exceptions.EmptyCatalog: + if fallback_to_auth: + return self._list( + url_query, + self.collection_key, + endpoint_filter={'interface': auth.AUTH_INTERFACE}) + else: + raise @filter_kwargs def put(self, **kwargs): |