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')
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')
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')
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')