Pull the endpoint from the Session
If the user passes a Session in, we can pull the endpoint to use for discovery from the Session itself, rather than erroring. Closes-Bug: #1513839 Co-Authored-By: Dolph Mathews <dolph.mathews@gmail.com> Change-Id: I82a41c67f80d2494f04739d82b112b7ff1dc4682
This commit is contained in:
parent
355e47abe1
commit
d9031c2528
|
@ -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'
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue