Ejemplo n.º 1
0
Archivo: api.py Proyecto: crobby/sahara
def job_binary_internal_destroy(context, job_binary_internal_id):
    session = get_session()
    with session.begin():
        job_binary_internal = _job_binary_internal_get(context, session,
                                                       job_binary_internal_id)
        if not job_binary_internal:
            raise ex.NotFoundException(
                job_binary_internal_id,
                _("JobBinaryInternal id '%s' not found!"))

        validate.check_tenant_for_delete(context, job_binary_internal)
        validate.check_protected_from_delete(job_binary_internal)

        session.delete(job_binary_internal)
Ejemplo n.º 2
0
def job_binary_internal_destroy(context, job_binary_internal_id):
    session = get_session()
    with session.begin():
        job_binary_internal = _job_binary_internal_get(context, session,
                                                       job_binary_internal_id)
        if not job_binary_internal:
            raise ex.NotFoundException(
                job_binary_internal_id,
                _("JobBinaryInternal id '%s' not found!"))

        validate.check_tenant_for_delete(context, job_binary_internal)
        validate.check_protected_from_delete(job_binary_internal)

        session.delete(job_binary_internal)
Ejemplo n.º 3
0
def cluster_template_destroy(context,
                             cluster_template_id,
                             ignore_prot_on_def=False):
    session = get_session()
    with session.begin():
        cluster_template = _cluster_template_get(context, session,
                                                 cluster_template_id)
        if not cluster_template:
            raise ex.NotFoundException(
                cluster_template_id, _("Cluster Template id '%s' not found!"))

        validate.check_tenant_for_delete(context, cluster_template)
        if not (cluster_template.is_default and ignore_prot_on_def):
            validate.check_protected_from_delete(cluster_template)

        session.delete(cluster_template)
Ejemplo n.º 4
0
def job_binary_destroy(context, job_binary_id):
    session = get_session()
    with session.begin():
        job_binary = _job_binary_get(context, session, job_binary_id)
        if not job_binary:
            raise ex.NotFoundException(job_binary_id,
                                       _("JobBinary id '%s' not found!"))

        validate.check_tenant_for_delete(context, job_binary)
        validate.check_protected_from_delete(job_binary)

        if _check_job_binary_referenced(context, session, job_binary_id):
            raise ex.DeletionFailed(
                _("JobBinary is referenced and cannot be deleted"))

        session.delete(job_binary)
Ejemplo n.º 5
0
def job_destroy(context, job_id):
    session = get_session()
    try:
        with session.begin():
            job = _job_get(context, session, job_id)
            if not job:
                raise ex.NotFoundException(job_id, _("Job id '%s' not found!"))

            validate.check_tenant_for_delete(context, job)
            validate.check_protected_from_delete(job)

            session.delete(job)
    except db_exc.DBError as e:
        msg = ("foreign key constraint" in six.text_type(e)
               and _(" on foreign key constraint") or "")
        raise ex.DeletionFailed(_("Job deletion failed%s") % msg)
Ejemplo n.º 6
0
def node_group_template_destroy(context, node_group_template_id,
                                ignore_prot_on_def=False):
    session = get_session()
    with session.begin():
        node_group_template = _node_group_template_get(context, session,
                                                       node_group_template_id)
        if not node_group_template:
            raise ex.NotFoundException(
                node_group_template_id,
                _("Node Group Template id '%s' not found!"))

        validate.check_tenant_for_delete(context, node_group_template)
        if not (node_group_template.is_default and ignore_prot_on_def):
            validate.check_protected_from_delete(node_group_template)

        session.delete(node_group_template)
