Beispiel #1
0
def copy_files(request):

    if request.method == "POST":
        error = None
        device = request.POST.get("device")

        if not device:
            raise Http404()

        try:
            manager = StorageDeviceManager(device)
            manager.mount()
        except (MountError, OSError), e:
            error = e
            messages.error(
                request,
                "Impossível montar dispositivo. Sistema de arquivo inadequado")
            return redirect('nimbus.system.views.select_storage')

        sizes = [getsize(dev) for dev in offsite.get_all_bacula_volumes()]
        required_size = sum(sizes)

        if required_size < manager.available_size:
            systemprocesses.min_priority_job("Nimbus upload volumes",
                                             upload_volumes_worker, manager)
            messages.success(request, u"O processo foi iniciado com sucesso.")
            return redirect('nimbus.offsite.views.list_uploadrequest')
        else:
            required_size = utils.bytes_to_mb(required_size)
            available_size = utils.bytes_to_mb(manager.available_size)
            manager.umount()
            error_msg = u"Espaço necessário é de %.3fMB, somente %.3fMB disponível em %s" %\
                    (required_size, available_size, device)
            messages.error(request, error_msg)
            return redirect('nimbus.system.views.select_storage')
Beispiel #2
0
def copy_files(request):

    if request.method == "POST":
        error = None
        device = request.POST.get("device")

        if not device:
            raise Http404()

        try:
            manager = StorageDeviceManager(device)
            manager.mount()
        except (MountError, OSError), e:
            error = e
            messages.error(request, "Impossível montar dispositivo. Sistema de arquivo inadequado")
            return redirect('nimbus.system.views.select_storage')


        sizes = [ getsize( dev) for dev in offsite.get_all_bacula_volumes() ]
        required_size = sum( sizes )


        if required_size <  manager.available_size:
            systemprocesses.min_priority_job("Nimbus upload volumes",
                                             upload_volumes_worker, manager)
            messages.success(request, u"O processo foi iniciado com sucesso.")
            return redirect('nimbus.offsite.views.list_uploadrequest')
        else:
            required_size = utils.bytes_to_mb(required_size)
            available_size = utils.bytes_to_mb(manager.available_size)
            manager.umount()
            error_msg = u"Espaço necessário é de %.3fMB, somente %.3fMB disponível em %s" %\
                    (required_size, available_size, device)
            messages.error(request, error_msg)
            return redirect('nimbus.system.views.select_storage')
Beispiel #3
0
def copy_files_to_storage(request):
    if request.method == "POST":
        device = request.POST.get("device")
        if not device:
            raise Http404()
        systemprocesses.min_priority_job("Nimbus volumes copy to disk", 
                                         copy_files_worker, device)
        return redirect('nimbus.offsite.views.list_uploadrequest')
    else:
        return redirect('nimbus.offsite.views.list_uploadrequest')
Beispiel #4
0
def copy_files_to_storage(request):
    if request.method == "POST":
        device = request.POST.get("device")
        if not device:
            raise Http404()
        systemprocesses.min_priority_job("Nimbus volumes copy to disk",
                                         copy_files_worker, device)
        return redirect('nimbus.offsite.views.list_uploadrequest')
    else:
        return redirect('nimbus.offsite.views.list_uploadrequest')
Beispiel #5
0
def recover_volumes(request):
    extra_content = {'wizard_title': u'Recuperando arquivos',
                     'title': u"Recuperação do sistema"}
    if request.method == "GET":
        return render_to_response(request, "recovery_recover_volumes.html",
                                  extra_content)
    elif request.method == "POST":
        localsource = request.POST.get("localsource", "offsite")
        if localsource != "offsite":
            device = request.POST.get("device")
            storage = StorageDeviceManager(device)
            manager = offsite.LocalManager(storage, "/bacula")
        else:
            manager =  offsite.RemoteManager()
        systemprocesses.min_priority_job("Recovery nimbus volumes",
                                         recover_volumes_worker, manager)
        extra_content.update({ "object_list" : DownloadRequest.objects.all()})
        return render_to_response(request, "recovery_recover_volumes.html", extra_content)
    else:
        raise Http404()
Beispiel #6
0
def recover_volumes(request):
    extra_content = {
        'wizard_title': u'Recuperando arquivos',
        'title': u"Recuperação do sistema"
    }
    if request.method == "GET":
        return render_to_response(request, "recovery_recover_volumes.html",
                                  extra_content)
    elif request.method == "POST":
        localsource = request.POST.get("localsource", "offsite")
        if localsource != "offsite":
            device = request.POST.get("device")
            storage = StorageDeviceManager(device)
            manager = offsite.LocalManager(storage, "/bacula")
        else:
            manager = offsite.RemoteManager()
        systemprocesses.min_priority_job("Recovery nimbus volumes",
                                         recover_volumes_worker, manager)
        extra_content.update({"object_list": DownloadRequest.objects.all()})
        return render_to_response(request, "recovery_recover_volumes.html",
                                  extra_content)
    else:
        raise Http404()
Beispiel #7
0
            device = request.POST.get("device")
            storage = StorageDeviceManager(device)
            try:
                storage.mount()
            except MountError, error:
                extra_content.update({
                    "error": error,
                    "device": device,
                    "localsource": True
                })
                return render_to_response(request, 'recovery_mounterror.html',
                                          extra_content)
            manager = offsite.LocalManager(storage, "/bacula")
    manager = offsite.RecoveryManager(manager)
    logger.info("adicionando trabalho")
    systemprocesses.min_priority_job("Recovery nimbus database",
                                     recover_databases_worker, manager)
    logger.info("trabalho adicionado com sucesso")
    extra_content.update({"device": device, "localsource": localsource})
    return render_to_response(request, "recovery_recover_databases.html",
                              extra_content)


@only_wizard
def check_volume_recover(request):
    count = DownloadRequest.objects.count()
    has_finished = systemprocesses.has_pending_jobs()
    return HttpResponse(
        simplejson.dumps({
            "count": count,
            "has_finished": has_finished
        }))
Beispiel #8
0
        localsource = request.POST.get("localsource", "offsite")
        if localsource != "offsite":
            device = request.POST.get("device")
            storage = StorageDeviceManager(device)
            try:
                storage.mount()
            except MountError, error:
                extra_content.update({"error": error,
                                      "device" : device,
                                      "localsource"  : True})
                return render_to_response(request, 'recovery_mounterror.html',
                                          extra_content)
            manager = offsite.LocalManager(storage, "/bacula")
    manager = offsite.RecoveryManager(manager)
    logger.info("adicionando trabalho")
    systemprocesses.min_priority_job("Recovery nimbus database",
                                     recover_databases_worker, manager)
    logger.info("trabalho adicionado com sucesso")
    extra_content.update({"device" : device, "localsource"  : localsource})
    return render_to_response(request, "recovery_recover_databases.html",
                              extra_content)



@only_wizard
def check_volume_recover(request):
    count = DownloadRequest.objects.count()
    has_finished = systemprocesses.has_pending_jobs()
    return HttpResponse(simplejson.dumps({"count": count,
                                          "has_finished" : has_finished}))

@only_wizard