Exemplo n.º 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')
Exemplo n.º 2
0
def umount(request):
    if request.method == "GET":
        devices = offsite.list_disk_labels()
        title = u'Remover dispositivo externo com segurança'
        return render_to_response(request, "umount_storage.html", locals())

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

        try:
            manager = StorageDeviceManager(device)
            manager.umount()
        except UmountError, e:
            error = e
            messages.error(request, u"Erro ao remover unidade")

        messages.success(request, u"Unidade removida corretamente.")
        return redirect('nimbus.base.views.home')
Exemplo n.º 3
0
def umount(request):
    if request.method == "GET":
        devices = offsite.list_disk_labels()
        title = u'Remover dispositivo externo com segurança'
        return render_to_response(request, "umount_storage.html", locals())

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

        try:
            manager = StorageDeviceManager(device)
            manager.umount()
        except UmountError, e:
            error = e
            messages.error(request, u"Erro ao remover unidade")

        messages.success(request, u"Unidade removida corretamente.")
        return redirect('nimbus.base.views.home')
Exemplo n.º 4
0
def recover_databases(request):
    logger = logging.getLogger(__name__)
    extra_content = {'wizard_title': u'Recuperação do sistema',
                     'title': u"Recuperação do sistema"}
    if request.method == "GET":
        manager = offsite.RemoteManager()
    elif request.method == "POST":
        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")
Exemplo n.º 5
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')
Exemplo n.º 6
0
def recover_databases(request):
    logger = logging.getLogger(__name__)
    extra_content = {
        'wizard_title': u'Recuperação do sistema',
        'title': u"Recuperação do sistema"
    }
    if request.method == "GET":
        manager = offsite.RemoteManager()
    elif request.method == "POST":
        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")
Exemplo n.º 7
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()