コード例 #1
0
    def delete(self, audit):
        """Delete an audit.

        :param audit: UUID or name of an audit.
        """
        context = pecan.request.context
        audit_to_delete = api_utils.get_resource('Audit', audit, eager=True)
        policy.enforce(context,
                       'audit:delete',
                       audit_to_delete,
                       action='audit:delete')

        initial_state = audit_to_delete.state
        new_state = objects.audit.State.DELETED
        if not objects.audit.AuditStateTransitionManager().check_transition(
                initial_state, new_state):
            raise exception.DeleteError(state=initial_state)

        audit_to_delete.soft_delete()
コード例 #2
0
    def delete(self, action_plan_uuid):
        """Delete an action plan.

        :param action_plan_uuid: UUID of a action.
        """
        context = pecan.request.context
        action_plan = api_utils.get_resource(
            'ActionPlan', action_plan_uuid, eager=True)
        policy.enforce(context, 'action_plan:delete', action_plan,
                       action='action_plan:delete')

        allowed_states = (ap_objects.State.SUCCEEDED,
                          ap_objects.State.RECOMMENDED,
                          ap_objects.State.FAILED,
                          ap_objects.State.SUPERSEDED,
                          ap_objects.State.CANCELLED)
        if action_plan.state not in allowed_states:
            raise exception.DeleteError(
                state=action_plan.state)

        action_plan.soft_delete()