Exemplo n.º 1
0
def AnsiblePlayBookLogsList(request, format=None):
    if request.method == 'POST':
        try:
            snippets = Log_Ansible_Playbook.objects.filter(
                create_time__gte=request.data.get('startTime'),
                create_time__lte=request.data.get('endTime'),
            ).order_by("id")[:1000]
            serializer = serializers.AnsiblePlaybookLogsSerializer(snippets,
                                                                   many=True)
        except Exception, ex:
            return ex
        if request.user.has_perm('can_delete_log_ansible_playbook'):
            return Response({"data": serializer.data, "perm": 1})
        else:
            return Response({"data": serializer.data, "perm": 0})
Exemplo n.º 2
0
def playbookLogsdetail(request, id, format=None):
    """
    Retrieve, update or delete a server assets instance.
    """
    try:
        snippet = Log_Ansible_Playbook.objects.get(id=id)
    except Log_Ansible_Playbook.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)

    if request.method == 'GET':
        serializer = serializers.AnsiblePlaybookLogsSerializer(snippet)
        return Response(serializer.data)

    elif request.method == 'DELETE':
        if not request.user.has_perm('OMBA.can_delete_log_ansible_playbook'):
            return Response(status=status.HTTP_403_FORBIDDEN)
        snippet.delete()
        return Response(status=status.HTTP_204_NO_CONTENT)