diff --git a/keystoneclient/auth/base.py b/keystoneclient/auth/base.py index 27faa2abc..c1cf69e0d 100644 --- a/keystoneclient/auth/base.py +++ b/keystoneclient/auth/base.py @@ -12,6 +12,7 @@ import os +from keystoneauth1 import plugin import six import stevedore @@ -21,7 +22,7 @@ from keystoneclient import exceptions # NOTE(jamielennox): The AUTH_INTERFACE is a special value that can be # requested from get_endpoint. If a plugin receives this as the value of # 'interface' it should return the initial URL that was passed to the plugin. -AUTH_INTERFACE = object() +AUTH_INTERFACE = plugin.AUTH_INTERFACE PLUGIN_NAMESPACE = 'keystoneclient.auth.plugin' IDENTITY_AUTH_HEADER_NAME = 'X-Auth-Token' diff --git a/keystoneclient/discover.py b/keystoneclient/discover.py index 62aec44d3..7bc9cbe7a 100644 --- a/keystoneclient/discover.py +++ b/keystoneclient/discover.py @@ -17,6 +17,7 @@ from debtcollector import removals import six from keystoneclient import _discover +from keystoneclient.auth import base from keystoneclient import exceptions from keystoneclient.i18n import _ from keystoneclient import session as client_session @@ -170,11 +171,14 @@ class Discover(_discover.Discover): elif auth_url: self._use_endpoint = False url = auth_url + elif session.auth: + self._use_endpoint = False + url = session.get_endpoint(interface=base.AUTH_INTERFACE) if not url: raise exceptions.DiscoveryFailure( - _('Not enough information to determine URL. Provide either ' - 'auth_url or endpoint')) + _('Not enough information to determine URL. Provide' + ' either a Session, or auth_url or endpoint')) self._client_kwargs = kwargs super(Discover, self).__init__(session, url, diff --git a/keystoneclient/tests/unit/auth/test_identity_v3.py b/keystoneclient/tests/unit/auth/test_identity_v3.py index aaae50080..f0c36af50 100644 --- a/keystoneclient/tests/unit/auth/test_identity_v3.py +++ b/keystoneclient/tests/unit/auth/test_identity_v3.py @@ -216,7 +216,7 @@ class V3IdentityPlugin(utils.TestCase): username=self.TEST_USER, password=self.TEST_PASS) s = session.Session(auth=a) - cs = client.Client(session=s, auth_url=self.TEST_URL) + cs = client.Client(session=s) # As a sanity check on the auth_ref, make sure client has the # proper user id, that it fetches the right project response diff --git a/requirements.txt b/requirements.txt index 808053d2a..9f19ff994 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ argparse Babel>=1.3 iso8601>=0.1.9 debtcollector>=0.3.0 # Apache-2.0 +keystoneauth1>=1.0.0 netaddr!=0.7.16,>=0.7.12 oslo.config>=2.3.0 # Apache-2.0 oslo.i18n>=1.5.0 # Apache-2.0