Set up keystone credentials. Only intended to be used within Keystone-enabled modules.

    CLI Example:

    .. code-block:: bash

        salt '*' keystone.auth

def auth(profile=None, **connection_args):
    '''
    Set up keystone credentials. Only intended to be used within Keystone-enabled modules.

    CLI Example:

    .. code-block:: bash

        salt '*' keystone.auth
    '''
    __utils__['versions.warn_until'](
        'Neon',
        (
            'The keystone module has been deprecated and will be removed in {version}.  '
            'Please update to using the keystoneng module'
        ),
    )
    kwargs = _get_kwargs(profile=profile, **connection_args)

    disc = discover.Discover(auth_url=kwargs['auth_url'])
    v2_auth_url = disc.url_for('v2.0')
    v3_auth_url = disc.url_for('v3.0')
    if v3_auth_url:
        global _OS_IDENTITY_API_VERSION
        global _TENANTS
        _OS_IDENTITY_API_VERSION = 3
        _TENANTS = 'projects'
        kwargs['auth_url'] = v3_auth_url
    else:
        kwargs['auth_url'] = v2_auth_url
        kwargs.pop('user_domain_name')
        kwargs.pop('project_domain_name')
    auth = generic.Password(**kwargs)
    sess = session.Session(auth=auth)
    ks_cl = disc.create_client(session=sess)
    return ks_cl