Ejemplo n.º 1
0
def get_session_and_auth(context, **kwargs):
    """Get session and auth parameters

    :param context: action context
    :return: dict to be used as kwargs for client serviceinitialization
    """

    if not context:
        raise AssertionError('context is mandatory')

    project_endpoint = get_endpoint_for_project(**kwargs)
    endpoint = format_url(
        project_endpoint.url,
        {
            'tenant_id': context.project_id,
            'project_id': context.project_id
        }
    )

    auth = Token(endpoint=endpoint, token=context.auth_token)

    auth_uri = context.auth_uri or CONF.keystone_authtoken.auth_uri
    ks_auth = Token(
        endpoint=auth_uri,
        token=context.auth_token
    )
    session = ks_session.Session(
        auth=ks_auth,
        verify=_determine_verify(context)
    )

    return {
        "session": session,
        "auth": auth
    }
Ejemplo n.º 2
0
    def get_baremetal_introspection_client(self, context):
        bmi_endpoint = keystone_utils.get_endpoint_for_project(
            context, 'ironic-inspector')

        auth = Token(endpoint=bmi_endpoint.url, token=context.auth_token)

        return ironic_inspector_client.ClientV1(
            api_version='1.2',
            region_name=bmi_endpoint.region,
            session=ks_session.Session(auth))
Ejemplo n.º 3
0
    def _create_client(self, context):
        LOG.debug("Baremetal introspection action security context: %s",
                  context)

        inspector_endpoint = keystone_utils.get_endpoint_for_project(
            service_type='baremetal-introspection')
        auth = Token(endpoint=inspector_endpoint.url, token=context.auth_token)

        return self._get_client_class()(api_version=1,
                                        session=ks_session.Session(auth))
Ejemplo n.º 4
0
def get_session_and_auth(context, **kwargs):
    """Get session and auth parameters

    :param context: action context
    :return: dict to be used as kwargs for client serviceinitialization
    """

    if not context:
        raise AssertionError('context is mandatory')

    if context.trust_id:
        kwargs['project_name'] = None
        kwargs['project_domain_name'] = None
        kwargs['project_id'] = None
        kwargs['trust_id'] = context.trust_id
        kwargs.pop('service_name')

        auth = loading.load_auth_from_conf_options(CONF, 'keystone_authtoken',
                                                   **kwargs)
        session = loading.load_session_from_conf_options(CONF,
                                                         'keystone',
                                                         auth=auth)
    else:
        project_endpoint = get_endpoint_for_project(context, **kwargs)
        endpoint = format_url(project_endpoint.url, {
            'tenant_id': context.project_id,
            'project_id': context.project_id
        })

        auth = Token(endpoint=endpoint, token=context.auth_token)

        auth_uri = context.auth_uri or CONF.keystone_authtoken.auth_uri
        ks_auth = Token(endpoint=auth_uri, token=context.auth_token)
        session = ks_session.Session(auth=ks_auth,
                                     verify=_determine_verify(context))

    return {"session": session, "auth": auth}
Ejemplo n.º 5
0
def get_session(ctx):
    """Get session and auth parameters.

    :param ctx: action context
    :return: session object for dns service
    """

    if not ctx:
        raise AssertionError('context is mandatory')

    endpoint = get_endpoint(version='v2')

    auth = Token(endpoint=endpoint, token=ctx.auth_token)

    session = ks_session.Session(
        auth=auth,
        verify=_determine_verify(ctx)
    )

    return session