mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
feat(vmbackups): backup targets: a storage pool per host, checked to be one directory
A backup target is a dir or NFS storage pool the administrator makes on the hosts and registers on the new Backup targets page (Backups in the menu, superusers only). Each compute's pool is kept with its UUID, so a pool replaced by another of the same name is refused. A second compute's pool is accepted only when it is the same directory as the target's first (the exclusive-create check migrations use). The target page shows each pool's space and warns when the target is inside another pool's directory, as its backups would share that storage's failures. The storage pages refuse to delete a target's pool, and a volume of a backup (page and API): backups are deleted from the Backups pages.
This commit is contained in:
parent
c7d6f90823
commit
022737f143
17 changed files with 821 additions and 54 deletions
29
vmbackups/forms.py
Normal file
29
vmbackups/forms.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from computes.models import Compute
|
||||
|
||||
from .models import BackupTarget
|
||||
|
||||
|
||||
class TargetPoolForm(forms.Form):
|
||||
"""A compute's storage pool for a target; computes that have one already are not offered."""
|
||||
|
||||
compute = forms.ModelChoiceField(Compute.objects.all(), label=_("Compute"))
|
||||
pool = forms.CharField(label=_("Storage pool"), max_length=128)
|
||||
|
||||
def __init__(self, *args, target=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if target is not None:
|
||||
self.fields["compute"].queryset = Compute.objects.exclude(backuptargetpool__target=target)
|
||||
|
||||
|
||||
class TargetForm(TargetPoolForm):
|
||||
name = forms.CharField(label=_("Name"), max_length=64)
|
||||
field_order = ["name", "compute", "pool"]
|
||||
|
||||
def clean_name(self):
|
||||
name = self.cleaned_data["name"]
|
||||
if BackupTarget.objects.filter(name=name).exists():
|
||||
raise forms.ValidationError(_("A backup target with this name exists"))
|
||||
return name
|
||||
Loading…
Add table
Add a link
Reference in a new issue