Ejemplo n.º 7
0
def cluster_template_destroy(context, cluster_template_id,
                             ignore_prot_on_def=False):
    session = get_session()
    with session.begin():
        cluster_template = _cluster_template_get(context, session,
                                                 cluster_template_id)
        if not cluster_template:
            raise ex.NotFoundException(
                cluster_template_id,
                _("Cluster Template id '%s' not found!"))

        validate.check_tenant_for_delete(context, cluster_template)
        if not (cluster_template.is_default and ignore_prot_on_def):
            validate.check_protected_from_delete(cluster_template)

        session.delete(cluster_template)
Ejemplo n.º 8
0
Archivo: api.py Proyecto: crobby/sahara
def job_binary_destroy(context, job_binary_id):
    session = get_session()
    with session.begin():
        job_binary = _job_binary_get(context, session, job_binary_id)
        if not job_binary:
            raise ex.NotFoundException(job_binary_id,
                                       _("JobBinary id '%s' not found!"))

        validate.check_tenant_for_delete(context, job_binary)
        validate.check_protected_from_delete(job_binary)

        if _check_job_binary_referenced(context, session, job_binary_id):
            raise ex.DeletionFailed(
                _("JobBinary is referenced and cannot be deleted"))

        session.delete(job_binary)
Ejemplo n.º 9
0
def data_source_destroy(context, data_source_id):
    session = get_session()
    try:
        with session.begin():
            data_source = _data_source_get(context, session, data_source_id)
            if not data_source:
                raise ex.NotFoundException(data_source_id,
                                           _("Data Source id '%s' not found!"))

            validate.check_tenant_for_delete(context, data_source)
            validate.check_protected_from_delete(data_source)

            session.delete(data_source)
    except db_exc.DBError as e:
        msg = ("foreign key constraint" in six.text_type(e)
               and _(" on foreign key constraint") or "")
        raise ex.DeletionFailed(_("Data Source deletion failed%s") % msg)
Ejemplo n.º 10
0
def node_group_template_destroy(context,
                                node_group_template_id,
                                ignore_prot_on_def=False):
    session = get_session()
    with session.begin():
        node_group_template = _node_group_template_get(context, session,
                                                       node_group_template_id)
        if not node_group_template:
            raise ex.NotFoundException(
                node_group_template_id,
                _("Node Group Template id '%s' not found!"))

        validate.check_tenant_for_delete(context, node_group_template)
        if not (node_group_template.is_default and ignore_prot_on_def):
            validate.check_protected_from_delete(node_group_template)

        session.delete(node_group_template)
Ejemplo n.º 11
0
Archivo: api.py Proyecto: crobby/sahara
def job_destroy(context, job_id):
    session = get_session()
    try:
        with session.begin():
            job = _job_get(context, session, job_id)
            if not job:
                raise ex.NotFoundException(job_id,
                                           _("Job id '%s' not found!"))

            validate.check_tenant_for_delete(context, job)
            validate.check_protected_from_delete(job)

            session.delete(job)
    except db_exc.DBError as e:
        msg = ("foreign key constraint" in six.text_type(e) and
               _(" on foreign key constraint") or "")
        raise ex.DeletionFailed(_("Job deletion failed%s") % msg)
Ejemplo n.º 12
0
Archivo: api.py Proyecto: crobby/sahara
def data_source_destroy(context, data_source_id):
    session = get_session()
    try:
        with session.begin():
            data_source = _data_source_get(context, session, data_source_id)
            if not data_source:
                raise ex.NotFoundException(
                    data_source_id,
                    _("Data Source id '%s' not found!"))

            validate.check_tenant_for_delete(context, data_source)
            validate.check_protected_from_delete(data_source)

            session.delete(data_source)
    except db_exc.DBError as e:
        msg = ("foreign key constraint" in six.text_type(e) and
               _(" on foreign key constraint") or "")
        raise ex.DeletionFailed(_("Data Source deletion failed%s") % msg)
