Esempio n. 1
0
    def action_send_nrpecfg(self, request, queryset):

        for sonda in queryset:
            send_nrpecfg.apply_async((sonda.pk, None), serializer="json")

        messages.info(request, str(queryset.count()) + ' sondas have been pushed to the task queue')
        return HttpResponseRedirect(request.get_full_path())
Esempio n. 2
0
    def resend_nrpecfg(self, request, queryset):
        sondas = []
        tasklog_list = []
        sondas_updated = 0
        for tasklog in SondaTasksLog.objects.all():
            if tasklog.task.name == "send_nrpecfg":
                if SondaTaskStatus.objects.filter(tasklog=tasklog).count() == 1:
                    last_timestamp = SondaTaskStatus.objects.get(tasklog=tasklog).timestamp
                else:
                    last_timestamp = max([i.timestamp for i in SondaTaskStatus.objects.filter(tasklog=tasklog)])
                taskstatus = SondaTaskStatus.objects.get(timestamp=last_timestamp, tasklog=tasklog)
                if taskstatus.status > 0:
                    sondas.append(tasklog.sonda)
                    tasklog_list.append(tasklog)
                    sondas_updated += 1

        if sondas_updated == 0:
            messages.info(request, str(sondas_updated) + ' sondas have been pushed to the task queue')
            return HttpResponseRedirect(request.get_full_path())

        for i in range(0, len(sondas)):
            send_nrpecfg.apply_async((sondas[i].pk, tasklog_list[i].pk), serializer="json")

        messages.info(request, str(sondas_updated) + ' sondas have been pushed to the task queue')
        return HttpResponseRedirect(request.get_full_path())