Esempio n. 1
0
def volume_lock(request, object_id):
    volume = models.Volume.objects.get(id=object_id)
    assert(volume.vol_encrypt > 0)

    if request.method == "POST":

        _n = notifier()
        if '__confirm' not in request.POST and not _n.is_freenas() and _n.failover_licensed():
            remaining_volumes = [v for v in models.Volume.objects.exclude(pk=object_id) if v.is_decrypted()]

            if not remaining_volumes:
                message = render_to_string('freeadmin/generic_model_confirm.html', {
                    'message': 'Warning: Locking this volume will prevent failover from functioning correctly.<br />Do you want to continue?',
                })
                return JsonResp(request, confirm=message)

        notifier().volume_detach(volume)
        if hasattr(notifier, 'failover_status') and notifier().failover_status() == 'MASTER':
            from freenasUI.failover.enc_helper import LocalEscrowCtl
            escrowctl = LocalEscrowCtl()
            escrowctl.clear()
            try:
                os.unlink('/tmp/.failover_master')
            except Exception:
                pass
            try:
                with client as c:
                    c.call('failover.call_remote', 'failover.encryption_clearkey')
            except Exception:
                log.warn('Failed to clear key on standby node, is it down?', exc_info=True)
        notifier().restart("system_datasets")
        return JsonResp(request, message=_("Volume locked"))
    return render(request, "storage/lock.html")
Esempio n. 2
0
def volume_lock(request, object_id):
    volume = models.Volume.objects.get(id=object_id)
    assert (volume.vol_encrypt > 0)

    if request.method == "POST":
        notifier().volume_detach(volume)
        if hasattr(notifier, 'failover_status') and notifier().failover_status(
        ) == 'MASTER':
            from freenasUI.failover.enc_helper import LocalEscrowCtl
            escrowctl = LocalEscrowCtl()
            escrowctl.clear()
            try:
                os.unlink('/tmp/.failover_master')
            except Exception:
                pass
            try:
                with client as c:
                    c.call('failover.call_remote',
                           'failover.encryption_clearkey')
            except Exception:
                log.warn('Failed to clear key on standby node, is it down?',
                         exc_info=True)
        notifier().restart("system_datasets")
        return JsonResp(request, message=_("Volume locked"))
    return render(request, "storage/lock.html")
Esempio n. 3
0
def volume_lock(request, object_id):
    volume = models.Volume.objects.get(id=object_id)
    assert (volume.vol_encrypt > 0)

    if request.method == "POST":
        notifier().volume_detach(volume)
        if hasattr(notifier, 'failover_status'):
            if notifier().failover_status() == 'MASTER':
                from freenasUI.failover.enc_helper import LocalEscrowCtl
                escrowctl = LocalEscrowCtl()
                escrowctl.clear()
                try:
                    os.unlink('/tmp/.failover_master')
                except:
                    pass
        notifier().restart("system_datasets")
        return JsonResp(request, message=_("Volume locked"))
    return render(request, "storage/lock.html")
Esempio n. 4
0
def volume_lock(request, object_id):
    volume = models.Volume.objects.get(id=object_id)
    assert(volume.vol_encrypt > 0)

    if request.method == "POST":
        notifier().volume_detach(volume)
        if hasattr(notifier, 'failover_status'):
            if notifier().failover_status() == 'MASTER':
                from freenasUI.failover.enc_helper import LocalEscrowCtl
                escrowctl = LocalEscrowCtl()
                escrowctl.clear()
                try:
                    os.unlink('/tmp/.failover_master')
                except:
                    pass
        notifier().restart("system_datasets")
        return JsonResp(request, message=_("Volume locked"))
    return render(request, "storage/lock.html")
Esempio n. 5
0
def volume_lock(request, object_id):
    volume = models.Volume.objects.get(id=object_id)
    assert (volume.vol_encrypt > 0)

    if request.method == "POST":

        _n = notifier()
        if '__confirm' not in request.POST and not _n.is_freenas(
        ) and _n.failover_licensed():
            remaining_volumes = [
                v for v in models.Volume.objects.exclude(pk=object_id)
                if v.is_decrypted()
            ]

            if not remaining_volumes:
                message = render_to_string(
                    'freeadmin/generic_model_confirm.html', {
                        'message':
                        'Warning: Locking this volume will prevent failover from functioning correctly.<br />Do you want to continue?',
                    })
                return JsonResp(request, confirm=message)

        notifier().volume_detach(volume)
        if hasattr(notifier, 'failover_status') and notifier().failover_status(
        ) == 'MASTER':
            from freenasUI.failover.enc_helper import LocalEscrowCtl
            escrowctl = LocalEscrowCtl()
            escrowctl.clear()
            try:
                os.unlink('/tmp/.failover_master')
            except Exception:
                pass
            try:
                with client as c:
                    c.call('failover.call_remote',
                           'failover.encryption_clearkey')
            except Exception:
                log.warn('Failed to clear key on standby node, is it down?',
                         exc_info=True)
        notifier().restart("system_datasets")
        return JsonResp(request, message=_("Volume locked"))
    return render(request, "storage/lock.html")
Esempio n. 6
0
 def enc_setkey(self, request, secret, passphrase):
     from freenasUI.failover.enc_helper import LocalEscrowCtl
     self._authenticated(secret)
     escrowctl = LocalEscrowCtl()
     return escrowctl.setkey(passphrase)
Esempio n. 7
0
 def enc_setkey(self, request, secret, passphrase):
     from freenasUI.failover.enc_helper import LocalEscrowCtl
     self._authenticated(secret)
     escrowctl = LocalEscrowCtl()
     return escrowctl.setkey(passphrase)