def _get_keystone_session(config, project=None):
"""Return a new keystone session based on configuration.
Arguments:
config (dict): a dictionary with the session configuration keys: ``auth_url``, ``username``, ``password``.
project (str, optional): a project to scope the session to.
Returns:
keystoneauth1.session.Session: the Keystone session scoped for the project if specified.
"""
auth = keystone_identity.Password(
auth_url='{auth_url}/v3'.format(auth_url=config.get('auth_url', 'http://localhost:5000')),
username=config.get('username', 'username'),
password=config.get('password', 'password'),
project_name=project,
user_domain_id='default',
project_domain_id='default')
return keystone_session.Session(auth=auth)
评论列表
文章目录