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

fix(tags): audit: races, a taken name, case

- A VM's tags set while its host's list drops it: the VM is checked
  again under the ownership lock and the page says it was moved, instead
  of a 500 or a success that kept the old tags in its removed record.
- A tag deleted right after another rename cleans the removed VMs' kept
  name it has now; a delete sent while a backup schedule uses the tag
  (saved after the page was shown) is refused with the schedules' names.
- A rename to a name another tag took meanwhile is a form error, not a
  500; "There is a tag with this name already" is translated.
- Tom Select makes a typed name lower case and offers no new tag for one
  that is there in another case; the API's ?tag= is lower-cased too.
This commit is contained in:
catborise 2026-11-18 22:47:18 +03:00
parent 904dd860d0
commit 45225df1a4
11 changed files with 198 additions and 114 deletions

View file

@ -54,6 +54,7 @@ class TagForm(forms.ModelForm):
class Meta:
model = Tag
fields = ["name"]
error_messages = {"name": {"unique": _("There is a tag with this name already")}}
def clean_name(self):
return self.cleaned_data["name"].strip().lower()

View file

@ -2,7 +2,10 @@
from django.contrib.auth.models import User
from django.test import TestCase
from unittest.mock import patch
from django.urls import reverse
from django.utils import translation
from computes.models import Compute, Tag
from instances.models import Instance, InstanceTombstone
@ -66,10 +69,44 @@ class TagAdminTests(TestCase):
from vmbackups.models import BackupPolicy, BackupTarget
BackupPolicy.objects.create(name="nightly", target=BackupTarget.objects.create(name="nfs"), tag=self.prod,
time=datetime.time(2), keep=3)
# the confirm page is not shown, and a delete sent anyway (the schedule saved since) is refused
self.assertContains(self.client.get(reverse("admin:tag_delete", args=[self.prod.pk]), follow=True),
"The backup schedule nightly backs up its VMs")
response = self.client.post(reverse("admin:tag_delete", args=[self.prod.pk]), follow=True)
self.assertContains(response, "The backup schedule nightly backs up its VMs")
self.assertTrue(Tag.objects.filter(name="prod").exists())
self.assertEqual(self.messages(), [])
# what another request does while this one waits for the ownership lock
def meanwhile(self, change):
from computes import utils
real = utils.lock_ownership
def lock():
change()
real()
return patch("admin.views.lock_ownership", side_effect=lock)
def test_a_rename_meanwhile_is_cleaned_from_removed_vms_on_delete(self):
def rename():
Tag.objects.filter(pk=self.prod.pk).update(name="live")
InstanceTombstone.objects.filter(pk=self.tombstone.pk).update(tags=["live", "db"])
with self.meanwhile(rename):
self.client.post(reverse("admin:tag_delete", args=[self.prod.pk]))
self.tombstone.refresh_from_db()
self.assertEqual(self.tombstone.tags, ["db"])
def test_a_name_taken_meanwhile_is_refused(self):
with self.meanwhile(lambda: Tag.objects.create(name="live")):
response = self.client.post(reverse("admin:tag_update", args=[self.prod.pk]), {"name": "live"})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["form"].errors["name"], ["There is a tag with this name already"])
self.assertEqual(Tag.objects.get(pk=self.prod.pk).name, "prod")
def test_a_name_taken_is_refused_in_the_reader_s_language(self):
Tag.objects.create(name="db")
response = self.client.post(reverse("admin:tag_update", args=[self.prod.pk]), {"name": "db"})
with translation.override("tr"): # the message is read in the reader's language
self.assertEqual(list(response.context["form"].errors["name"]), ["Bu adla bir etiket zaten var"])
def test_only_superusers(self):
self.client.force_login(User.objects.create_user("tg-user", password="pw"))

View file

