Ejemplo n.º 1
0
def retrieve_preauth_url():
    '''This function returns the storage URL for Swift in the current project.

    :returns: The storage URL for the current project's Swift store, or None
              if it can't be found.

    '''
    client = k.client()
    catalog = client.service_catalog.get_endpoints('object-store')
    for ep in catalog.get('object-store'):
        if ep.get('interface') == 'public':
            return ep.get('url')
    return None
Ejemplo n.º 2
0
def create_trust(cluster):
    client = keystone.client()

    ctx = context.current()

    trustee_id = keystone.client_for_admin().user_id

    trust = client.trusts.create(trustor_user=client.user_id,
                                 trustee_user=trustee_id,
                                 impersonation=True,
                                 role_names=ctx.roles,
                                 project=client.tenant_id)
    conductor.cluster_update(ctx, cluster, {'trust_id': trust.id})
Ejemplo n.º 3
0
def retrieve_preauth_url():
    '''This function returns the storage URL for Swift in the current project.

    :returns: The storage URL for the current project's Swift store, or None
              if it can't be found.

    '''
    client = k.client()
    catalog = client.service_catalog.get_endpoints('object-store')
    for ep in catalog.get('object-store'):
        if ep.get('interface') == 'public':
            return ep.get('url')
    return None
Ejemplo n.º 4
0
def create_trust(cluster):
    client = keystone.client()

    ctx = context.current()

    trustee_id = keystone.client_for_admin().user_id

    trust = client.trusts.create(
        trustor_user=client.user_id,
        trustee_user=trustee_id,
        impersonation=True,
        role_names=ctx.roles,
        project=client.tenant_id,
    )
    conductor.cluster_update(ctx, cluster, {"trust_id": trust.id})
Ejemplo n.º 5
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.
    """
    trustor = keystone.client()
    ctx = context.current()
    trustee = keystone.client_for_admin()

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

    conductor.cluster_update(ctx, cluster, {"trust_id": trust_id})
Ejemplo n.º 6
0
def create_trust_for_cluster(cluster):
    '''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.

    '''
    trustor = keystone.client()
    ctx = context.current()
    trustee = keystone.client_for_admin()

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

    conductor.cluster_update(ctx, cluster, {'trust_id': trust_id})
Ejemplo n.º 7
0
def create_trust_for_cluster(cluster):
    '''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.

    '''
    trustor = keystone.client()
    ctx = context.current()
    trustee = keystone.client_for_admin()

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

    conductor.cluster_update(ctx,
                             cluster,
                             {'trust_id': trust_id})
Ejemplo n.º 8
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 = proxy_user_create(username)
    current_user = k.client()
    proxy_user = k.client_for_proxy_user(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)
Ejemplo n.º 9
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 = proxy_user_create(username)
    current_user = k.client()
    proxy_user = k.client_for_proxy_user(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)
Ejemplo n.º 10
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 = proxy_user_create(username)
    current_user = k.client()
    proxy_user = k.client_for_proxy_user(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)
Ejemplo n.º 11
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 = proxy_user_create(username)
    current_user = k.client()
    proxy_user = k.client_for_proxy_user(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)
Ejemplo n.º 12
0
def check_cinder_exists():
    services = [service.name for service in
                keystone.client().services.list()]
    if 'cinder' not in services:
        raise ex.InvalidException("Cinder is not supported")
Ejemplo n.º 13
0
def check_cinder_exists():
    services = [service.name for service in keystone.client().services.list()]
    if 'cinder' not in services:
        raise ex.InvalidException("Cinder is not supported")