1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 08:56:07 +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

@ -35,6 +35,12 @@
{% trans "Left" %} <span class="fw-semibold">{{ tombstone.host }}</span>
<span class="text-body-secondary">· {% trans "Owners" %}:</span> {{ tombstone.owner_names|join:", "|default:"–" }}
</div>
{% if tombstone.policy_names or tombstone.backup_count %}
<div class="mt-1">
{% if tombstone.policy_names %}<span class="text-body-secondary">{% trans "Schedules" %}:</span> {{ tombstone.policy_names|join:", " }}{% endif %}
{% if tombstone.backup_count %}{% if tombstone.policy_names %} · {% endif %}{% blocktrans count counter=tombstone.backup_count %}{{ counter }} backup{% plural %}{{ counter }} backups{% endblocktrans %}{% endif %}
</div>
{% endif %}
<div class="text-body-secondary mt-1">
{% trans "Removed" %} <span class="text-nowrap">{{ tombstone.removed|date:"Y-m-d H:i" }}</span>
· {% trans "expires" %} <span class="text-nowrap">{{ tombstone.expires|date:"Y-m-d H:i" }}</span>

View file

@ -1,6 +1,6 @@
"""Superusers list the ownership kept for VMs that vanished and can remove it."""
from datetime import timedelta
from datetime import time, timedelta
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
@ -9,6 +9,9 @@ from django.utils import timezone
from instances.models import InstanceTombstone
from logs.models import Logs
from lxml import html
from computes.models import Tag
from vmbackups.models import Backup, BackupPolicy, BackupTarget
UUID = "00000000-0000-4000-8000-000000000001"
@ -50,6 +53,22 @@ class TombstoneTests(TestCase):
self.assertEqual(self.client.post(url).status_code, 403)
self.assertTrue(InstanceTombstone.objects.exists())
def test_the_list_names_its_schedules_and_counts_its_backups(self):
# a VM kept for its backups or schedules alone has no owner to show; only what would come back is told
target = BackupTarget.objects.create(name="t")
chosen, by_tag = (BackupPolicy.objects.create(name=name, target=target, time=time(2), keep=1)
for name in ("nightly", "by-tag"))
BackupPolicy.objects.filter(pk=by_tag.pk).update(tag=Tag.objects.create(name="web"))
kept = [Backup.objects.create(target=target, vm_uuid=UUID, vm_name="ts-vm", compute_name="ts-host").pk
for _ in range(2)]
InstanceTombstone.objects.filter(pk=self.tombstone.pk).update(
owners=[], tags=[], policies=[chosen.pk, by_tag.pk, 999999], backups=[*kept, 999999])
page = html.fromstring(self.client.get(reverse("admin:tombstone_list")).content)
(row,) = page.xpath("//div[@data-search][contains(@data-search, 'ts-vm')]")
text = " ".join(row.text_content().split())
self.assertIn("Schedules: nightly · 2 backups", text)
self.assertNotIn("by-tag", text)
def test_a_get_only_asks_for_confirmation(self):
response = self.client.get(reverse("admin:tombstone_delete", args=[self.tombstone.pk]))
self.assertContains(response, "ts-vm")

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})

Binary file not shown.

View file

