Пример #1
0
def disk_wipe(request, devname):
    global DISK_WIPE_JOB_ID

    if request.method == "POST":
        form = forms.DiskWipeForm(request.POST, disk=devname)
        if form.is_valid():
            DISK_WIPE_JOB_ID = None
            try:
                with client as c:
                    DISK_WIPE_JOB_ID = c.call('disk.wipe', devname, form.cleaned_data['method'])
                    wait_job(c, DISK_WIPE_JOB_ID)
            except JobAborted:
                raise MiddlewareError(_('Disk wipe job was aborted'))
            except JobFailed as e:
                raise MiddlewareError(_('Disk wipe job failed: %s') % str(e.value))
            return JsonResp(
                request,
                message=_("Disk successfully wiped"))

        return JsonResp(request, form=form)

    form = forms.DiskWipeForm(disk=devname)

    return render(request, "storage/disk_wipe.html", {
        'devname': devname,
        'form': form,
    })
Пример #2
0
def disk_wipe(request, devname):
    global DISK_WIPE_JOB_ID

    if request.method == "POST":
        form = forms.DiskWipeForm(request.POST, disk=devname)
        if form.is_valid():
            DISK_WIPE_JOB_ID = None
            try:
                with client as c:
                    DISK_WIPE_JOB_ID = c.call('disk.wipe', devname, form.cleaned_data['method'])
                    wait_job(c, DISK_WIPE_JOB_ID)
            except JobAborted:
                raise MiddlewareError(_('Disk wipe job was aborted'))
            except JobFailed as e:
                raise MiddlewareError(_('Disk wipe job failed: %s') % str(e.value))
            return JsonResp(
                request,
                message=_("Disk successfully wiped"))

        return JsonResp(request, form=form)

    form = forms.DiskWipeForm(disk=devname)

    return render(request, "storage/disk_wipe.html", {
        'devname': devname,
        'form': form,
    })