Example #1
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
Example #2
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
Example #3
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
Example #4
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)
Example #5
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
Example #6
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)
Example #7
0
File: nova.py Project: 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
Example #8
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
Example #9
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
Example #10
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
Example #11
0
def create_trust_for_cluster(cluster, expires=True):
    """Create a trust for a cluster

    This delegates a trust from the current user to the Sahara admin user
    based on the current context roles, and then adds the trust identifier
    to the cluster object.

    :param expires: The trust will expire if this is set to True.
    """
    ctx = context.current()
    trustor = keystone.auth()
    trustee = keystone.auth_for_admin(project_name=CONF.keystone_authtoken.admin_tenant_name)

    trust_id = create_trust(trustor=trustor, trustee=trustee, role_names=ctx.roles, expires=expires)

    conductor.cluster_update(ctx, cluster, {"trust_id": trust_id})
Example #12
0
def create_proxy_user_for_job_execution(job_execution):
    '''Creates a proxy user and adds the credentials to the job execution

    :param job_execution: The job execution model to update

    '''
    username = '******'.format(job_execution.id)
    password = key_manager.store_secret(proxy_user_create(username))
    current_user = k.auth()
    proxy_user = k.auth_for_proxy(username, password)
    trust_id = t.create_trust(trustor=current_user,
                              trustee=proxy_user,
                              role_names=CONF.proxy_user_role_names)
    update = {'job_configs': job_execution.job_configs.to_dict()}
    update['job_configs']['proxy_configs'] = {
        'proxy_username': username,
        'proxy_password': password,
        'proxy_trust_id': trust_id
        }
    conductor.job_execution_update(context.ctx(), job_execution, update)
Example #13
0
def create_proxy_user_for_job_execution(job_execution):
    '''Creates a proxy user and adds the credentials to the job execution

    :param job_execution: The job execution model to update

    '''
    username = '******'.format(job_execution.id)
    password = key_manager.store_secret(proxy_user_create(username))
    current_user = k.auth()
    proxy_user = k.auth_for_proxy(username, password)
    trust_id = t.create_trust(trustor=current_user,
                              trustee=proxy_user,
                              role_names=CONF.proxy_user_role_names)
    update = {'job_configs': job_execution.job_configs.to_dict()}
    update['job_configs']['proxy_configs'] = {
        'proxy_username': username,
        'proxy_password': password,
        'proxy_trust_id': trust_id
    }
    conductor.job_execution_update(context.ctx(), job_execution, update)
Example #14
0
def create_trust_for_cluster(cluster, expires=True):
    '''Create a trust for a cluster

    This delegates a trust from the current user to the Sahara admin user
    based on the current context roles, and then adds the trust identifier
    to the cluster object.

    :param expires: The trust will expire if this is set to True.
    '''
    ctx = context.current()
    cluster = conductor.cluster_get(ctx, cluster)
    if CONF.use_identity_api_v3 and not cluster.trust_id:
        trustor = keystone.auth()
        trustee = keystone.auth_for_admin(
            project_name=CONF.keystone_authtoken.admin_tenant_name)

        trust_id = create_trust(trustor=trustor,
                                trustee=trustee,
                                role_names=ctx.roles,
                                allow_redelegation=True)

        conductor.cluster_update(ctx, cluster, {'trust_id': trust_id})
Example #15
0
def create_proxy_user_for_cluster(cluster):
    '''Creates a proxy user and adds the credentials to the cluster

    :param cluster: The cluster model to update

    '''
    if cluster.cluster_configs.get('proxy_configs'):
        return cluster
    username = '******'.format(cluster.id)
    password = key_manager.store_secret(proxy_user_create(username))
    current_user = k.auth()
    proxy_user = k.auth_for_proxy(username, password)
    trust_id = t.create_trust(trustor=current_user,
                              trustee=proxy_user,
                              role_names=CONF.proxy_user_role_names)
    update = {'cluster_configs': cluster.cluster_configs.to_dict()}
    update['cluster_configs']['proxy_configs'] = {
        'proxy_username': username,
        'proxy_password': password,
        'proxy_trust_id': trust_id
        }
    return conductor.cluster_update(context.ctx(), cluster, update)
Example #16
0
def create_proxy_user_for_cluster(cluster):
    '''Creates a proxy user and adds the credentials to the cluster

    :param cluster: The cluster model to update

    '''
    if cluster.cluster_configs.get('proxy_configs'):
        return cluster
    username = '******'.format(cluster.id)
    password = key_manager.store_secret(proxy_user_create(username))
    current_user = k.auth()
    proxy_user = k.auth_for_proxy(username, password)
    trust_id = t.create_trust(trustor=current_user,
                              trustee=proxy_user,
                              role_names=CONF.proxy_user_role_names)
    update = {'cluster_configs': cluster.cluster_configs.to_dict()}
    update['cluster_configs']['proxy_configs'] = {
        'proxy_username': username,
        'proxy_password': password,
        'proxy_trust_id': trust_id
    }
    return conductor.cluster_update(context.ctx(), cluster, update)
Example #17
0
def create_trust_for_cluster(cluster, expires=True):
    '''Create a trust for a cluster

    This delegates a trust from the current user to the Sahara admin user
    based on the current context roles, and then adds the trust identifier
    to the cluster object.

    :param expires: The trust will expire if this is set to True.
    '''
    ctx = context.current()
    cluster = conductor.cluster_get(ctx, cluster)
    if CONF.use_identity_api_v3 and not cluster.trust_id:
        trustor = keystone.auth()
        trustee = keystone.auth_for_admin(
            project_name=CONF.keystone_authtoken.admin_tenant_name)

        trust_id = create_trust(trustor=trustor,
                                trustee=trustee,
                                role_names=ctx.roles,
                                allow_redelegation=True)

        conductor.cluster_update(ctx,
                                 cluster,
                                 {'trust_id': trust_id})
Example #18
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
Example #19
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_GLANCE)
    glance = glance_client.Client('2', session=session, auth=keystone.auth())
    return glance
Example #20
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
Example #21
0
def client():
    session = sessions.cache().get_session(sessions.SESSION_TYPE_GLANCE)
    glance = glance_client.Client('2', session=session, auth=keystone.auth())
    return glance