def _create_keystone_client(self, args, version=None):
        from keystoneclient.auth import identity
        from keystoneclient import client
        auth_arg_list = [
            "username", "project_name", "tenant_name", "auth_url",
            "password",
        ]
        # NOTE(bigjools): If forcing a v2.0 URL then you cannot specify
        # domain-related info, or the service discovery will fail.
        if "v2.0" not in args["auth_url"] and version != "2":
            auth_arg_list.extend(
                ["user_domain_name", "domain_name", "project_domain_name"])
        auth_args = {key: args.get(key) for key in auth_arg_list}
        auth = identity.Password(**auth_args)
        session = self._get_session(auth=auth)
        args["session"] = session
        # NOTE(bigjools): When using sessions, keystoneclient no longer
        # does any pre-auth and calling client.authenticate() with
        # sessions is deprecated (it's still possible to call it but if
        # endpoint is defined it'll crash). We're forcing that pre-auth
        # here because the use of the service_catalog depends on doing
        # this. Also note that while the API has got the
        # endpoints.list() equivalent, there is no service_type in that
        # list which is why we need to ensure service_catalog is still
        # present.
        auth_ref = auth.get_access(session)
        ks = client.Client(version=version, **args)
        ks.auth_ref = auth_ref
        return ks
dataset/ETHPy150Open openstack/rally/rally/osclients.py/Keystone._create_keystone_client/original