示例#1
0
文件: api.py 项目: suriya2612/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!"))
            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)
示例#2
0
文件: api.py 项目: qinweiwei/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!")
            session.delete(job)
    except db_exc.DBError as e:
        msg = "foreign key constraint" in e.message and\
              " on foreign key constraint" or ""
        raise ex.DeletionFailed("Job deletion failed%s" % msg)
示例#3
0
文件: api.py 项目: suriya2612/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!"))

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

        session.delete(job_binary)
示例#4
0
文件: api.py 项目: suriya2612/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!"))
            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)
示例#5
0
文件: api.py 项目: qinweiwei/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!")
            session.delete(data_source)
    except db_exc.DBError as e:
        msg = "foreign key constraint" in e.message and\
              " on foreign key constraint" or ""
        raise ex.DeletionFailed("Data Source deletion failed%s" % msg)
示例#6
0
def delete_trust(trustee, trust_id):
    '''Delete a trust from a trustee

    :param trustee: The Keystone client to delete the trust from.
    :param trust_id: The identifier of the trust to delete.
    :raises DeletionFailed: If the trust cannot be deleted.

    '''
    try:
        trustee.trusts.delete(trust_id)
        LOG.debug('Deleted trust {0}'.format(six.text_type(trust_id)))
    except Exception as e:
        LOG.exception(_LE('Unable to delete trust (reason: %s)'), e)
        raise ex.DeletionFailed(
            _('Failed to delete trust {0}').format(trust_id))
示例#7
0
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)

        session.delete(cluster_template)
示例#8
0
文件: api.py 项目: lhcxx/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)

        session.delete(node_group_template)
示例#9
0
文件: trusts.py 项目: stackhpc/sahara
def delete_trust(trustee, trust_id):
    '''Delete a trust from a trustee

    :param trustee: The user to delete the trust from, this is an auth plugin.

    :param trust_id: The identifier of the trust to delete.

    :raises DeletionFailed: If the trust cannot be deleted.

    '''
    try:
        client = keystone.client_from_auth(trustee)
        client.trusts.delete(trust_id)
        LOG.debug('Deleted trust {trust_id}'.format(
            trust_id=six.text_type(trust_id)))
    except Exception as e:
        LOG.error('Unable to delete trust (reason: {reason})'.format(reason=e))
        raise ex.DeletionFailed(
            _('Failed to delete trust {0}').format(trust_id))
示例#10
0
文件: acl.py 项目: madar010/mad
def check_protected_from_delete(object):
    if object.is_protected:
        raise ex.DeletionFailed(
            _("{object} with id '{id}' could not be deleted because "
              "it's marked as protected").format(object=type(object).__name__,
                                                 id=object.id))
示例#11
0
文件: acl.py 项目: madar010/mad
def check_tenant_for_delete(context, object):
    if object.tenant_id != context.tenant_id:
        raise ex.DeletionFailed(
            _("{object} with id '{id}' could not be deleted because "
              "it wasn't created in this tenant").format(
                  object=type(object).__name__, id=object.id))