def volume_detach(request, vid): _n = notifier() standby_offline = False if not _n.is_freenas() and _n.failover_licensed(): try: with client as c: c.call('failover.call_remote', 'core.ping') except Exception: standby_offline = True volume = models.Volume.objects.get(pk=vid) usedbytes = volume._get_used_bytes() usedsize = humanize_size(usedbytes) if usedbytes else None with client as c: try: attachments = c.call('pool.attachments', volume.id) except Exception: attachments = [] if volume.vol_encrypt > 0: request.session["allow_gelikey"] = True if request.method == "POST": form = forms.VolumeExport( request.POST, instance=volume, attachments=attachments) if form.is_valid(): _n = notifier() if '__confirm' not in request.POST and not _n.is_freenas() and _n.failover_licensed(): remaining_volumes = models.Volume.objects.exclude(pk=vid) if not remaining_volumes.exists(): message = render_to_string('freeadmin/generic_model_confirm.html', { 'message': 'Warning: this pool is required for HA to function.<br />Do you want to continue?', }) return JsonResp(request, confirm=message) try: events = [] form.done(request, events) return JsonResp( request, message=_("The volume has been successfully detached"), events=events, ) except ServiceFailed as e: return JsonResp( request, form=form, error=True, message=e.value, events=["serviceFailed(\"%s\")" % e.service]) else: form = forms.VolumeExport(instance=volume, attachments=attachments) return render(request, 'storage/volume_detach.html', { 'standby_offline': standby_offline, 'volume': volume, 'form': form, 'used': usedsize, 'attachments': attachments, })
def volume_detach(request, vid): _n = notifier() standby_offline = False if not _n.is_freenas() and _n.failover_licensed(): try: with client as c: c.call('failover.call_remote', 'core.ping') except Exception: standby_offline = True volume = models.Volume.objects.get(pk=vid) usedbytes = volume._get_used_bytes() usedsize = humanize_size(usedbytes) if usedbytes else None services = { key: val for key, val in list(volume.has_attachments().items()) if len(val) > 0 } if volume.vol_encrypt > 0: request.session["allow_gelikey"] = True if request.method == "POST": form = forms.VolumeExport(request.POST, instance=volume, services=services) if form.is_valid(): _n = notifier() if '__confirm' not in request.POST and not _n.is_freenas( ) and _n.failover_licensed(): remaining_volumes = models.Volume.objects.exclude(pk=vid) if not remaining_volumes.exists(): message = render_to_string( 'freeadmin/generic_model_confirm.html', { 'message': 'Warning: this pool is required for HA to function.<br />Do you want to continue?', }) return JsonResp(request, confirm=message) try: events = [] volume.delete(destroy=form.cleaned_data['mark_new'], cascade=form.cleaned_data.get('cascade', True)) form.done(request, events) return JsonResp( request, message=_("The volume has been successfully detached"), events=events, ) except ServiceFailed as e: return JsonResp(request, error=True, message=str(e)) else: form = forms.VolumeExport(instance=volume, services=services) return render( request, 'storage/volume_detach.html', { 'standby_offline': standby_offline, 'volume': volume, 'form': form, 'used': usedsize, 'services': services, })
def volume_detach(request, vid): volume = models.Volume.objects.get(pk=vid) usedbytes = volume._get_used_bytes() usedsize = humanize_size(usedbytes) services = { key: val for key, val in volume.has_attachments().items() if len(val) > 0 } if volume.vol_encrypt > 0: request.session["allow_gelikey"] = True if request.method == "POST": form = forms.VolumeExport(request.POST, instance=volume, services=services) if form.is_valid(): try: events = [] volume.delete(destroy=form.cleaned_data['mark_new'], cascade=form.cleaned_data.get('cascade', True)) form.done(request, events) return JsonResp( request, message=_("The volume has been successfully detached"), events=events, ) except ServiceFailed, e: return JsonResp(request, error=True, message=unicode(e))
services=services) if form.is_valid(): try: events = [] volume.delete(destroy=form.cleaned_data['mark_new'], cascade=form.cleaned_data.get('cascade', True)) form.done(request, events) return JsonResp( request, message=_("The volume has been successfully detached"), events=events, ) except ServiceFailed, e: return JsonResp(request, error=True, message=unicode(e)) else: form = forms.VolumeExport(instance=volume, services=services) return render(request, 'storage/volume_detach.html', { 'volume': volume, 'form': form, 'used': usedsize, 'services': services, }) def zpool_scrub(request, vid): volume = models.Volume.objects.get(pk=vid) try: pool = notifier().zpool_parse(volume.vol_name) except: raise MiddlewareError( _('Pool output could not be parsed. Is the pool imported?'))