1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 01:16:10 +00:00

fix: a backup's files say so on the pool page; Removed VMs names schedules and backups

On a backup target's pool every backup file was "Not used on this host" and
listed with the unused volumes, though its deletion there is refused: it is
deleted with its backup. The column now says "Backup of <VM>" and counts it
as in use. A VM kept on the Removed VMs page for its schedules or backups
alone showed no owner and no reason; its row now names its schedules and
counts its backups.
This commit is contained in:
catborise 2026-11-20 08:50:29 +03:00
parent aeef837afa
commit 981ff7b294
11 changed files with 227 additions and 135 deletions

View file

@ -27,6 +27,7 @@ from logs.models import Logs
from operations import claims
from operations.utils import busy_message
from vrtManager import util
from vmbackups.models import Backup, BackupPolicy
from . import forms
from .decorators import superuser_only
@ -442,8 +443,15 @@ def tombstone_list(request):
ids = {owner["user"] for tombstone in tombstones for owner in tombstone.owners}
names = dict(User.objects.filter(id__in=ids).values_list("id", "username"))
retention = timedelta(days=getattr(settings, "INSTANCE_OWNERSHIP_RETENTION_DAYS", 30))
# what would come back (computes.utils._restore): schedules that choose their VMs one by one, backups unlinked
policies = dict(BackupPolicy.objects.filter(pk__in={pk for t in tombstones for pk in t.policies}, compute=None,
tag=None).values_list("pk", "name"))
backups = set(Backup.objects.filter(pk__in={pk for t in tombstones for pk in t.backups}, instance=None)
.values_list("pk", flat=True))
for tombstone in tombstones:
tombstone.owner_names = [names.get(owner["user"], _("deleted user")) for owner in tombstone.owners]
tombstone.policy_names = sorted(policies[pk] for pk in tombstone.policies if pk in policies)
tombstone.backup_count = len(backups.intersection(tombstone.backups))
tombstone.expires = tombstone.removed + retention
return render(request, "admin/tombstone_list.html", {"tombstones": tombstones})