コード例 #1
0
ファイル: keystone.py プロジェクト: uladz/sahara
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
ファイル: keystone.py プロジェクト: masafumiohta/sahara
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
ファイル: neutron.py プロジェクト: uladz/sahara
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
ファイル: neutron.py プロジェクト: gongwayne/Openstack
 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
ファイル: cinder.py プロジェクト: msionkin/sahara
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
ファイル: nova.py プロジェクト: Akanksha08/sahara
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
ファイル: heat.py プロジェクト: openstack/sahara
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
ファイル: context.py プロジェクト: uladz/sahara
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
ファイル: nova.py プロジェクト: mastermind1981/sahara-1
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
ファイル: keystone.py プロジェクト: wuhsh/sahara
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
ファイル: keystone.py プロジェクト: msionkin/sahara
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
ファイル: nova.py プロジェクト: uladz/sahara
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
ファイル: neutron.py プロジェクト: Chinmoy-Dey/sahara
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
ファイル: keystone.py プロジェクト: uladz/sahara
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
ファイル: keystone.py プロジェクト: uladz/sahara
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
ファイル: keystone.py プロジェクト: wuhsh/sahara
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
ファイル: keystone.py プロジェクト: wuhsh/sahara
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
ファイル: neutron.py プロジェクト: madar010/mad
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
ファイル: keystone.py プロジェクト: msionkin/sahara
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
ファイル: cinder.py プロジェクト: uladz/sahara
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
ファイル: keystone.py プロジェクト: wuhsh/sahara
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
ファイル: keystone.py プロジェクト: uladz/sahara
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
ファイル: keystone.py プロジェクト: wuhsh/sahara
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
ファイル: glance.py プロジェクト: openstack/sahara
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
ファイル: glance.py プロジェクト: Chinmoy-Dey/sahara
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
ファイル: neutron.py プロジェクト: crobby/sahara
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
ファイル: glance.py プロジェクト: yonglehou/sahara
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_GLANCE)
    glance = glance_client.Client('2', session=session, auth=keystone.auth())
    return glance