@ -10,8 +10,8 @@ from django.contrib.auth import update_session_auth_hash
from django.contrib.auth.models import Group, Permission, User
from django.core.paginator import Paginator
from django.http import HttpResponse
from django.db import transaction
from django.db.models import Count, Exists, OuterRef, Q
from django.db import IntegrityError, transaction
from django.db.models import Count, Exists, OuterRef, ProtectedError, Q
from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
from django.utils.http import url_has_allowed_host_and_scheme, urlencode
@ -492,32 +492,46 @@ def tag_update(request, pk):
old = tag.name
form = forms.TagForm(request.POST or None, instance=tag)
if request.method == "POST" and form.is_valid():
if form.cleaned_data["name"] != old:
if form.cleaned_data["name"] == old:
return redirect("admin:tag_list")
try:
with audit(request, None, f"Tag {old}", f"rename to {form.cleaned_data['name']}"), transaction.atomic():
lock_ownership()
current = Tag.objects.values_list("name", flat=True).get(pk=pk) # another rename may have come first
form.save()
_retag_removed_vms(current, tag.name)
return redirect("admin:tag_list")
except IntegrityError: # the name was given to another tag meanwhile
form.add_error("name", form.fields["name"].error_messages["unique"])
else:
return redirect("admin:tag_list")
return render(request, "common/form.html", {"form": form, "title": _("Rename tag %(tag)s") % {"tag": old}})
def _refuse_used(request, schedules):
"""Tells that the tag cannot go while the backup schedules back up its VMs (models.PROTECT)."""
messages.error(request, ngettext("The backup schedule %(schedules)s backs up its VMs: change it first",
"The backup schedules %(schedules)s back up its VMs: change them first",
len(schedules)) % {"schedules": ", ".join(schedules)})
return redirect("admin:tag_list")
@superuser_only
def tag_delete(request, pk):
tag = get_object_or_404(Tag, pk=pk)
schedules = list(tag.backup_policies.values_list("name", flat=True))
if schedules: # it would back up nothing (models.PROTECT)
messages.error(request, ngettext("The backup schedule %(schedules)s backs up its VMs: change it first",
"The backup schedules %(schedules)s back up its VMs: change them first",
len(schedules)) % {"schedules": ", ".join(schedules)})
return redirect("admin:tag_list")
if request.method == "POST":
with audit(request, None, f"Tag {tag.name}", "delete"), transaction.atomic():
lock_ownership()
tag.delete()
_retag_removed_vms(tag.name, None)
try:
with audit(request, None, f"Tag {tag.name}", "delete"), transaction.atomic():
lock_ownership()
tag = get_object_or_404(Tag, pk=pk) # its name now: another rename may have come first
tag.delete()
_retag_removed_vms(tag.name, None)
except ProtectedError as err: # a schedule backs up its VMs, also one saved since the page was shown
return _refuse_used(request, sorted(policy.name for policy in err.protected_objects))
messages.success(request, _("Tag %(tag)s deleted") % {"tag": tag.name})
return redirect("admin:tag_list")
schedules = list(tag.backup_policies.values_list("name", flat=True))
if schedules:
return _refuse_used(request, schedules)
vms, hosts = tag.instances.count(), tag.computes.count()
return render(request, "common/confirm_delete.html", {
"object": tag,

View file

@ -14,7 +14,7 @@ TAG_PARAMETER = OpenApiParameter("tag", str, description="Only those with this t
def with_tag(queryset, request):
"""queryset's VMs or hosts with the ?tag= of request, all without one; their tags read at once."""
tag = request.query_params.get("tag")
tag = request.query_params.get("tag", "").lower() # the names are kept in lower case
return (queryset.filter(tags__name=tag) if tag else queryset).prefetch_related("tags")

View file

@ -10,7 +10,7 @@ from django.contrib.auth import get_user_model
from django.template.loader import render_to_string
from django.test import TestCase
from django.urls import reverse
from instances.models import Instance
from instances.models import Instance, InstanceTombstone
from logs.models import Logs
@ -50,6 +50,20 @@ class VmTagsTests(TestCase):
self.assertEqual(self.names(), [])
self.assertFalse(Tag.objects.exists())
def test_a_vm_gone_meanwhile_keeps_its_removed_record(self):
from computes import utils
real = utils.lock_ownership
def lock():
utils.forget(Instance.objects.get(pk=self.vm.pk)) # the host no longer lists it
real()
self.vm.tags.add(Tag.objects.create(name="prod"))
with patch("instances.views.lock_ownership", side_effect=lock):
response = self.post(self.admin, ["db"])
self.assertEqual(response.status_code, 302)
self.assertEqual(InstanceTombstone.objects.get().tags, ["prod"])
self.assertFalse(Logs.objects.filter(message__startswith="VM vt-vm: tags").exists())
def test_the_vm_list_shows_them(self):
self.vm.tags.add(Tag.objects.create(name="prod"))
html = render_to_string("instance_name_cell.html", {"instance": self.vm})
@ -124,6 +138,7 @@ class TagsApiTests(TestCase):
self.assertEqual([(c["name"], c["tags"]) for c in self.client.get("/api/v1/computes/").json()],
[("ta", ["prod"]), ("ta2", [])])
self.assertEqual([c["name"] for c in self.client.get("/api/v1/computes/?tag=prod").json()], ["ta"])
self.assertEqual([c["name"] for c in self.client.get("/api/v1/computes/?tag=PROD").json()], ["ta"])
def test_a_tag_asked_of_one_host_is_no_filter(self):
self.assertEqual(self.client.get(f"/api/v1/computes/{self.compute.id}/?tag=other").status_code, 200)

View file

@ -2405,10 +2405,12 @@ def set_tags(request, pk):
messages.error(request, " ".join(form.errors["tags"]))
return _back(request, pk, "options")
names = form.cleaned_data["tags"]
with audit_vm(request, instance, f"tags {', '.join(sorted(names)) or 'none'}"), transaction.atomic():
with audit_vm(request, instance, f"tags {', '.join(sorted(names)) or 'none'}") as entry, transaction.atomic():
lock_ownership() # not while the VM's tags are kept or given back (computes.utils.forget)
instance.tags.set(Tag.named(names))
return _back(request, pk, "options")
entry.skip = moved = _moved_meanwhile(pk, instance) # its host's list may have dropped it meanwhile
if not moved:
instance.tags.set(Tag.named(names))
return _moved(request, pk) if moved else _back(request, pk, "options")
# Buses for the empty CD-ROM of a new VM: fdc and virtio have no ejectable

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-18 19:06+0000\n"
"POT-Creation-Date: 2026-11-18 19:42+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"
@ -171,13 +171,13 @@ msgid "User Profile"
msgstr "Kullanıcı Profili"
#: accounts/templates/account.html:17 accounts/templates/profile.html:18
#: admin/forms.py:102 admin/templates/admin/user_list.html:24
#: admin/forms.py:103 admin/templates/admin/user_list.html:24
#: admin/templates/admin/user_list.html:30
msgid "Superuser"
msgstr "Süperkullanıcı"
#: accounts/templates/account.html:19 accounts/templates/profile.html:20
#: admin/forms.py:102 admin/templates/admin/user_list.html:24
#: admin/forms.py:103 admin/templates/admin/user_list.html:24
#: admin/templates/admin/user_list.html:32
msgid "Template editor"
msgstr "Şablon düzenleyici"
@ -223,7 +223,7 @@ msgid "User sections"
msgstr "Kullanıcı bölümleri"
#: accounts/templates/account.html:50 accounts/templates/account.html:58
#: admin/forms.py:220 admin/templates/admin/tag_list.html:19
#: admin/forms.py:221 admin/templates/admin/tag_list.html:19
#: computes/templates/computes/list.html:34
#: computes/templates/computes/list.html:61 computes/templates/overview.html:90
#: instances/views.py:265 vmbackups/templates/vmbackups/policies.html:17
@ -750,7 +750,11 @@ msgstr ""
msgid "See every VM and host in the lists, read-only"
msgstr "Listelerde tüm sanal makineleri ve sunucuları salt okunur görme"
#: admin/forms.py:102 admin/templates/admin/logs.html:39
#: admin/forms.py:57
msgid "There is a tag with this name already"
msgstr "Bu adla bir etiket zaten var"
#: admin/forms.py:103 admin/templates/admin/logs.html:39
#: admin/templates/admin/user_list.html:24
#: admin/templates/admin/user_list.html:34
#: computes/templates/computes/instances.html:54
@ -762,24 +766,24 @@ msgstr "Listelerde tüm sanal makineleri ve sunucuları salt okunur görme"
msgid "User"
msgstr "Kullanıcı"
#: admin/forms.py:109 admin/templates/admin/group_form.html:31
#: admin/forms.py:110 admin/templates/admin/group_form.html:31
msgid "Permissions"
msgstr "İzinler"
#: admin/forms.py:116 admin/templates/admin/group_list.html:6
#: admin/forms.py:117 admin/templates/admin/group_list.html:6
#: admin/templates/admin/group_list.html:8
#: admin/templates/admin/group_list.html:24
#: admin/templates/admin/user_form.html:124 templates/navbar.html:36
msgid "Groups"
msgstr "Gruplar"
#: admin/forms.py:170
#: admin/forms.py:171
#, python-format
msgid "NEW_USER_DEFAULT_INSTANCES: %(name)s is not exactly one VM"
msgstr ""
"NEW_USER_DEFAULT_INSTANCES: %(name)s tam olarak tek bir sanal makine değil"
#: admin/forms.py:173
#: admin/forms.py:174
#, python-format
msgid ""
"NEW_USER_DEFAULT_INSTANCES: %(name)s has an owner, and only one is allowed"
@ -787,7 +791,7 @@ msgstr ""
"NEW_USER_DEFAULT_INSTANCES: %(name)s sanal makinesinin bir sahibi var ve "
"yalnızca bir sahibe izin veriliyor"
#: admin/forms.py:221 computes/templates/computes/list.html:62
#: admin/forms.py:222 computes/templates/computes/list.html:62
#: computes/templates/overview.html:102 instances/forms.py:15
#: instances/templates/allinstances_index_grouped.html:16
#: instances/templates/allinstances_index_nongrouped.html:14
@ -797,7 +801,7 @@ msgstr ""
msgid "vCPUs"
msgstr "vCPU"
#: admin/forms.py:222 computes/templates/computes/balance.html:62
#: admin/forms.py:223 computes/templates/computes/balance.html:62
#: computes/templates/computes/bulk_migrate.html:73
#: computes/templates/computes/instances.html:57
#: computes/templates/computes/list.html:63
@ -811,7 +815,7 @@ msgstr "vCPU"
msgid "Memory"
msgstr "Bellek"
#: admin/forms.py:223 instances/models.py:241
#: admin/forms.py:224 instances/models.py:241
#: instances/templates/create_instance_w2.html:118
#: instances/templates/instances/settings_tab.html:25
#: instances/templates/instances/stats_tab.html:53 vmbackups/forms.py:57
@ -819,7 +823,7 @@ msgstr "Bellek"
msgid "Disk"
msgstr "Disk"
#: admin/forms.py:224 instances/templates/instance.html:113
#: admin/forms.py:225 instances/templates/instance.html:113
#: templates/navbar.html:21 vmbackups/templates/vmbackups/index.html:8
#: vmbackups/templates/vmbackups/index.html:10
#: vmbackups/templates/vmbackups/policies.html:8
@ -831,27 +835,27 @@ msgstr "Disk"
msgid "Backups"
msgstr "Yedekler"
#: admin/forms.py:234
#: admin/forms.py:235
msgid "No limit"
msgstr "Sınır yok"
#: admin/forms.py:250
#: admin/forms.py:251
msgid "Enter a limit or choose No limit."
msgstr "Bir sınır girin ya da Sınır yok'u seçin."
#: admin/forms.py:262
#: admin/forms.py:263
msgid "The user must change it at their next login"
msgstr "Kullanıcı bir sonraki girişinde onu değiştirmek zorundadır"
#: admin/forms.py:268
#: admin/forms.py:269
msgid "With a password"
msgstr "Parolayla"
#: admin/forms.py:268
#: admin/forms.py:269
msgid "Without a password"
msgstr "Parolasız"
#: admin/forms.py:274
#: admin/forms.py:275
msgid "A user without a password cannot be made to change it"
msgstr "Parolası olmayan bir kullanıcıya parola değiştirme zorunluluğu konamaz"
@ -1323,12 +1327,12 @@ msgid "Its owners no longer get the VM back if its UUID shows up again."
msgstr ""
"UUID'si yeniden görünse bile sahipleri sanal makineyi artık geri almaz."
#: admin/views.py:502
#: admin/views.py:507
#, python-format
msgid "Rename tag %(tag)s"
msgstr "%(tag)s etiketini yeniden adlandır"
#: admin/views.py:510
#: admin/views.py:512
#, python-format
msgid "The backup schedule %(schedules)s backs up its VMs: change it first"
msgid_plural ""
@ -1340,24 +1344,24 @@ msgstr[1] ""
"%(schedules)s yedekleme zamanlamaları bu etiketin sanal makinelerini "
"yedekliyor: önce onları değiştirin"
#: admin/views.py:519
#: admin/views.py:530
#, python-format
msgid "Tag %(tag)s deleted"
msgstr "%(tag)s etiketi silindi"
#: admin/views.py:524
#: admin/views.py:538
#, 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:525
#: admin/views.py:539
#, 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:526
#: admin/views.py:540
#, python-format
msgid "%(count)s host"
msgid_plural "%(count)s hosts"
@ -3706,7 +3710,7 @@ msgstr ""
msgid "Create VM"
msgstr "Sanal makine oluştur"
#: instances/jobs.py:928 instances/jobs.py:975 instances/views.py:2630
#: instances/jobs.py:928 instances/jobs.py:975 instances/views.py:2632
msgid "A virtual machine with this name already exists"
msgstr "Bu isimde bir sanal makine mevcut"
@ -4066,7 +4070,7 @@ msgid "Disk source"
msgstr "Disk kaynağı"
#: instances/templates/add_instance_volume.html:21
#: instances/templates/create_instance_w2.html:134 instances/views.py:2660
#: instances/templates/create_instance_w2.html:134 instances/views.py:2662
msgid "New disk"
msgstr "Yeni disk"
@ -4467,7 +4471,7 @@ msgstr "Özel CPU modelleri"
msgid "Size (GiB)"
msgstr "Boyut (GiB)"
#: instances/templates/create_instance_w2.html:161 instances/views.py:2661
#: instances/templates/create_instance_w2.html:161 instances/views.py:2663
msgid "Existing volumes"
msgstr "Mevcut birimler"
@ -4504,7 +4508,7 @@ msgstr "Aygıt"
msgid "Remove"
msgstr "Kaldır"
#: instances/templates/create_instance_w2.html:194 instances/views.py:2662
#: instances/templates/create_instance_w2.html:194 instances/views.py:2664
msgid "Clone from template"
msgstr "Şablondan klonla"
@ -7164,7 +7168,7 @@ msgstr "Ön yükleme sırası başarıyla değiştirildi."
msgid "The XML is empty"
msgstr "XML boş"
#: instances/views.py:1963 instances/views.py:2642
#: instances/views.py:1963 instances/views.py:2644
#, python-format
msgid "The XML is not well-formed: %(error)s"
msgstr "XML düzgün biçimlendirilmemiş: %(error)s"
@ -7298,12 +7302,12 @@ msgstr "Sadece bir sahibe izin verilmiştir ve bir sahip zaten eklenmiş"
msgid "%(user)s is already an owner"
msgstr "%(user)s zaten bir sahip"
#: instances/views.py:2455
#: instances/views.py:2457
#, python-format
msgid "Console settings were not saved: %(errors)s"
msgstr "Konsol ayarları kaydedilmedi: %(errors)s"
#: instances/views.py:2477
#: instances/views.py:2479
msgid ""
"Error setting console password. You should check that your instance have an "
"graphic device."
@ -7311,37 +7315,37 @@ msgstr ""
"Konsol parolası ayarlanırken hata oluştu. Sanal makinenin bir grafik aygıtına"
" sahip olduğundan emin olunuz."
#: instances/views.py:2524
#: instances/views.py:2526
msgid "Shut the VM down to change whether it is a template."
msgstr "Şablon olup olmadığını değiştirmek için sanal makineyi kapatın."
#: instances/views.py:2530
#: instances/views.py:2532
#, python-format
msgid "%(quota)s: '%(instance_name)s' stays a template."
msgstr "%(quota)s: '%(instance_name)s' şablon olarak kalıyor."
#: instances/views.py:2628
#: instances/views.py:2630
msgid "The XML has no name"
msgstr "XML'de ad yok"
#: instances/views.py:2646 webvirtcloud/middleware.py:157
#: instances/views.py:2648 webvirtcloud/middleware.py:157
#, python-format
msgid "libvirt Error - %(exception)s"
msgstr "libvirt Hatası - %(exception)s"
#: instances/views.py:2660
#: instances/views.py:2662
msgid "An empty disk of the size you set"
msgstr "Belirlediğiniz boyutta boş bir disk"
#: instances/views.py:2661
#: instances/views.py:2663
msgid "Volumes already in a pool"
msgstr "Bir havuzda zaten bulunan birimler"
#: instances/views.py:2662
#: instances/views.py:2664
msgid "A copy of a template volume"
msgstr "Bir şablon biriminin kopyası"
#: instances/views.py:2752
#: instances/views.py:2754
msgid ""
"This host has no running storage pool for the VM's disks: add or start one on"
" its Storage page."
@ -7349,29 +7353,29 @@ msgstr ""
"Bu sunucuda sanal makinenin diskleri için çalışan bir depolama havuzu yok: "
"Depolama sayfasından bir tane ekleyin ya da başlatın."
#: instances/views.py:2754
#: instances/views.py:2756
msgid "This host has no network for the VM: add one on its Networks page."
msgstr ""
"Bu sunucuda sanal makine için ağ yok: Ağlar sayfasından bir tane ekleyin."
#: instances/views.py:2786
#: instances/views.py:2788
#, python-format
msgid "The machine type is q35, not %(machine)s: UEFI Secure Boot needs it"
msgstr "Makine türü %(machine)s değil q35: UEFI Secure Boot bunu gerektiriyor"
#: instances/views.py:2815
#: instances/views.py:2817
msgid "Flavor Created"
msgstr "Flavor Oluşturuldu"
#: instances/views.py:2823
#: instances/views.py:2825
msgid "Create Flavor"
msgstr "Kullanıcı Oluştur"
#: instances/views.py:2835
#: instances/views.py:2837
msgid "Flavor Deleted"
msgstr "Flavor Silindi"
#: instances/views.py:2841
#: instances/views.py:2843
msgid "Only the size template goes; VMs made from it keep their size."
msgstr ""
"Yalnızca boyut şablonu silinir; ondan oluşturulan sanal makineler boyutlarını"

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-18 19:06+0000\n"
"POT-Creation-Date: 2026-11-18 19:42+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -168,13 +168,13 @@ msgid "User Profile"
msgstr "用户资料"
#: accounts/templates/account.html:17 accounts/templates/profile.html:18
#: admin/forms.py:102 admin/templates/admin/user_list.html:24
#: admin/forms.py:103 admin/templates/admin/user_list.html:24
#: admin/templates/admin/user_list.html:30
msgid "Superuser"
msgstr "超级用户"
#: accounts/templates/account.html:19 accounts/templates/profile.html:20
#: admin/forms.py:102 admin/templates/admin/user_list.html:24
#: admin/forms.py:103 admin/templates/admin/user_list.html:24
#: admin/templates/admin/user_list.html:32
msgid "Template editor"
msgstr "模板编辑者"
@ -218,7 +218,7 @@ msgid "User sections"
msgstr "用户页面导航"
#: accounts/templates/account.html:50 accounts/templates/account.html:58
#: admin/forms.py:220 admin/templates/admin/tag_list.html:19
#: admin/forms.py:221 admin/templates/admin/tag_list.html:19
#: computes/templates/computes/list.html:34
#: computes/templates/computes/list.html:61 computes/templates/overview.html:90
#: instances/views.py:265 vmbackups/templates/vmbackups/policies.html:17
@ -727,7 +727,11 @@ msgstr "为其可修改的虚拟机创建、恢复和删除快照"
msgid "See every VM and host in the lists, read-only"
msgstr "在列表中查看所有虚拟机和主机(只读)"
#: admin/forms.py:102 admin/templates/admin/logs.html:39
#: admin/forms.py:57
msgid "There is a tag with this name already"
msgstr "已存在同名标签"
#: admin/forms.py:103 admin/templates/admin/logs.html:39
#: admin/templates/admin/user_list.html:24
#: admin/templates/admin/user_list.html:34
#: computes/templates/computes/instances.html:54
@ -739,29 +743,29 @@ msgstr "在列表中查看所有虚拟机和主机(只读)"
msgid "User"
msgstr "用户"
#: admin/forms.py:109 admin/templates/admin/group_form.html:31
#: admin/forms.py:110 admin/templates/admin/group_form.html:31
msgid "Permissions"
msgstr "权限"
#: admin/forms.py:116 admin/templates/admin/group_list.html:6
#: admin/forms.py:117 admin/templates/admin/group_list.html:6
#: admin/templates/admin/group_list.html:8
#: admin/templates/admin/group_list.html:24
#: admin/templates/admin/user_form.html:124 templates/navbar.html:36
msgid "Groups"
msgstr "用户组"
#: admin/forms.py:170
#: admin/forms.py:171
#, python-format
msgid "NEW_USER_DEFAULT_INSTANCES: %(name)s is not exactly one VM"
msgstr "NEW_USER_DEFAULT_INSTANCES:%(name)s 不是唯一的一台虚拟机"
#: admin/forms.py:173
#: admin/forms.py:174
#, python-format
msgid ""
"NEW_USER_DEFAULT_INSTANCES: %(name)s has an owner, and only one is allowed"
msgstr "NEW_USER_DEFAULT_INSTANCES:%(name)s 已有所有者,且只允许一个所有者"
#: admin/forms.py:221 computes/templates/computes/list.html:62
#: admin/forms.py:222 computes/templates/computes/list.html:62
#: computes/templates/overview.html:102 instances/forms.py:15
#: instances/templates/allinstances_index_grouped.html:16
#: instances/templates/allinstances_index_nongrouped.html:14
@ -771,7 +775,7 @@ msgstr "NEW_USER_DEFAULT_INSTANCES:%(name)s 已有所有者,且只允许一
msgid "vCPUs"
msgstr "vCPU"
#: admin/forms.py:222 computes/templates/computes/balance.html:62
#: admin/forms.py:223 computes/templates/computes/balance.html:62
#: computes/templates/computes/bulk_migrate.html:73
#: computes/templates/computes/instances.html:57
#: computes/templates/computes/list.html:63
@ -785,7 +789,7 @@ msgstr "vCPU"
msgid "Memory"
msgstr "内存"
#: admin/forms.py:223 instances/models.py:241
#: admin/forms.py:224 instances/models.py:241
#: instances/templates/create_instance_w2.html:118
#: instances/templates/instances/settings_tab.html:25
#: instances/templates/instances/stats_tab.html:53 vmbackups/forms.py:57
@ -793,7 +797,7 @@ msgstr "内存"
msgid "Disk"
msgstr "磁盘"
#: admin/forms.py:224 instances/templates/instance.html:113
#: admin/forms.py:225 instances/templates/instance.html:113
#: templates/navbar.html:21 vmbackups/templates/vmbackups/index.html:8
#: vmbackups/templates/vmbackups/index.html:10
#: vmbackups/templates/vmbackups/policies.html:8
@ -805,27 +809,27 @@ msgstr "磁盘"
msgid "Backups"
msgstr "备份"
#: admin/forms.py:234
#: admin/forms.py:235
msgid "No limit"
msgstr "不限"
#: admin/forms.py:250
#: admin/forms.py:251
msgid "Enter a limit or choose No limit."
msgstr "请输入限制值,或选择“不限”。"
#: admin/forms.py:262
#: admin/forms.py:263
msgid "The user must change it at their next login"
msgstr "用户必须在下次登录时修改密码"
#: admin/forms.py:268
#: admin/forms.py:269
msgid "With a password"
msgstr "使用密码"
#: admin/forms.py:268
#: admin/forms.py:269
msgid "Without a password"
msgstr "不使用密码"
#: admin/forms.py:274
#: admin/forms.py:275
msgid "A user without a password cannot be made to change it"
msgstr "没有密码的用户无法被要求修改密码"
@ -1281,35 +1285,35 @@ msgstr "已删除已移除的虚拟机 %(name)s"
msgid "Its owners no longer get the VM back if its UUID shows up again."
msgstr "若其 UUID 再次出现,其所有者将不再恢复对该虚拟机的所有权。"
#: admin/views.py:502
#: admin/views.py:507
#, python-format
msgid "Rename tag %(tag)s"
msgstr "重命名标签 %(tag)s"
#: admin/views.py:510
#: admin/views.py:512
#, 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:519
#: admin/views.py:530
#, python-format
msgid "Tag %(tag)s deleted"
msgstr "标签 %(tag)s 已删除"
#: admin/views.py:524
#: admin/views.py:538
#, python-format
msgid "It is taken off %(vms)s and %(hosts)s."
msgstr "它将从 %(vms)s 和 %(hosts)s 上移除。"
#: admin/views.py:525
#: admin/views.py:539
#, python-format
msgid "%(count)s VM"
msgid_plural "%(count)s VMs"
msgstr[0] "%(count)s 个虚拟机"
#: admin/views.py:526
#: admin/views.py:540
#, python-format
msgid "%(count)s host"
msgid_plural "%(count)s hosts"
@ -3504,7 +3508,7 @@ msgstr "磁盘缓存 %(cache)s 与设置中的原生 (native) 磁盘 I/O 不兼
msgid "Create VM"
msgstr "创建虚拟机"
#: instances/jobs.py:928 instances/jobs.py:975 instances/views.py:2630
#: instances/jobs.py:928 instances/jobs.py:975 instances/views.py:2632
msgid "A virtual machine with this name already exists"
msgstr "同名虚拟机已存在"
@ -3852,7 +3856,7 @@ msgid "Disk source"
msgstr "磁盘来源"
#: instances/templates/add_instance_volume.html:21
#: instances/templates/create_instance_w2.html:134 instances/views.py:2660
#: instances/templates/create_instance_w2.html:134 instances/views.py:2662
msgid "New disk"
msgstr "新磁盘"
@ -4241,7 +4245,7 @@ msgstr "自定义 CPU 型号"
msgid "Size (GiB)"
msgstr "大小(GiB)"
#: instances/templates/create_instance_w2.html:161 instances/views.py:2661
#: instances/templates/create_instance_w2.html:161 instances/views.py:2663
msgid "Existing volumes"
msgstr "已有卷"
@ -4278,7 +4282,7 @@ msgstr "设备"
msgid "Remove"
msgstr "移除"
#: instances/templates/create_instance_w2.html:194 instances/views.py:2662
#: instances/templates/create_instance_w2.html:194 instances/views.py:2664
msgid "Clone from template"
msgstr "从模板克隆"
@ -6739,7 +6743,7 @@ msgstr "启动顺序已成功更改。"
msgid "The XML is empty"
msgstr "XML 为空"
#: instances/views.py:1963 instances/views.py:2642
#: instances/views.py:1963 instances/views.py:2644
#, python-format
msgid "The XML is not well-formed: %(error)s"
msgstr "XML 格式不正确:%(error)s"
@ -6858,75 +6862,75 @@ msgstr "只允许一个所有者,且已添加"
msgid "%(user)s is already an owner"
msgstr "%(user)s 已是所有者"
#: instances/views.py:2455
#: instances/views.py:2457
#, python-format
msgid "Console settings were not saved: %(errors)s"
msgstr "控制台设置未保存:%(errors)s"
#: instances/views.py:2477
#: instances/views.py:2479
msgid ""
"Error setting console password. You should check that your instance have an "
"graphic device."
msgstr "设置控制台密码出错。请检查虚拟机是否有图形设备。"
#: instances/views.py:2524
#: instances/views.py:2526
msgid "Shut the VM down to change whether it is a template."
msgstr "请关闭虚拟机以更改其是否为模板。"
#: instances/views.py:2530
#: instances/views.py:2532
#, python-format
msgid "%(quota)s: '%(instance_name)s' stays a template."
msgstr "%(quota)s:“%(instance_name)s”仍为模板。"
#: instances/views.py:2628
#: instances/views.py:2630
msgid "The XML has no name"
msgstr "XML 中没有名称"
#: instances/views.py:2646 webvirtcloud/middleware.py:157
#: instances/views.py:2648 webvirtcloud/middleware.py:157
#, python-format
msgid "libvirt Error - %(exception)s"
msgstr "libvirt 错误 - %(exception)s"
#: instances/views.py:2660
#: instances/views.py:2662
msgid "An empty disk of the size you set"
msgstr "按设定大小创建的空磁盘"
#: instances/views.py:2661
#: instances/views.py:2663
msgid "Volumes already in a pool"
msgstr "存储池中已有的卷"
#: instances/views.py:2662
#: instances/views.py:2664
msgid "A copy of a template volume"
msgstr "模板卷的副本"
#: instances/views.py:2752
#: instances/views.py:2754
msgid ""
"This host has no running storage pool for the VM's disks: add or start one on"
" its Storage page."
msgstr "此主机没有可用于虚拟机磁盘的运行中存储池:请在其“存储”页面添加或启动一个。"
#: instances/views.py:2754
#: instances/views.py:2756
msgid "This host has no network for the VM: add one on its Networks page."
msgstr "此主机没有可供虚拟机使用的网络:请在其“网络”页面添加一个。"
#: instances/views.py:2786
#: instances/views.py:2788
#, python-format
msgid "The machine type is q35, not %(machine)s: UEFI Secure Boot needs it"
msgstr "机器类型为 q35,而不是 %(machine)s:UEFI 安全启动需要它"
#: instances/views.py:2815
#: instances/views.py:2817
msgid "Flavor Created"
msgstr "规格已创建"
#: instances/views.py:2823
#: instances/views.py:2825
msgid "Create Flavor"
msgstr "创建规格"
#: instances/views.py:2835
#: instances/views.py:2837
msgid "Flavor Deleted"
msgstr "规格已删除"
#: instances/views.py:2841
#: instances/views.py:2843
msgid "Only the size template goes; VMs made from it keep their size."
msgstr "仅删除此规格;由它创建的虚拟机保持其大小。"

View file

@ -7,10 +7,17 @@ document.querySelectorAll("select[data-searchable]").forEach(function (select) {
});
});
// A <select multiple data-tags>: the tags there are, and a new one typed (the server checks it).
// A <select multiple data-tags>: the tags there are, and a new one typed (the
// server checks it), in lower case as the tags are kept: "Prod" is "prod".
document.querySelectorAll("select[data-tags]").forEach(function (select) {
new TomSelect(select, {
create: true, persist: false, createFilter: /^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/,
create: function (input) {
return {value: input.toLowerCase(), text: input.toLowerCase()};
},
createFilter: function (input) {
return /^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/.test(input) && !this.options[input.toLowerCase()];
},
persist: false,
render: {
// the page's own words (data-add): the library's are English
option_create: function (data, escape) {