@ -11,7 +11,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-20 05:17+0000\n"
"POT-Creation-Date: 2026-11-20 05:53+0000\n"
"PO-Revision-Date: 2020-11-04 12:00+0000\n"
"Last-Translator: catborise <muhammetalisag@gmail.com>, 2020\n"
"Language-Team: Turkish (https://www.transifex.com/catborise/teams/110663/tr/)\n"
@ -262,7 +262,7 @@ msgstr "Yalnızca güç ve konsol"
#: accounts/templates/account.html:81 computes/templates/computes/list.html:110
#: instances/templates/instance_actions.html:9
#: storages/templates/storage.html:166
#: storages/templates/storage.html:167
#, python-format
msgid "Actions for %(name)s"
msgstr "%(name)s için işlemler"
@ -326,7 +326,7 @@ msgstr "Burada oturumunuz açık kalır; diğer oturumlarınız kapanır."
#: storages/templates/create_stg_block.html:183
#: storages/templates/create_stg_vol_block.html:35
#: storages/templates/create_stg_vol_block.html:68
#: storages/templates/storage.html:228 templates/base.html:65
#: storages/templates/storage.html:229 templates/base.html:65
#: templates/common/confirm_delete.html:25 templates/common/form.html:27
#: virtsecrets/templates/create_secret_block.html:48
#: virtsecrets/templates/secrets.html:106
@ -470,7 +470,7 @@ msgstr "%(name)s API anahtarı için işlemler"
#: accounts/templates/ssh_key_list.html:13
#: admin/templates/admin/group_list.html:44
#: admin/templates/admin/tag_list.html:38
#: admin/templates/admin/tombstone_list.html:44
#: admin/templates/admin/tombstone_list.html:50
#: admin/templates/admin/user_list.html:74
#: admin/templates/admin/user_list.html:76
#: instances/templates/create_flavors.html:11
@ -478,7 +478,7 @@ msgstr "%(name)s API anahtarı için işlemler"
#: instances/templates/instances/settings_tab.html:315
#: instances/templates/instances/snapshots_tab.html:103
#: instances/templates/instances/snapshots_tab.html:117
#: networks/templates/network.html:168 storages/templates/storage.html:179
#: networks/templates/network.html:168 storages/templates/storage.html:180
#: templates/common/confirm_delete.html:5
#: templates/common/confirm_delete.html:9
#: templates/common/confirm_delete.html:26
@ -1013,16 +1013,16 @@ msgstr "Sonuç"
msgid "IP"
msgstr "IP"
#: admin/templates/admin/logs.html:56 admin/views.py:397 instances/states.py:19
#: admin/templates/admin/logs.html:56 admin/views.py:398 instances/states.py:19
#: instances/views.py:491 logs/views.py:18
msgid "Unknown"
msgstr "Bilinmeyen"
#: admin/templates/admin/logs.html:56 admin/views.py:397 logs/views.py:18
#: admin/templates/admin/logs.html:56 admin/views.py:398 logs/views.py:18
msgid "Done"
msgstr "Tamamlandı"
#: admin/templates/admin/logs.html:56 admin/views.py:397 logs/views.py:18
#: admin/templates/admin/logs.html:56 admin/views.py:398 logs/views.py:18
#: operations/templates/operations/job.html:110
#: vmbackups/templates/vmbackups/index.html:34
#: vmbackups/templates/vmbackups/policy.html:39
@ -1127,15 +1127,30 @@ msgstr "Ayrıldığı sunucu"
msgid "Owners"
msgstr "Sahipler"
#: admin/templates/admin/tombstone_list.html:39
#: admin/templates/admin/tombstone_list.html:40
#: vmbackups/templates/vmbackups/index.html:12
#: vmbackups/templates/vmbackups/policies.html:8
#: vmbackups/templates/vmbackups/policy.html:10
#: vmbackups/templates/vmbackups/policy_new.html:8
msgid "Schedules"
msgstr "Zamanlamalar"
#: admin/templates/admin/tombstone_list.html:41
#, python-format
msgid "%(counter)s backup"
msgid_plural "%(counter)s backups"
msgstr[0] "%(counter)s yedek"
msgstr[1] "%(counter)s yedek"
#: admin/templates/admin/tombstone_list.html:45
msgid "Removed"
msgstr "Kaldırılma"
#: admin/templates/admin/tombstone_list.html:40
#: admin/templates/admin/tombstone_list.html:46
msgid "expires"
msgstr "sona erer"
#: admin/templates/admin/tombstone_list.html:51
#: admin/templates/admin/tombstone_list.html:57
msgid "No removed VM matches the search."
msgstr "Aramayla eşleşen kaldırılmış sanal makine yok."
@ -1224,7 +1239,7 @@ msgstr "Kullanıcı oluştur"
msgid "New user"
msgstr "Yeni kullanıcı"
#: admin/templates/admin/user_list.html:19 admin/views.py:181
#: admin/templates/admin/user_list.html:19 admin/views.py:182
#: instances/templates/instances/settings_tab.html:79 templates/navbar.html:35
msgid "Users"
msgstr "Kullanıcılar"
@ -1283,7 +1298,7 @@ msgstr "Burada belirlenen parolayla oturum açar."
msgid "Signs in another way, such as LDAP. The current password is removed."
msgstr "LDAP gibi başka bir yolla oturum açar. Mevcut parola kaldırılır."
#: admin/views.py:44
#: admin/views.py:45
#, python-format
msgid ""
"%(name)s was changed meanwhile: here it is as it is now; make your change "
@ -1291,55 +1306,55 @@ msgid ""
msgstr ""
"%(name)s bu arada değişti: güncel hâli aşağıda; değişikliğinizi yeniden yapın"
#: admin/views.py:77
#: admin/views.py:78
msgid "Create Group"
msgstr "Grup Oluştur"
#: admin/views.py:119
#: admin/views.py:120
msgid "Update Group"
msgstr "Grubu Güncelle"
#: admin/views.py:135
#: admin/views.py:136
msgid "Its members stay but lose the permissions it gave them."
msgstr "Üyeleri kalır ancak grubun onlara verdiği izinleri kaybeder."
#: admin/views.py:141
#: admin/views.py:142
msgid "You cannot block, delete or demote your own account"
msgstr "Kendi hesabınızı engelleyemez, silemez veya yetkisini düşüremezsiniz"
#: admin/views.py:142
#: admin/views.py:143
msgid "This would leave no active superuser"
msgstr "Bu işlem hiç etkin süper kullanıcı bırakmaz"
#: admin/views.py:216
#: admin/views.py:217
msgid "Create User"
msgstr "Kullanıcı Oluştur"
#: admin/views.py:289
#: admin/views.py:290
msgid "Update User"
msgstr "Kullanıcı Güncelle"
#: admin/views.py:313
#: admin/views.py:314
#, python-format
msgid "Password changed for %(user)s"
msgstr "%(user)s parolası değiştirildi"
#: admin/views.py:340
#: admin/views.py:341
msgid "Their access to VMs, SSH keys and settings go; the VMs themselves stay."
msgstr ""
"Sanal makinelere erişimi, SSH anahtarları ve ayarları silinir; sanal "
"makinelerin kendisi kalır."
#: admin/views.py:446
#: admin/views.py:452
msgid "deleted user"
msgstr "silinmiş kullanıcı"
#: admin/views.py:458
#: admin/views.py:466
#, python-format
msgid "Removed VM %(name)s deleted"
msgstr "Kaldırılan sanal makine %(name)s silindi"
#: admin/views.py:465
#: admin/views.py:473
msgid ""
"Its owners, tags, protection and schedules no longer come back if its UUID "
"shows up again, nor are its backups linked to it again."
@ -1347,12 +1362,12 @@ msgstr ""
"UUID'si yeniden görünse bile sahipleri, etiketleri, koruması ve zamanlamaları"
" artık geri gelmez, yedekleri de ona yeniden bağlanmaz."
#: admin/views.py:512
#: admin/views.py:520
#, python-format
msgid "Rename tag %(tag)s"
msgstr "%(tag)s etiketini yeniden adlandır"
#: admin/views.py:517
#: admin/views.py:525
#, python-format
msgid "The backup schedule %(schedules)s backs up its VMs: change it first"
msgid_plural ""
@ -1364,24 +1379,24 @@ msgstr[1] ""
"%(schedules)s yedekleme zamanlamaları bu etiketin sanal makinelerini "
"yedekliyor: önce onları değiştirin"
#: admin/views.py:535
#: admin/views.py:543
#, python-format
msgid "Tag %(tag)s deleted"
msgstr "%(tag)s etiketi silindi"
#: admin/views.py:543
#: admin/views.py:551
#, python-format
msgid "It is taken off %(vms)s and %(hosts)s."
msgstr "%(vms)s ve %(hosts)s üzerinden kaldırılır."
#: admin/views.py:544
#: admin/views.py:552
#, python-format
msgid "%(count)s VM"
msgid_plural "%(count)s VMs"
msgstr[0] "%(count)s sanal makine"
msgstr[1] "%(count)s sanal makine"
#: admin/views.py:545
#: admin/views.py:553
#, python-format
msgid "%(count)s host"
msgid_plural "%(count)s hosts"
@ -3397,7 +3412,7 @@ msgstr "Bağlan"
#: storages/templates/create_stg_block.html:21
#: storages/templates/create_stg_vol_block.html:16
#: storages/templates/create_stg_vol_block.html:54
#: storages/templates/storage.html:201 templates/base.html:61
#: storages/templates/storage.html:202 templates/base.html:61
#: virtsecrets/templates/create_secret_block.html:16
#: virtsecrets/templates/secrets.html:97
msgid "Close"
@ -4284,7 +4299,7 @@ msgstr "Depolama havuzu"
#: instances/templates/add_instance_volume.html:41
#: instances/templates/create_instance_w2.html:46 storages/forms.py:119
#: storages/templates/storage.html:209
#: storages/templates/storage.html:210
msgid "Letters, digits, dot, dash and underscore."
msgstr "Harf, rakam, nokta, tire ve alt çizgi."
@ -4297,14 +4312,14 @@ msgstr "Boyut"
#: instances/templates/add_instance_volume.html:51
#: instances/templates/instances/edit_instance_volume.html:82
#: storages/templates/storage.html:141 storages/templates/storage.html:216
#: storages/templates/storage.html:141 storages/templates/storage.html:217
msgid "Format"
msgstr "Biçem"
#: instances/templates/add_instance_volume.html:61
#: instances/templates/create_instance_w2.html:154
#: instances/templates/create_instance_w2.html:220 storages/forms.py:125
#: storages/forms.py:145 storages/templates/storage.html:224
#: storages/forms.py:145 storages/templates/storage.html:225
msgid "Preallocate metadata (qcow2)"
msgstr "Meta veriyi önceden ayır (qcow2)"
@ -4796,7 +4811,7 @@ msgstr "Ayrıntılar"
#: instances/templates/instances/settings_tab.html:882
#: instances/templates/instances/settings_tab.html:884
#: nwfilters/templates/nwfilters.html:57 nwfilters/templates/nwfilters.html:94
#: storages/templates/storage.html:169 storages/templates/storage.html:229
#: storages/templates/storage.html:170 storages/templates/storage.html:230
msgid "Clone"
msgstr "Klonla"
@ -4905,7 +4920,7 @@ msgstr "Kapat"
#: instances/templates/instance_actions.html:39
#: interfaces/templates/interface.html:22 networks/templates/network.html:22
#: networks/templates/network.html:162 storages/templates/storage.html:26
#: storages/templates/storage.html:173
#: storages/templates/storage.html:174
msgid "More actions"
msgstr "Diğer işlemler"
@ -8836,7 +8851,7 @@ msgstr "Aramayla eşleşen filtre yok."
msgid "Clone filter"
msgstr "Filtreyi klonla"
#: nwfilters/templates/nwfilters.html:88 storages/templates/storage.html:207
#: nwfilters/templates/nwfilters.html:88 storages/templates/storage.html:208
msgid "Name of the copy"
msgstr "Kopyanın adı"
@ -9619,28 +9634,33 @@ msgstr "Birimlerde ara"
msgid "Volume use"
msgstr "Disk kullanımı"
#: storages/templates/storage.html:128 storages/templates/storage.html:156
#: storages/templates/storage.html:128 storages/templates/storage.html:157
msgid "In use"
msgstr "Kullanımda"
#: storages/templates/storage.html:131 storages/templates/storage.html:157
#: storages/templates/storage.html:131 storages/templates/storage.html:158
msgid "Not used on this host"
msgstr "Bu sunucuda kullanılmıyor"
#: storages/templates/storage.html:156
#: storages/templates/storage.html:155
#, python-format
msgid "Backup of %(vm)s"
msgstr "%(vm)s yedeği"
#: storages/templates/storage.html:157
msgid "Another volume is built on it"
msgstr "Başka bir disk bunun üzerine kurulu"
#: storages/templates/storage.html:163
#: storages/templates/storage.html:164
#, python-format
msgid "%(allocated)s allocated"
msgstr "%(allocated)s ayrılmış"
#: storages/templates/storage.html:175
#: storages/templates/storage.html:176
msgid "Download"
msgstr "İndir"
#: storages/templates/storage.html:179
#: storages/templates/storage.html:180
#, python-format
msgid ""
"Delete volume %(name)s? Its file and data are removed; a volume a VM uses is "
@ -9649,27 +9669,27 @@ msgstr ""
"%(name)s birimi silinsin mi? Dosyası ve verisi kaldırılır; bir sanal "
"makinenin kullandığı birim silinmez."
#: storages/templates/storage.html:192
#: storages/templates/storage.html:193
msgid "No volume matches the search."
msgstr "Aramayla eşleşen birim yok."
#: storages/templates/storage.html:200
#: storages/templates/storage.html:201
msgid "Clone image"
msgstr "İmaj Klonla"
#: storages/templates/storage.html:213
#: storages/templates/storage.html:214
msgid "Convert it to another format"
msgstr "Başka bir biçime dönüştür"
#: storages/templates/storage.html:218
#: storages/templates/storage.html:219
msgid "raw"
msgstr "raw"
#: storages/templates/storage.html:219
#: storages/templates/storage.html:220
msgid "qcow2"
msgstr "qcow2"
#: storages/templates/storage.html:236
#: storages/templates/storage.html:237
msgid "This pool has no volumes."
msgstr "Bu havuzda birim yok."
@ -10736,13 +10756,6 @@ msgstr ""
"%(vm)s VM'inin %(time)s tarihli yedeği silinsin mi? Dosyaları %(target)s "
"hedefinden kaldırılır; bu geri alınamaz."
#: vmbackups/templates/vmbackups/index.html:12
#: vmbackups/templates/vmbackups/policies.html:8
#: vmbackups/templates/vmbackups/policy.html:10
#: vmbackups/templates/vmbackups/policy_new.html:8
msgid "Schedules"
msgstr "Zamanlamalar"
#: vmbackups/templates/vmbackups/index.html:13
#: vmbackups/templates/vmbackups/target.html:7
#: vmbackups/templates/vmbackups/target.html:9
@ -11146,7 +11159,7 @@ msgstr "Zamanlamalar:"
msgid "No backup of this VM yet."
msgstr "Bu sanal makinenin henüz yedeği yok."
#: vmbackups/utils.py:28
#: vmbackups/utils.py:36
#, python-format
msgid ""
"Volume %(volume)s belongs to a backup of %(vm)s; delete the backup on the "
@ -11154,7 +11167,7 @@ msgid ""
msgstr ""
"%(volume)s birimi %(vm)s yedeğine ait; yedeği Yedekler sayfasından silin"
#: vmbackups/utils.py:38
#: vmbackups/utils.py:46
#, python-format
msgid ""
"Storage pool %(pool)s is backup target %(target)s; remove it from the target "
@ -11162,14 +11175,14 @@ msgid ""
msgstr ""
"%(pool)s depolama havuzu %(target)s yedek hedefidir; önce hedeften çıkarın"
#: vmbackups/utils.py:65
#: vmbackups/utils.py:73
msgid ""
"No backup target open to VM owners has a storage pool on this VM's host."
msgstr ""
"VM sahiplerine açık hiçbir yedek hedefinin bu VM'in sunucusunda depolama "
"havuzu yok."
#: vmbackups/utils.py:66
#: vmbackups/utils.py:74
msgid "No backup target has a storage pool on this VM's host."
msgstr ""
"Hiçbir yedek hedefinin bu sanal makinenin sunucusunda depolama havuzu yok."

