Merge "Use keystoneauth1 for creating the keystone session"
This commit is contained in:
@@ -15,10 +15,10 @@
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from keystoneclient.auth.identity.generic import token
|
from keystoneauth1 import identity
|
||||||
|
from keystoneauth1 import loading as ka_loading
|
||||||
from keystoneclient import client
|
from keystoneclient import client
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
from keystoneclient import session
|
|
||||||
|
|
||||||
from cinder import db
|
from cinder import db
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
@@ -221,14 +221,17 @@ def _keystone_client(context, version=(3, 0)):
|
|||||||
:param version: version of Keystone to request
|
:param version: version of Keystone to request
|
||||||
:return: keystoneclient.client.Client object
|
:return: keystoneclient.client.Client object
|
||||||
"""
|
"""
|
||||||
auth_plugin = token.Token(
|
auth_plugin = identity.Token(
|
||||||
auth_url=CONF.keystone_authtoken.auth_uri,
|
auth_url=CONF.keystone_authtoken.auth_uri,
|
||||||
token=context.auth_token,
|
token=context.auth_token,
|
||||||
project_id=context.project_id)
|
project_id=context.project_id)
|
||||||
client_session = session.Session(auth=auth_plugin,
|
|
||||||
verify=False if
|
client_session = ka_loading.session.Session().load_from_options(
|
||||||
CONF.keystone_authtoken.insecure else
|
auth=auth_plugin,
|
||||||
(CONF.keystone_authtoken.cafile or True))
|
insecure=CONF.keystone_authtoken.insecure,
|
||||||
|
cacert=CONF.keystone_authtoken.cafile,
|
||||||
|
key=CONF.keystone_authtoken.keyfile,
|
||||||
|
cert=CONF.keystone_authtoken.certfile)
|
||||||
return client.Client(auth_url=CONF.keystone_authtoken.auth_uri,
|
return client.Client(auth_url=CONF.keystone_authtoken.auth_uri,
|
||||||
session=client_session, version=version)
|
session=client_session, version=version)
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class QuotaUtilsTest(test.TestCase):
|
|||||||
self.fixture.config(auth_uri=self.auth_url, group='keystone_authtoken')
|
self.fixture.config(auth_uri=self.auth_url, group='keystone_authtoken')
|
||||||
|
|
||||||
@mock.patch('keystoneclient.client.Client')
|
@mock.patch('keystoneclient.client.Client')
|
||||||
@mock.patch('keystoneclient.session.Session')
|
@mock.patch('keystoneauth1.session.Session')
|
||||||
def test_keystone_client_instantiation(self, ksclient_session,
|
def test_keystone_client_instantiation(self, ksclient_session,
|
||||||
ksclient_class):
|
ksclient_class):
|
||||||
quota_utils._keystone_client(self.context)
|
quota_utils._keystone_client(self.context)
|
||||||
|
|||||||
Reference in New Issue
Block a user