Initialize Keystone session using the new keystone package.

Change-Id: I5e9ca6201431680a65888830cffabf332fddeb1f
changes/97/641697/34
Federico Ressi 4 years ago
parent a29d930a84
commit d8b1d1b618

@ -31,14 +31,8 @@ class ClientManager(object):
def session(self):
"""Returns keystone session."""
if self._session is None:
from keystoneauth1 import loading
from keystoneauth1 import session
loader = loading.get_plugin_loader('password')
credentials = (self.credentials or
keystone.default_keystone_credentials()).to_dict()
del credentials['api_version'] # this parameter is not accepted
auth = loader.load_from_options(**credentials)
self._session = session.Session(auth=auth, verify=False)
self._session = keystone.get_keystone_session(
credentials=self.credentials)
return self._session
@property

@ -23,3 +23,4 @@ InvalidKeystoneCredentials = credentials.InvalidKeystoneCredentials
KeystoneSessionFixture = session.KeystoneSessionFixture
KeystoneSessionManager = session.KeystoneSessionManager
get_keystone_session = session.get_keystone_session

@ -87,3 +87,11 @@ class KeystoneSessionManager(object):
SESSIONS = KeystoneSessionManager()
def get_keystone_session(credentials=None, shared=True, init_session=None,
manager=None):
manager = manager or SESSIONS
session = manager.get_session(credentials=credentials, shared=shared,
init_session=init_session)
return tobiko.setup_fixture(session).session

Loading…
Cancel
Save