Ejemplo n.º 13
0
Archivo: api.py Proyecto: crobby/sahara
def node_group_template_destroy(context, node_group_template_id,
                                ignore_default=False):
    session = get_session()
    with session.begin():
        node_group_template = _node_group_template_get(context, session,
                                                       node_group_template_id)
        if not node_group_template:
            raise ex.NotFoundException(
                node_group_template_id,
                _("Node Group Template id '%s' not found!"))
        elif not ignore_default and node_group_template.is_default:
            raise ex.DeletionFailed(
                _("Node group template id '%s' "
                  "is a default template") % node_group_template_id)

        validate.check_tenant_for_delete(context, node_group_template)
        validate.check_protected_from_delete(node_group_template)

        session.delete(node_group_template)
Ejemplo n.º 14
0
Archivo: api.py Proyecto: crobby/sahara
def cluster_template_destroy(context, cluster_template_id,
                             ignore_default=False):
    session = get_session()
    with session.begin():
        cluster_template = _cluster_template_get(context, session,
                                                 cluster_template_id)
        if not cluster_template:
            raise ex.NotFoundException(
                cluster_template_id,
                _("Cluster Template id '%s' not found!"))
        elif not ignore_default and cluster_template.is_default:
            raise ex.DeletionFailed(
                _("Cluster template id '%s' "
                  "is a default template") % cluster_template.id)

        validate.check_tenant_for_delete(context, cluster_template)
        validate.check_protected_from_delete(cluster_template)

        session.delete(cluster_template)
Ejemplo n.º 15
0
Archivo: api.py Proyecto: uladz/sahara
def node_group_template_destroy(context, node_group_template_id,
                                ignore_default=False):
    session = get_session()
    with session.begin():
        node_group_template = _node_group_template_get(context, session,
                                                       node_group_template_id)
        if not node_group_template:
            raise ex.NotFoundException(
                node_group_template_id,
                _("Node Group Template id '%s' not found!"))
        elif not ignore_default and node_group_template.is_default:
            raise ex.DeletionFailed(
                _("Node group template id '%s' "
                  "is a default template") % node_group_template_id)

        validate.check_tenant_for_delete(context, node_group_template)
        validate.check_protected_from_delete(node_group_template)

        session.delete(node_group_template)
Ejemplo n.º 16
0
Archivo: api.py Proyecto: uladz/sahara
def cluster_template_destroy(context, cluster_template_id,
                             ignore_default=False):
    session = get_session()
    with session.begin():
        cluster_template = _cluster_template_get(context, session,
                                                 cluster_template_id)
        if not cluster_template:
            raise ex.NotFoundException(
                cluster_template_id,
                _("Cluster Template id '%s' not found!"))
        elif not ignore_default and cluster_template.is_default:
            raise ex.DeletionFailed(
                _("Cluster template id '%s' "
                  "is a default template") % cluster_template.id)

        validate.check_tenant_for_delete(context, cluster_template)
        validate.check_protected_from_delete(cluster_template)

        session.delete(cluster_template)
Ejemplo n.º 17
0
def check_cluster_delete(cluster_id, **kwargs):
    cluster = api.get_cluster(cluster_id)

    acl.check_tenant_for_delete(context.current(), cluster)
    acl.check_protected_from_delete(cluster)
Ejemplo n.º 18
0
def check_cluster_delete(cluster_id, **kwargs):
    cluster = api.get_cluster(cluster_id)

    acl.check_tenant_for_delete(context.current(), cluster)
    acl.check_protected_from_delete(cluster)
Ejemplo n.º 19
0
def check_job_execution_delete(job_id, **kwargs):
    ctx = context.current()
    je = conductor.job_execution_get(ctx, job_id)

    acl.check_tenant_for_delete(ctx, je)
    acl.check_protected_from_delete(je)
Ejemplo n.º 20
0
def check_job_execution_delete(job_execution_id, **kwargs):
    ctx = context.current()
    je = conductor.job_execution_get(ctx, job_execution_id)

    acl.check_tenant_for_delete(ctx, je)
    acl.check_protected_from_delete(je)