mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
feat(instances): a protected VM is not deleted nor restored over
A superuser turns a VM's protection on or off on its Settings tab, not while a job holds the VM (a deletion or a restore over it that runs would not stop). While it is on, its deletion (page, API, a queued job at its start) and a restore of a backup over it are refused; the Destroy tab, the destroy page and the restore page say so. A VM moved outside the panel keeps it. The API shows the flag read-only.
This commit is contained in:
parent
57e90e0d27
commit
adb4231db7
21 changed files with 706 additions and 491 deletions
|
|
@ -2543,6 +2543,18 @@ def set_template(request, pk):
|
|||
return _back(request, pk, "options")
|
||||
|
||||
|
||||
@require_POST
|
||||
@superuser_only
|
||||
@serialize_instance_mutation # not while a deletion or a restore over it runs: it would not stop them
|
||||
def set_protected(request, pk):
|
||||
"""Turns a VM's protection against deletion and a restore over it on or off."""
|
||||
instance = get_instance(request.user, pk)
|
||||
protected = bool(request.POST.get("protected"))
|
||||
with audit_vm(request, instance, "protect" if protected else "unprotect"):
|
||||
Instance.objects.filter(pk=instance.pk).update(protected=protected)
|
||||
return _back(request, pk, "options")
|
||||
|
||||
|
||||
def keyfile_value(value):
|
||||
"""value as a GLib key file (the .vv file) reads it back: a backslash,
|
||||
a line break or a leading space would change it."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue