Пример #1
0
def service_catalog_from_auth(auth):
    '''Return the service catalog associated with an auth plugin.

    :param auth: the auth plugin to inspect.

    :returns: a list containing the service catalog.
    '''
    if CONF.use_identity_api_v3:
        return auth.get_access(
            sessions.cache().get_session()).get('catalog', [])
    else:
        return auth.get_access(
            sessions.cache().get_session()).get('serviceCatalog', [])
Пример #2
0
def service_catalog_from_auth(auth):
    '''Return the service catalog associated with an auth plugin.

    :param auth: the auth plugin to inspect.

    :returns: a list containing the service catalog.
    '''
    if CONF.use_identity_api_v3:
        return auth.get_access(
            sessions.cache().get_session()).get('catalog', [])
    else:
        return auth.get_access(
            sessions.cache().get_session()).get('serviceCatalog', [])
Пример #3
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_NEUTRON)
    neutron = neutron_cli.Client('2.0',
                                 session=session,
                                 auth=keystone.auth(),
                                 endpoint_type=CONF.neutron.endpoint_type)
    return neutron
Пример #4
0
 def __init__(self, network, token, tenant_name, auth=None):
     session = sessions.cache().get_session(sessions.SESSION_TYPE_NEUTRON)
     if auth is None:
         auth = keystone.token_auth(token=token, project_name=tenant_name)
     self.neutron = neutron_cli.Client('2.0', session=session, auth=auth,
                                       region_name=CONF.os_region_name)
     self.network = network
Пример #5
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_CINDER)
    cinder = cinder_client_v2.Client(
        session=session, auth=keystone.auth(),
        endpoint_type=CONF.cinder.endpoint_type,
        region_name=CONF.os_region_name)
    return cinder
Пример #6
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_NOVA)
    nova = nova_client.Client('2', session=session, auth=keystone.auth(),
                              endpoint_type=CONF.nova.endpoint_type,
                              region_name=CONF.os_region_name)
    nova.images = images.SaharaImageManager(nova)
    return nova
Пример #7
0
def client():
    ctx = context.ctx()
    session = sessions.cache().get_heat_session()
    heat_url = base.url_for(ctx.service_catalog, 'orchestration',
                            endpoint_type=CONF.heat.endpoint_type)
    return heat_client.Client(
        '1', endpoint=heat_url, session=session, auth=keystone.auth(),
        region_name=CONF.os_region_name)
Пример #8
0
def get_auth_token():
    cur = current()
    if cur.auth_plugin:
        try:
            cur.auth_token = sessions.cache().token_for_auth(cur.auth_plugin)
        except Exception as e:
            LOG.warning(_LW("Cannot update token, reason: {reason}"), e)
    return cur.auth_token
Пример #9
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_NOVA)
    nova = nova_client.Client('2',
                              session=session,
                              auth=keystone.auth(),
                              endpoint_type=CONF.nova.endpoint_type,
                              region_name=CONF.os_region_name)
    return nova
Пример #10
0
def token_from_auth(auth):
    '''Return an authentication token from an auth plugin.

    :param auth: the auth plugin to acquire a token from.

    :returns: an auth token in string format.
    '''
    return sessions.cache().token_for_auth(auth)
Пример #11
0
def token_from_auth(auth):
    '''Return an authentication token from an auth plugin.

    :param auth: the auth plugin to acquire a token from.

    :returns: an auth token in string format.
    '''
    return sessions.cache().token_for_auth(auth)
Пример #12
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_NOVA)
    nova = nova_client.Client('2',
                              session=session,
                              auth=keystone.auth(),
                              endpoint_type=CONF.nova.endpoint_type)
    nova.images = images.SaharaImageManager(nova)
    return nova
Пример #13
0
def client(auth=None):
    if not auth:
        auth = keystone.auth()
    session = sessions.cache().get_session(sessions.SESSION_TYPE_NEUTRON)
    neutron = neutron_cli.Client(
        "2.0", session=session, auth=auth, endpoint_type=CONF.neutron.endpoint_type, region_name=CONF.os_region_name
    )
    return neutron
Пример #14
0
def client():
    ctx = context.ctx()
    session = sessions.cache().get_heat_session()
    heat_url = base.url_for(ctx.service_catalog, 'orchestration',
                            endpoint_type=CONF.heat.endpoint_type)
    return heat_client.Client(
        '1', endpoint=heat_url, session=session, auth=keystone.auth(),
        region_name=CONF.os_region_name)
Пример #15
0
def user_id_from_auth(auth):
    '''Return a user id associated with an auth plugin.

    :param auth: the auth plugin to inspect.

    :returns: a token associated with the auth.
    '''
    return auth.get_user_id(sessions.cache().get_session(
        sessions.SESSION_TYPE_KEYSTONE))