Binary file not shown.

View file

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-20 05:17+0000\n"
"POT-Creation-Date: 2026-11-20 05:53+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -257,7 +257,7 @@ msgstr "仅电源和控制台"
#: accounts/templates/account.html:81 computes/templates/computes/list.html:110
#: instances/templates/instance_actions.html:9
#: storages/templates/storage.html:166
#: storages/templates/storage.html:167
#, python-format
msgid "Actions for %(name)s"
msgstr "%(name)s 的操作"
@ -321,7 +321,7 @@ msgstr "您在此处保持登录;您的其他会话将结束。"
#: storages/templates/create_stg_block.html:183
#: storages/templates/create_stg_vol_block.html:35
#: storages/templates/create_stg_vol_block.html:68
#: storages/templates/storage.html:228 templates/base.html:65
#: storages/templates/storage.html:229 templates/base.html:65
#: templates/common/confirm_delete.html:25 templates/common/form.html:27
#: virtsecrets/templates/create_secret_block.html:48
#: virtsecrets/templates/secrets.html:106
@ -463,7 +463,7 @@ msgstr "API 令牌 %(name)s 的操作"
#: accounts/templates/ssh_key_list.html:13
#: admin/templates/admin/group_list.html:44
#: admin/templates/admin/tag_list.html:38
#: admin/templates/admin/tombstone_list.html:44
#: admin/templates/admin/tombstone_list.html:50
#: admin/templates/admin/user_list.html:74
#: admin/templates/admin/user_list.html:76
#: instances/templates/create_flavors.html:11
@ -471,7 +471,7 @@ msgstr "API 令牌 %(name)s 的操作"
#: instances/templates/instances/settings_tab.html:315
#: instances/templates/instances/snapshots_tab.html:103
#: instances/templates/instances/snapshots_tab.html:117
#: networks/templates/network.html:168 storages/templates/storage.html:179
#: networks/templates/network.html:168 storages/templates/storage.html:180
#: templates/common/confirm_delete.html:5
#: templates/common/confirm_delete.html:9
#: templates/common/confirm_delete.html:26
@ -985,16 +985,16 @@ msgstr "结果"
msgid "IP"
msgstr "IP"
#: admin/templates/admin/logs.html:56 admin/views.py:397 instances/states.py:19
#: admin/templates/admin/logs.html:56 admin/views.py:398 instances/states.py:19
#: instances/views.py:491 logs/views.py:18
msgid "Unknown"
msgstr "未知"
#: admin/templates/admin/logs.html:56 admin/views.py:397 logs/views.py:18
#: admin/templates/admin/logs.html:56 admin/views.py:398 logs/views.py:18
msgid "Done"
msgstr "完成"
#: admin/templates/admin/logs.html:56 admin/views.py:397 logs/views.py:18
#: admin/templates/admin/logs.html:56 admin/views.py:398 logs/views.py:18
#: operations/templates/operations/job.html:110
#: vmbackups/templates/vmbackups/index.html:34
#: vmbackups/templates/vmbackups/policy.html:39
@ -1093,15 +1093,29 @@ msgstr "已离开"
msgid "Owners"
msgstr "所有者"
#: admin/templates/admin/tombstone_list.html:39
#: admin/templates/admin/tombstone_list.html:40
#: vmbackups/templates/vmbackups/index.html:12
#: vmbackups/templates/vmbackups/policies.html:8
#: vmbackups/templates/vmbackups/policy.html:10
#: vmbackups/templates/vmbackups/policy_new.html:8
msgid "Schedules"
msgstr "计划"
#: admin/templates/admin/tombstone_list.html:41
#, python-format
msgid "%(counter)s backup"
msgid_plural "%(counter)s backups"
msgstr[0] "%(counter)s 个备份"
#: admin/templates/admin/tombstone_list.html:45
msgid "Removed"
msgstr "移除时间"
#: admin/templates/admin/tombstone_list.html:40
#: admin/templates/admin/tombstone_list.html:46
msgid "expires"
msgstr "过期"
#: admin/templates/admin/tombstone_list.html:51
#: admin/templates/admin/tombstone_list.html:57
msgid "No removed VM matches the search."
msgstr "没有与搜索匹配的已移除虚拟机。"
@ -1186,7 +1200,7 @@ msgstr "创建用户"
msgid "New user"
msgstr "新建用户"
#: admin/templates/admin/user_list.html:19 admin/views.py:181
#: admin/templates/admin/user_list.html:19 admin/views.py:182
#: instances/templates/instances/settings_tab.html:79 templates/navbar.html:35
msgid "Users"
msgstr "用户"
@ -1244,94 +1258,94 @@ msgstr "使用此处设置的密码登录。"
msgid "Signs in another way, such as LDAP. The current password is removed."
msgstr "通过其他方式(如 LDAP)登录。当前密码将被移除。"
#: admin/views.py:44
#: admin/views.py:45
#, python-format
msgid ""
"%(name)s was changed meanwhile: here it is as it is now; make your change "
"again"
msgstr "%(name)s 在此期间已更改:以下是其当前状态;请重新进行更改"
#: admin/views.py:77
#: admin/views.py:78
msgid "Create Group"
msgstr "创建用户组"
#: admin/views.py:119
#: admin/views.py:120
msgid "Update Group"
msgstr "更新用户组"
#: admin/views.py:135
#: admin/views.py:136
msgid "Its members stay but lose the permissions it gave them."
msgstr "其成员仍保留,但会失去该用户组授予的权限。"
#: admin/views.py:141
#: admin/views.py:142
msgid "You cannot block, delete or demote your own account"
msgstr "不能禁用、删除或降级你自己的账户"
#: admin/views.py:142
#: admin/views.py:143
msgid "This would leave no active superuser"
msgstr "这将导致没有可用的超级用户"
#: admin/views.py:216
#: admin/views.py:217
msgid "Create User"
msgstr "创建用户"
#: admin/views.py:289
#: admin/views.py:290
msgid "Update User"
msgstr "更新用户"
#: admin/views.py:313
#: admin/views.py:314
#, python-format
msgid "Password changed for %(user)s"
msgstr "已为 %(user)s 修改密码"
#: admin/views.py:340
#: admin/views.py:341
msgid "Their access to VMs, SSH keys and settings go; the VMs themselves stay."
msgstr "其对虚拟机、SSH 密钥和设置的访问将被移除;虚拟机本身保留。"
#: admin/views.py:446
#: admin/views.py:452
msgid "deleted user"
msgstr "已删除的用户"
#: admin/views.py:458
#: admin/views.py:466
#, python-format
msgid "Removed VM %(name)s deleted"
msgstr "已删除已移除的虚拟机 %(name)s"
#: admin/views.py:465
#: admin/views.py:473
msgid ""
"Its owners, tags, protection and schedules no longer come back if its UUID "
"shows up again, nor are its backups linked to it again."
msgstr "若其 UUID 再次出现,其所有者、标签、保护和计划将不再恢复,其备份也不会重新关联到它。"
#: admin/views.py:512
#: admin/views.py:520
#, python-format
msgid "Rename tag %(tag)s"
msgstr "重命名标签 %(tag)s"
#: admin/views.py:517
#: admin/views.py:525
#, python-format
msgid "The backup schedule %(schedules)s backs up its VMs: change it first"
msgid_plural ""
"The backup schedules %(schedules)s back up its VMs: change them first"
msgstr[0] "备份计划 %(schedules)s 正在备份该标签的虚拟机:请先修改计划"
#: admin/views.py:535
#: admin/views.py:543
#, python-format
msgid "Tag %(tag)s deleted"
msgstr "标签 %(tag)s 已删除"
#: admin/views.py:543
#: admin/views.py:551
#, python-format
msgid "It is taken off %(vms)s and %(hosts)s."
msgstr "它将从 %(vms)s 和 %(hosts)s 上移除。"
#: admin/views.py:544
#: admin/views.py:552
#, python-format
msgid "%(count)s VM"
msgid_plural "%(count)s VMs"
msgstr[0] "%(count)s 个虚拟机"
#: admin/views.py:545
#: admin/views.py:553
#, python-format
msgid "%(count)s host"
msgid_plural "%(count)s hosts"
@ -3230,7 +3244,7 @@ msgstr "连接"
#: storages/templates/create_stg_block.html:21
#: storages/templates/create_stg_vol_block.html:16
#: storages/templates/create_stg_vol_block.html:54
#: storages/templates/storage.html:201 templates/base.html:61
#: storages/templates/storage.html:202 templates/base.html:61
#: virtsecrets/templates/create_secret_block.html:16
#: virtsecrets/templates/secrets.html:97
msgid "Close"
@ -4052,7 +4066,7 @@ msgstr "存储池"
#: instances/templates/add_instance_volume.html:41
#: instances/templates/create_instance_w2.html:46 storages/forms.py:119
#: storages/templates/storage.html:209
#: storages/templates/storage.html:210
msgid "Letters, digits, dot, dash and underscore."
msgstr "字母、数字、点、短横线和下划线。"
@ -4065,14 +4079,14 @@ msgstr "大小"
#: instances/templates/add_instance_volume.html:51
#: instances/templates/instances/edit_instance_volume.html:82
#: storages/templates/storage.html:141 storages/templates/storage.html:216
#: storages/templates/storage.html:141 storages/templates/storage.html:217
msgid "Format"
msgstr "格式"
#: instances/templates/add_instance_volume.html:61
#: instances/templates/create_instance_w2.html:154
#: instances/templates/create_instance_w2.html:220 storages/forms.py:125
#: storages/forms.py:145 storages/templates/storage.html:224
#: storages/forms.py:145 storages/templates/storage.html:225
msgid "Preallocate metadata (qcow2)"
msgstr "预分配元数据(qcow2)"
@ -4550,7 +4564,7 @@ msgstr "详情"
#: instances/templates/instances/settings_tab.html:882
#: instances/templates/instances/settings_tab.html:884
#: nwfilters/templates/nwfilters.html:57 nwfilters/templates/nwfilters.html:94
#: storages/templates/storage.html:169 storages/templates/storage.html:229
#: storages/templates/storage.html:170 storages/templates/storage.html:230
msgid "Clone"
msgstr "克隆"
@ -4657,7 +4671,7 @@ msgstr "关机"
#: instances/templates/instance_actions.html:39
#: interfaces/templates/interface.html:22 networks/templates/network.html:22
#: networks/templates/network.html:162 storages/templates/storage.html:26
#: storages/templates/storage.html:173
#: storages/templates/storage.html:174
msgid "More actions"
msgstr "更多操作"
@ -8307,7 +8321,7 @@ msgstr "没有与搜索匹配的过滤器。"
msgid "Clone filter"
msgstr "克隆过滤器"
#: nwfilters/templates/nwfilters.html:88 storages/templates/storage.html:207
#: nwfilters/templates/nwfilters.html:88 storages/templates/storage.html:208
msgid "Name of the copy"
msgstr "副本名称"
@ -9053,55 +9067,60 @@ msgstr "搜索卷"
msgid "Volume use"
msgstr "卷使用情况"
#: storages/templates/storage.html:128 storages/templates/storage.html:156
#: storages/templates/storage.html:128 storages/templates/storage.html:157
msgid "In use"
msgstr "使用中"
#: storages/templates/storage.html:131 storages/templates/storage.html:157
#: storages/templates/storage.html:131 storages/templates/storage.html:158
msgid "Not used on this host"
msgstr "未在此主机上使用"
#: storages/templates/storage.html:156
#: storages/templates/storage.html:155
#, python-format
msgid "Backup of %(vm)s"
msgstr "%(vm)s 的备份"
#: storages/templates/storage.html:157
msgid "Another volume is built on it"
msgstr "另一个卷基于它"
#: storages/templates/storage.html:163
#: storages/templates/storage.html:164
#, python-format
msgid "%(allocated)s allocated"
msgstr "已分配 %(allocated)s"
#: storages/templates/storage.html:175
#: storages/templates/storage.html:176
msgid "Download"
msgstr "下载"
#: storages/templates/storage.html:179
#: storages/templates/storage.html:180
#, python-format
msgid ""
"Delete volume %(name)s? Its file and data are removed; a volume a VM uses is "
"not deleted."
msgstr "删除卷 %(name)s?其文件和数据将被删除;虚拟机正在使用的卷不会被删除。"
#: storages/templates/storage.html:192
#: storages/templates/storage.html:193
msgid "No volume matches the search."
msgstr "没有与搜索匹配的卷。"
#: storages/templates/storage.html:200
#: storages/templates/storage.html:201
msgid "Clone image"
msgstr "克隆镜像"
#: storages/templates/storage.html:213
#: storages/templates/storage.html:214
msgid "Convert it to another format"
msgstr "转换为其他格式"
#: storages/templates/storage.html:218
#: storages/templates/storage.html:219
msgid "raw"
msgstr "raw"
#: storages/templates/storage.html:219
#: storages/templates/storage.html:220
msgid "qcow2"
msgstr "qcow2"
#: storages/templates/storage.html:236
#: storages/templates/storage.html:237
msgid "This pool has no volumes."
msgstr "此存储池中没有卷。"
@ -10099,13 +10118,6 @@ msgid ""
"%(target)s; this cannot be undone."
msgstr "删除 %(vm)s 于 %(time)s 的备份?其文件将从 %(target)s 中移除;此操作无法撤销。"
#: vmbackups/templates/vmbackups/index.html:12
#: vmbackups/templates/vmbackups/policies.html:8
#: vmbackups/templates/vmbackups/policy.html:10
#: vmbackups/templates/vmbackups/policy_new.html:8
msgid "Schedules"
msgstr "计划"
#: vmbackups/templates/vmbackups/index.html:13
#: vmbackups/templates/vmbackups/target.html:7
#: vmbackups/templates/vmbackups/target.html:9
@ -10482,26 +10494,26 @@ msgstr "计划:"
msgid "No backup of this VM yet."
msgstr "此虚拟机还没有备份。"
#: vmbackups/utils.py:28
#: vmbackups/utils.py:36
#, python-format
msgid ""
"Volume %(volume)s belongs to a backup of %(vm)s; delete the backup on the "
"Backups page"
msgstr "卷 %(volume)s 属于 %(vm)s 的备份;请在备份页面删除该备份"
#: vmbackups/utils.py:38
#: vmbackups/utils.py:46
#, python-format
msgid ""
"Storage pool %(pool)s is backup target %(target)s; remove it from the target "
"first"
msgstr "存储池 %(pool)s 是备份目标 %(target)s;请先将其从目标中移除"
#: vmbackups/utils.py:65
#: vmbackups/utils.py:73
msgid ""
"No backup target open to VM owners has a storage pool on this VM's host."
msgstr "没有向虚拟机所有者开放的备份目标在此虚拟机的主机上有存储池。"
#: vmbackups/utils.py:66
#: vmbackups/utils.py:74
msgid "No backup target has a storage pool on this VM's host."
msgstr "没有备份目标在此虚拟机的主机上有存储池。"

View file

@ -139,7 +139,7 @@
<tr>
<th scope="col">{% trans "Name" %}</th>
<th scope="col">{% trans "Format" %}</th>
{% if users_read %}<th scope="col" data-sort-method="text">{% trans "Used by" %}</th>{% endif %}
{% if users_read or has_backups %}<th scope="col" data-sort-method="text">{% trans "Used by" %}</th>{% endif %}
<th scope="col" class="d-none d-sm-table-cell" data-sort-method="number">{% trans "Capacity" %}</th>
<th scope="col" data-sort-method="none"><span class="visually-hidden">{% trans "Actions" %}</span></th>
</tr>
@ -149,12 +149,13 @@
<tr data-search="{{ volume.name }}{% for vm in volume.users %} {{ vm }}{% endfor %}">
<td class="text-break">{{ volume.name }}</td>
<td><span class="badge text-bg-light border">{{ volume.type }}</span></td>
{% if users_read %}
{% if users_read or has_backups %}
{# a delete still asks the other hosts: one sharing this storage may use the volume #}
<td class="text-break small">
{% if volume.users %}<span data-state="used">{{ volume.users|join:", " }}</span>
{% if volume.backup %}<span data-state="used">{% blocktrans with vm=volume.backup.vm_name %}Backup of {{ vm }}{% endblocktrans %}</span>
{% elif volume.users %}<span data-state="used">{{ volume.users|join:", " }}</span>
{% elif volume.users is not None %}<span data-state="used" title="{% trans "Another volume is built on it" %}">{% trans "In use" %}</span>
{% else %}<span class="text-body-secondary" data-state="unused">{% trans "Not used on this host" %}</span>{% endif %}
{% elif users_read %}<span class="text-body-secondary" data-state="unused">{% trans "Not used on this host" %}</span>{% endif %}
</td>
{% endif %}
{# capacity: what the guest sees; allocated: what it takes on the storage now #}

View file

@ -13,6 +13,7 @@ from libvirt import libvirtError
from lxml import html
from storages.forms import CreateVolumeForm
from vmbackups.models import Backup, BackupTarget, BackupTargetPool
class PoolPageTests(TestCase):
@ -138,6 +139,27 @@ class PoolPageTests(TestCase):
self.assertEqual(page.xpath("//tbody/tr/@data-search"), ["a.img vm1 vm2", "b.img", "c.img"])
self.assertEqual(page.xpath("//div[@id='state-pills']/button/@data-pill"), ["", "used", "unused"])
def test_a_backups_files_say_whose_backup_they_are(self):
# in a backup target's pool: deleted with their backup, not as unused volumes
target = BackupTarget.objects.create(name="t")
BackupTargetPool.objects.create(target=target, compute=self.compute, pool="default", pool_uuid="u")
backup = Backup.objects.create(target=target, vm_uuid="00000000-0000-4000-8000-000000000001", vm_name="web",
compute_name="pp", state=Backup.READY)
self.conn.get_size.return_value = (10, 4)
self.conn.update_volumes.return_value = [
{"name": name, "path": f"/p/{name}", "size": 1, "allocation": 1, "type": "qcow2"}
for name in (f"{backup.prefix}-vda.qcow2", "left.qcow2")]
page = html.fromstring(self.client.get(reverse("storage", args=[self.compute.pk, "default"])).content)
self.assertEqual([" ".join(t.split()) for t in page.xpath("//tbody/tr/td[3]//text()[normalize-space()]")],
["Backup of web", "Not used on this host"])
self.assertEqual(page.xpath("//tbody/tr//@data-state"), ["used", "unused"])
# the VMs' use not read: the backup is still told, the other volume is not called unused
self.conn.volume_users.side_effect = libvirtError("cannot read the domains")
page = html.fromstring(self.client.get(reverse("storage", args=[self.compute.pk, "default"])).content)
self.assertEqual([" ".join(t.split()) for t in page.xpath("//tbody/tr/td[3]//text()[normalize-space()]")],
["Backup of web"])
self.assertFalse(page.xpath("//div[@id='state-pills']"))
def test_volumes_whose_use_cannot_be_read_are_listed(self):
self.conn.get_size.return_value = (10, 4)
self.conn.update_volumes.return_value = [{"name": "a.img", "path": "/p/a.img", "size": 1, "allocation": 1,

View file

@ -23,7 +23,7 @@ from vrtManager.storage import wvmStorage, wvmStorages
from storages.forms import AddStgPool, CloneImage, CreateVolumeForm
from storages.jobs import is_iso
from storages.upload import write_chunk
from vmbackups.utils import refuse_backup_volume, refuse_target_pool
from vmbackups.utils import backups_of, refuse_backup_volume, refuse_target_pool
from webvirtcloud.gunicorn_worker import request_progressed
@ -237,8 +237,10 @@ def storage(request, compute_id, pool):
# which VMs of this host use each volume; the page lists them without it when it cannot be read
with contextlib.suppress(libvirtError):
users = conn.volume_users()
backups = backups_of(compute, pool, [volume["name"] for volume in volumes or []])
for volume in volumes or []:
volume["iso"] = is_iso(volume["name"])
volume["backup"] = backups.get(volume["name"])
volume["users"] = users.get(volume["path"]) if users is not None else None
try:
size, free = conn.get_size()
@ -258,6 +260,7 @@ def storage(request, compute_id, pool):
"state": state,
"volumes": volumes,
"users_read": users is not None,
"has_backups": bool(backups),
"size": size,
"free": free,
"used": used,

View file

@ -20,15 +20,23 @@ def inside_vm_pool(conn, pool):
return None
def backups_of(compute, pool, volumes):
"""{volume name: its backup} for those of volumes that are files of a backup in the compute's pool."""
if not volumes:
return {}
backups = list(Backup.objects.filter(target__pools__compute=compute, target__pools__pool=pool)
.only("prefix", "vm_name"))
return {volume: backup for volume in volumes for backup in backups if backup.owns(volume)}
def refuse_backup_volume(compute, pool, volume):
"""A volume of a backup is deleted with its backup, on the Backups pages."""
for backup in Backup.objects.filter(target__pools__compute=compute, target__pools__pool=pool):
if backup.owns(volume):
raise InUse(
gettext_noop("Volume %(volume)s belongs to a backup of %(vm)s; delete the backup on the Backups page"),
volume=volume,
vm=backup.vm_name,
)
if backup := backups_of(compute, pool, [volume]).get(volume):
raise InUse(
gettext_noop("Volume %(volume)s belongs to a backup of %(vm)s; delete the backup on the Backups page"),
volume=volume,
vm=backup.vm_name,
)
def refuse_target_pool(compute, pool):