Пример #16
0
def project_id_from_auth(auth):
    '''Return the project id associated with an auth plugin.

    :param auth: the auth plugin to inspect.

    :returns: the project id associated with the auth plugin.
    '''
    return auth.get_project_id(
        sessions.cache().get_session(sessions.SESSION_TYPE_KEYSTONE))
Пример #17
0
def user_id_from_auth(auth):
    '''Return a user id associated with an auth plugin.

    :param auth: the auth plugin to inspect.

    :returns: a token associated with the auth.
    '''
    return auth.get_user_id(sessions.cache().get_session(
        sessions.SESSION_TYPE_KEYSTONE))
Пример #18
0
 def __init__(self, network, token, tenant_name, auth=None):
     session = sessions.cache().get_session(sessions.SESSION_TYPE_NEUTRON)
     if auth is None:
         auth = keystone.token_auth(token=token, project_name=tenant_name)
     self.neutron = neutron_cli.Client('2.0',
                                       session=session,
                                       auth=auth,
                                       region_name=CONF.os_region_name)
     self.network = network
Пример #19
0
def project_id_from_auth(auth):
    '''Return the project id associated with an auth plugin.

    :param auth: the auth plugin to inspect.

    :returns: the project id associated with the auth plugin.
    '''
    return auth.get_project_id(sessions.cache().get_session(
        sessions.SESSION_TYPE_KEYSTONE))
Пример #20
0
def client(auth=None):
    if not auth:
        auth = keystone.auth()
    session = sessions.cache().get_session(sessions.SESSION_TYPE_NEUTRON)
    neutron = neutron_cli.Client('2.0',
                                 session=session,
                                 auth=auth,
                                 endpoint_type=CONF.neutron.endpoint_type,
                                 region_name=CONF.os_region_name)
    return neutron
Пример #21
0
def service_catalog_from_auth(auth):
    '''Return the service catalog associated with an auth plugin.

    :param auth: the auth plugin to inspect.

    :returns: a list containing the service catalog.
    '''
    access_info = auth.get_access(
        sessions.cache().get_session(sessions.SESSION_TYPE_KEYSTONE))
    if access_info.has_service_catalog():
        return access_info.service_catalog.catalog
    else:
        return []
Пример #22
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_CINDER)
    auth = keystone.auth()

    if CONF.cinder.api_version == 1:
        cinder = cinder_client_v1.Client(
            session=session, auth=auth,
            endpoint_type=CONF.cinder.endpoint_type)
    else:
        cinder = cinder_client_v2.Client(
            session=session, auth=auth,
            endpoint_type=CONF.cinder.endpoint_type)
    return cinder
Пример #23
0
def service_catalog_from_auth(auth):
    '''Return the service catalog associated with an auth plugin.

    :param auth: the auth plugin to inspect.

    :returns: a list containing the service catalog.
    '''
    access_info = auth.get_access(sessions.cache().get_session(
        sessions.SESSION_TYPE_KEYSTONE))
    if access_info.has_service_catalog():
        return access_info.service_catalog.catalog
    else:
        return []
Пример #24
0
def client_from_auth(auth):
    '''Return a session based client from the auth plugin provided.

    A session is obtained from the global session cache.

    :param auth: the auth plugin object to use in client creation.

    :returns: a keystone client
    '''
    session = sessions.cache().get_session(sessions.SESSION_TYPE_KEYSTONE)
    if CONF.use_identity_api_v3:
        client_class = keystone_client_v3.Client
    else:
        client_class = keystone_client.Client
    return client_class(session=session, auth=auth)
Пример #25
0
def client_from_auth(auth):
    '''Return a session based client from the auth plugin provided.

    A session is obtained from the global session cache.

    :param auth: the auth plugin object to use in client creation.

    :returns: a keystone client
    '''
    session = sessions.cache().get_session(sessions.SESSION_TYPE_KEYSTONE)
    if CONF.use_identity_api_v3:
        client_class = keystone_client_v3.Client
    else:
        client_class = keystone_client.Client
    return client_class(session=session, auth=auth)
Пример #26
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_GLANCE)
    glance = glance_client.Client('2', session=session, auth=keystone.auth(),
                                  interface=CONF.glance.endpoint_type)
    return glance
Пример #27
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_GLANCE)
    glance = glance_client.Client('2', session=session, auth=keystone.auth())
    return glance
Пример #28
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_NEUTRON)
    neutron = neutron_cli.Client('2.0', session=session, auth=keystone.auth(),
                                 endpoint_type=CONF.neutron.endpoint_type)
    return neutron
Пример #29
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_GLANCE)
    glance = glance_client.Client('2', session=session, auth=keystone.auth())
    return glance