diff --git a/instances/jobs.py b/instances/jobs.py index 8ca7a297..3842d1ab 100644 --- a/instances/jobs.py +++ b/instances/jobs.py @@ -533,7 +533,7 @@ class RevertSnapshot(Kind): # a revert gives the VM the host devices it had then: not one given since to another VM has_hostdevs, definitions = _snapshot_definitions(proxy, op.params) if has_hostdevs: - check_hostdevs(proxy, proxy.instance.name(), definitions) + check_hostdevs(proxy, proxy.instance.name(), definitions, restore=True) def run(self, op, ctx): proxy = _proxy(_instance(op.params["instance"])) diff --git a/instances/templates/instances/host_devices_form.html b/instances/templates/instances/host_devices_form.html index 51ada794..6d7bfb4d 100644 --- a/instances/templates/instances/host_devices_form.html +++ b/instances/templates/instances/host_devices_form.html @@ -4,11 +4,14 @@ {% if error %}
{% blocktrans %}The host's devices could not be read: {{ error }}{% endblocktrans %}
{% else %} +{% if unmatched %} +
{% blocktrans with problems=unmatched|join:"; " %}The VM does not start until this is fixed: {{ problems }}. Remove the device and add the one the host has.{% endblocktrans %}
+{% endif %}
{% csrf_token %} diff --git a/instances/tests/test_host_devices.py b/instances/tests/test_host_devices.py index 78de37f5..14262e93 100644 --- a/instances/tests/test_host_devices.py +++ b/instances/tests/test_host_devices.py @@ -35,26 +35,38 @@ class HostUsbViewTests(TestCase): self.proxy.wvm.listAllDevices.return_value = [node(*n) for n in NODES] self.proxy.domain_trees.side_effect = lambda: [("db-1", [etree.fromstring(other.XMLDesc())])] self.proxy.get_hostdevs.return_value = ([], [], []) + self.proxy.instance.XMLDesc.return_value = domain() def test_the_form_offers_what_can_be_given_and_says_why_not(self): page = html.fromstring(self.client.get(reverse("instances:host_devices", args=[self.instance.id])).content) options = {o.get("value"): (o.get("disabled") is not None, o.text_content()) for o in page.xpath("//select[@name='usb_device']/option[@value!='']")} - self.assertEqual(sorted(options), ["1/1", "1/2", "1/3"]) - self.assertTrue(options["1/1"][0] and "is a hub" in options["1/1"][1]) - self.assertTrue(options["1/3"][0] and "is given to db-1" in options["1/3"][1]) - self.assertFalse(options["1/2"][0]) + self.assertEqual(sorted(options), ["1/1/1d6b:0001", "1/2/0627:0001", "1/3/0627:0001"]) + self.assertTrue(options["1/1/1d6b:0001"][0] and "is a hub" in options["1/1/1d6b:0001"][1]) + self.assertTrue(options["1/3/0627:0001"][0] and "is given to db-1" in options["1/3/0627:0001"][1]) + self.assertFalse(options["1/2/0627:0001"][0]) # a device the VM has already self.proxy.domain_trees.side_effect = lambda: [("kiosk-1", [etree.fromstring(domain(by_model("
")))])] page = html.fromstring(self.client.get(reverse("instances:host_devices", args=[self.instance.id])).content) - self.assertEqual(page.xpath("//option[@value='1/2']/@disabled"), ["disabled"]) + self.assertEqual(page.xpath("//option[@value='1/2/0627:0001']/@disabled"), ["disabled"]) + + def test_the_form_says_which_usb_device_of_the_vm_the_host_cannot_give(self): + url = reverse("instances:host_devices", args=[self.instance.id]) + for given, warning in (("
", None), + ("
", "USB device 0627:0001 at 1/9 is not on the host"), + ("", "the host has 2 of USB device 0627:0001: name the one to give by its address")): + self.proxy.instance.XMLDesc.return_value = domain(by_model(given)) + alerts = html.fromstring(self.client.get(url).content).xpath("//div[contains(@class, 'alert-warning')]") + with self.subTest(given=given): + self.assertEqual([warning in a.text_content() for a in alerts], [True] if warning else []) def test_a_device_is_given_by_address_when_the_host_has_several_of_its_model(self): url = reverse("instances:add_usb_hostdev", args=[self.instance.id]) - response = self.client.post(url, {"usb_device": "1/2"}) + response = self.client.post(url, {"usb_device": "1/2/0627:0001"}) self.assertEqual(response.status_code, 302) self.proxy.add_usb_hostdev.assert_called_once_with("0x0627", "0x0001", (1, 2)) - # refused on the server too: another VM's device, a hub - for chosen, why in (("1/3", "is given to db-1"), ("1/1", "is a hub"), ("9/9", "has no USB device")): + # refused on the server too: another VM's device, a hub, one gone, another device at the address + for chosen, why in (("1/3/0627:0001", "is given to db-1"), ("1/1/1d6b:0001", "is a hub"), + ("9/9/0627:0001", "has no USB device"), ("1/2/1d6b:0001", "reload the page")): response = self.client.post(url, {"usb_device": chosen}) with self.subTest(chosen=chosen): self.assertIn(why, " ".join(str(m) for m in get_messages(response.wsgi_request))) @@ -62,7 +74,7 @@ class HostUsbViewTests(TestCase): def test_a_device_is_given_by_model_when_the_host_has_one_of_it(self): self.proxy.wvm.listAllDevices.return_value = [node(*n) for n in NODES if n[0] not in ("usb_1_2", "usb_1_2_1_0")] - self.client.post(reverse("instances:add_usb_hostdev", args=[self.instance.id]), {"usb_device": "1/2"}) + self.client.post(reverse("instances:add_usb_hostdev", args=[self.instance.id]), {"usb_device": "1/2/0627:0001"}) self.proxy.add_usb_hostdev.assert_called_once_with("0x0627", "0x0001", None) def test_a_pci_device_is_given_when_it_can_be(self): diff --git a/instances/views.py b/instances/views.py index 5ca77c3c..7e72ef9a 100755 --- a/instances/views.py +++ b/instances/views.py @@ -49,6 +49,7 @@ from libvirt import (VIR_DOMAIN_PAUSED, VIR_ERR_NO_SUPPORT, libvirtError) from logs.audit import audit, audit_vm, failed_vm +from lxml import etree from operations import claims, jobs from operations.utils import HOST_BUSY, busy_message, summary from webvirtcloud.middleware import error_text, same_origin_referer @@ -57,7 +58,7 @@ from vrtManager.connection import CONNECT_TIMEOUT from vrtManager.create import cpu_choices, wvmCreate from vrtManager.instance import USAGE_MAX_WINDOW, wvmInstances from vrtManager.interface import wvmInterface -from vrtManager.nodedevs import device_names, hostdev_problems, node_devices, pci_problems +from vrtManager.nodedevs import device_names, hostdev_problems, node_devices, pci_problems, usb_unmatched from vrtManager.storage import rbd_source_children, wvmStorage from vrtManager.util import randomPasswd @@ -2118,7 +2119,10 @@ def host_devices(request, pk): pci, usb = _host_devices(instance) domain = instance.proxy.instance state = domain.info()[0] + # the VM's next start takes its USB devices as its definition names them + unmatched = usb_unmatched([etree.fromstring(domain.XMLDesc(VIR_DOMAIN_XML_INACTIVE))], usb) context = {"instance": instance, "host_pci": pci, "host_usb": usb, "running": state == VIR_DOMAIN_RUNNING, + "unmatched": [util.render(m["text"], m["values"], _) for m in unmatched], # paused, or with a saved state the VM would start from without the change "pci_frozen": state not in (VIR_DOMAIN_RUNNING, VIR_DOMAIN_SHUTOFF) or domain.hasManagedSaveImage(0)} except libvirtError as err: @@ -2134,9 +2138,10 @@ def add_usb_hostdev(request, pk): claim, so no other VM gets it meanwhile.""" instance = get_instance(request.user, pk) chosen = request.POST.get("usb_device", "") - device = next((d for d in _host_devices(instance)[1] if f"{d['bus']}/{d['device']}" == chosen), None) + # the address and the IDs: a device replugged meanwhile may have another's address + device = next((d for d in _host_devices(instance)[1] if f"{d['bus']}/{d['device']}/{d['ids']}" == chosen), None) if device is None: - messages.error(request, _("The host has no USB device %(device)s") % {"device": chosen}) + messages.error(request, _("The host has no USB device %(device)s; reload the page") % {"device": chosen}) elif device["problems"]: messages.error(request, "; ".join(device["problems"])) else: diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index 5746aa17..39a68007 100644 Binary files a/locale/tr/LC_MESSAGES/django.mo and b/locale/tr/LC_MESSAGES/django.mo differ diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po index 48885ae4..4ea6346c 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -11,7 +11,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-11 12:16+0000\n" +"POT-Creation-Date: 2026-11-11 13:15+0000\n" "PO-Revision-Date: 2020-11-04 12:00+0000\n" "Last-Translator: catborise , 2020\n" "Language-Team: Turkish (https://www.transifex.com/catborise/teams/110663/tr/)\n" @@ -938,7 +938,7 @@ msgid "IP" msgstr "IP" #: admin/templates/admin/logs.html:56 admin/views.py:292 instances/states.py:19 -#: instances/views.py:422 instances/views.py:424 logs/views.py:18 +#: instances/views.py:423 instances/views.py:425 logs/views.py:18 msgid "Unknown" msgstr "Bilinmeyen" @@ -1808,8 +1808,8 @@ msgstr "Kaydedildi: %(settings)s" msgid "Nothing changed" msgstr "Hiçbir şey değişmedi" -#: appsettings/views.py:123 vrtManager/nodedevs.py:219 -#: vrtManager/nodedevs.py:258 +#: appsettings/views.py:123 vrtManager/nodedevs.py:247 +#: vrtManager/nodedevs.py:286 msgid "Other" msgstr "Diğer" @@ -2687,7 +2687,7 @@ msgstr "" "VNC olarak değiştirin." #: instances/api/viewsets.py:149 instances/api/viewsets.py:167 -#: instances/views.py:810 instances/views.py:828 instances/views.py:1797 +#: instances/views.py:811 instances/views.py:829 instances/views.py:1798 msgid "Templates cannot be started." msgstr "Şablon makineler başlatılamaz." @@ -3029,7 +3029,7 @@ msgstr "" msgid "Create VM" msgstr "Sanal makine oluştur" -#: instances/jobs.py:883 instances/jobs.py:925 instances/views.py:2501 +#: instances/jobs.py:883 instances/jobs.py:925 instances/views.py:2506 msgid "A virtual machine with this name already exists" msgstr "Bu isimde bir sanal makine mevcut" @@ -3388,7 +3388,7 @@ msgid "Disk source" msgstr "Disk kaynağı" #: instances/templates/add_instance_volume.html:21 -#: instances/templates/create_instance_w2.html:134 instances/views.py:2520 +#: instances/templates/create_instance_w2.html:134 instances/views.py:2525 msgid "New disk" msgstr "Yeni disk" @@ -3774,7 +3774,7 @@ msgstr "Özel CPU modelleri" msgid "Size (GiB)" msgstr "Boyut (GiB)" -#: instances/templates/create_instance_w2.html:161 instances/views.py:2521 +#: instances/templates/create_instance_w2.html:161 instances/views.py:2526 msgid "Existing volumes" msgstr "Mevcut birimler" @@ -3810,7 +3810,7 @@ msgstr "Aygıt" msgid "Remove" msgstr "Kaldır" -#: instances/templates/create_instance_w2.html:194 instances/views.py:2522 +#: instances/templates/create_instance_w2.html:194 instances/views.py:2527 msgid "Clone from template" msgstr "Şablondan klonla" @@ -4345,41 +4345,50 @@ msgid "The host's devices could not be read: %(error)s" msgstr "Sunucunun aygıtları okunamadı: %(error)s" #: instances/templates/instances/host_devices_form.html:8 +#, python-format +msgid "" +"The VM does not start until this is fixed: %(problems)s. Remove the device " +"and add the one the host has." +msgstr "" +"Bu düzeltilene kadar sanal makine başlamaz: %(problems)s. Aygıtı kaldırın ve " +"sunucudakini ekleyin." + +#: instances/templates/instances/host_devices_form.html:11 msgid "USB device of the host" msgstr "Sunucunun USB aygıtı" -#: instances/templates/instances/host_devices_form.html:9 +#: instances/templates/instances/host_devices_form.html:12 msgid "Choose a USB device of the host…" msgstr "Sunucunun bir USB aygıtını seçin…" -#: instances/templates/instances/host_devices_form.html:14 +#: instances/templates/instances/host_devices_form.html:17 msgid "Add USB device" msgstr "USB aygıtı ekle" -#: instances/templates/instances/host_devices_form.html:17 +#: instances/templates/instances/host_devices_form.html:20 msgid "PCI device of the host" msgstr "Sunucunun PCI aygıtı" -#: instances/templates/instances/host_devices_form.html:18 +#: instances/templates/instances/host_devices_form.html:21 msgid "Choose a PCI device of the host…" msgstr "Sunucunun bir PCI aygıtını seçin…" -#: instances/templates/instances/host_devices_form.html:20 +#: instances/templates/instances/host_devices_form.html:23 msgid "no driver" msgstr "sürücü yok" -#: instances/templates/instances/host_devices_form.html:23 +#: instances/templates/instances/host_devices_form.html:26 msgid "Add PCI device" msgstr "PCI aygıtı ekle" -#: instances/templates/instances/host_devices_form.html:25 +#: instances/templates/instances/host_devices_form.html:28 msgid "" "A paused VM, or one with a saved state, does not change its PCI devices." msgstr "" "Duraklatılmış ya da kayıtlı durumu olan bir sanal makinenin PCI aygıtları " "değiştirilemez." -#: instances/templates/instances/host_devices_form.html:26 +#: instances/templates/instances/host_devices_form.html:29 msgid "" "The device is plugged into the running VM at once and kept for its next " "start; libvirt binds it to vfio-pci. It needs a free slot: on a q35 VM a free" @@ -4389,7 +4398,7 @@ msgstr "" "korunur; libvirt onu vfio-pci'ye bağlar. Boş bir yuva gerekir: q35 sanal " "makinede, sanal makine kapalıyken eklenmiş boş bir pcie-root-port." -#: instances/templates/instances/host_devices_form.html:27 +#: instances/templates/instances/host_devices_form.html:30 msgid "" "libvirt binds the device to vfio-pci when the VM starts, and gives it back to" " the host when the VM stops; a device bound to vfio-pci before stays bound to" @@ -6027,43 +6036,43 @@ msgstr "Geçersiz MAC adresi" msgid "More MAC addresses than networks" msgstr "Ağlardan daha fazla MAC adresi" -#: instances/views.py:175 +#: instances/views.py:176 msgid "Enter an IP address, a network such as 192.0.2.0/24, or a MAC address." msgstr "Bir IP adresi, 192.0.2.0/24 gibi bir ağ ya da bir MAC adresi girin." -#: instances/views.py:181 instances/views.py:215 +#: instances/views.py:182 instances/views.py:216 msgid "Too many searches are still running; try again shortly." msgstr "Çok fazla arama hâlâ çalışıyor; birazdan yeniden deneyin." -#: instances/views.py:263 +#: instances/views.py:264 #, python-format msgid "The host %(host)s of '%(name)s' cannot be reached: %(error)s" msgstr "'%(name)s' sanal makinesinin sunucusu %(host)s erişilemiyor: %(error)s" -#: instances/views.py:269 +#: instances/views.py:270 #, python-format msgid "The host of '%(name)s' cannot be reached right now." msgstr "'%(name)s' sanal makinesinin sunucusuna şu anda erişilemiyor." -#: instances/views.py:270 +#: instances/views.py:271 msgid " Jobs on it can be followed under Jobs in the menu." msgstr " Üzerindeki işler menüdeki İşler bölümünden izlenebilir." -#: instances/views.py:278 +#: instances/views.py:279 #, python-format msgid "'%(name)s' is no longer on its host." msgstr "'%(name)s' artık sunucusunda yok." -#: instances/views.py:365 +#: instances/views.py:366 msgid "There is no other host to migrate to." msgstr "Taşınacak başka bir sunucu yok." -#: instances/views.py:367 +#: instances/views.py:368 msgid "A VM migrates when it is running, paused or shut off." msgstr "" "Sanal makine çalışırken, duraklatılmışken ya da kapalıyken taşınabilir." -#: instances/views.py:369 +#: instances/views.py:370 msgid "" "A VM with snapshots cannot be migrated: its snapshots stay on this host. " "Delete them first." @@ -6071,7 +6080,7 @@ msgstr "" "Anlık görüntüsü olan bir sanal makine taşınamaz: anlık görüntüleri bu " "sunucuda kalır. Önce onları silin." -#: instances/views.py:371 +#: instances/views.py:372 msgid "" "A VM with host devices cannot be migrated: the destination may not have them." " Remove them first." @@ -6079,16 +6088,16 @@ msgstr "" "Sunucu aygıtları olan bir sanal makine taşınamaz: hedefte bu aygıtlar " "olmayabilir. Önce onları kaldırın." -#: instances/views.py:583 +#: instances/views.py:584 #, python-format msgid "Disk %(dev)s has changed since the page was loaded; reload the page" msgstr "%(dev)s diski sayfa yüklendikten sonra değişti; sayfayı yenileyin" -#: instances/views.py:658 instances/views.py:659 +#: instances/views.py:659 instances/views.py:660 msgid "The VM was moved meanwhile; try again." msgstr "Sanal makine bu arada taşındı; yeniden deneyin." -#: instances/views.py:775 +#: instances/views.py:776 msgid "" "The running VM has no free PCI slot for another disk on this bus: choose the " "scsi bus if the VM has a SCSI controller, or shut the VM down and add the " @@ -6101,7 +6110,7 @@ msgstr "" "yuvaları ekle, sonraki başlatmadan itibaren ona boş yuvalar verir. Yeni bir " "birim havuzunda kalır, mevcut birim olarak eklenebilir." -#: instances/views.py:779 +#: instances/views.py:780 msgid "" "The running VM has no free PCI slot for the SCSI controller the disk needs: " "shut the VM down and add the disk then; Add PCIe slots on the Disks tab gives" @@ -6113,181 +6122,181 @@ msgstr "" "PCIe yuvaları ekle, sonraki başlatmadan itibaren ona boş yuvalar verir. Yeni " "bir birim havuzunda kalır, mevcut birim olarak eklenebilir." -#: instances/views.py:797 +#: instances/views.py:798 #, python-format msgid "Invalid disk options: %(options)s" msgstr "Geçersiz disk seçenekleri: %(options)s" -#: instances/views.py:836 +#: instances/views.py:837 msgid "The VM was forced off but did not start again: it stays off." msgstr "Sanal makine zorla kapatıldı ancak yeniden başlamadı: kapalı kalıyor." -#: instances/views.py:1021 +#: instances/views.py:1022 #, python-format msgid "Set the gstfsd key of %(compute)s first (Computes, edit the host)" msgstr "" "Önce %(compute)s sunucusunun gstfsd anahtarını ayarlayın (Sunucular, sunucuyu" " düzenle)" -#: instances/views.py:1028 instances/views.py:1046 instances/views.py:1055 +#: instances/views.py:1029 instances/views.py:1047 instances/views.py:1056 #, python-format msgid "gstfsd error: %(err)s" msgstr "gstfsd hatası: %(err)s" -#: instances/views.py:1056 +#: instances/views.py:1057 msgid "the reply is not signed with the key" msgstr "yanıt anahtarla imzalanmamış" -#: instances/views.py:1064 +#: instances/views.py:1065 msgid "Shut the VM down, or start its QEMU guest agent, and try again" msgstr "" "Sanal makineyi kapatın ya da QEMU konuk ajanını başlatın ve yeniden deneyin" -#: instances/views.py:1077 +#: instances/views.py:1078 msgid "The change may still be made when the agent answers again." msgstr "Ajan yeniden yanıt verdiğinde değişiklik yine de yapılabilir." -#: instances/views.py:1105 +#: instances/views.py:1106 msgid "Reset root password" msgstr "Root parolasını sıfırla" -#: instances/views.py:1109 +#: instances/views.py:1110 msgid "Enter a password" msgstr "Bir parola girin" -#: instances/views.py:1123 +#: instances/views.py:1124 msgid "Select an SSH public key" msgstr "Bir SSH açık anahtarı seçin" -#: instances/views.py:1145 +#: instances/views.py:1146 #, python-format msgid "Installed new SSH public key %(keyname)s" msgstr "Yeni %(keyname)s SSH açık anahtarı yüklendi" -#: instances/views.py:1165 +#: instances/views.py:1166 msgid "Enter a whole number of vCPUs" msgstr "vCPU sayısı için bir tam sayı girin" -#: instances/views.py:1169 +#: instances/views.py:1170 msgid "Shut off the VM to change its vCPUs" msgstr "vCPU'larını değiştirmek için sanal makineyi kapatın" -#: instances/views.py:1172 +#: instances/views.py:1173 msgid "The current vCPUs cannot be more than the maximum" msgstr "Geçerli vCPU sayısı en fazla değerden büyük olamaz" -#: instances/views.py:1179 +#: instances/views.py:1180 #, python-format msgid "%(quota)s: cannot resize the CPU of '%(instance_name)s'." msgstr "%(quota)s: '%(instance_name)s' CPU'su yeniden boyutlandırılamıyor." -#: instances/views.py:1187 +#: instances/views.py:1188 #, python-format msgid "vCPUs set to %(cur)s (maximum %(max)s)" msgstr "vCPU sayısı %(cur)s olarak ayarlandı (en fazla %(max)s)" -#: instances/views.py:1206 +#: instances/views.py:1207 msgid "Enter a whole number for memory" msgstr "Bellek için bir tam sayı girin" -#: instances/views.py:1209 +#: instances/views.py:1210 msgid "The current memory cannot be more than the maximum" msgstr "Geçerli bellek en fazla değerden büyük olamaz" -#: instances/views.py:1213 +#: instances/views.py:1214 #, python-format msgid "%(quota)s: cannot resize the memory of '%(instance_name)s'." msgstr "%(quota)s: '%(instance_name)s' belleği yeniden boyutlandırılamıyor." -#: instances/views.py:1219 +#: instances/views.py:1220 #, python-format msgid "Memory set to %(cur)s MiB (maximum %(max)s MiB)" msgstr "Bellek %(cur)s MiB olarak ayarlandı (en fazla %(max)s MiB)" -#: instances/views.py:1239 +#: instances/views.py:1240 msgid "Enter disk sizes as whole GiB" msgstr "Disk boyutlarını tam GiB olarak girin" -#: instances/views.py:1243 +#: instances/views.py:1244 #, python-format msgid "%(dev)s is %(size)s: a disk cannot shrink" msgstr "%(dev)s boyutu %(size)s: disk küçültülemez" -#: instances/views.py:1251 +#: instances/views.py:1252 msgid "No disks were selected or valid for resizing." msgstr "Boyutlandırma için seçilmiş ya da geçerli disk yok." -#: instances/views.py:1260 +#: instances/views.py:1261 #, python-format msgid "%(quota)s: cannot resize the disks of '%(instance_name)s'." msgstr "%(quota)s: '%(instance_name)s' diskleri yeniden boyutlandırılamıyor." -#: instances/views.py:1272 +#: instances/views.py:1273 #, python-format msgid "The storage pool of %(dev)s cannot resize its volumes" msgstr "%(dev)s diskinin depolama havuzu birimlerini boyutlandıramaz" -#: instances/views.py:1274 +#: instances/views.py:1275 #, python-format msgid "Disk is resized: %(dev)s" msgstr "Disk boyutu değiştirildi: %(dev)s" -#: instances/views.py:1368 +#: instances/views.py:1369 msgid "The VM's machine has no PCIe slots to add" msgstr "Sanal makinenin makine tipinde eklenecek PCIe yuvası yok" -#: instances/views.py:1373 +#: instances/views.py:1374 #, python-format msgid "%(count)s PCIe slots added" msgstr "%(count)s PCIe yuvası eklendi" -#: instances/views.py:1375 +#: instances/views.py:1376 #, python-format msgid "%(count)s PCIe slots added: the VM gets them at its next start" msgstr "" "%(count)s PCIe yuvası eklendi: sanal makine bunları sonraki başlatmasında " "alır" -#: instances/views.py:1421 +#: instances/views.py:1422 #, python-format msgid "%(volume)s is already a disk of this VM" msgstr "%(volume)s zaten bu sanal makinenin bir diski" -#: instances/views.py:1511 +#: instances/views.py:1512 msgid "Volume changes are applied. But it will be activated after shutdown" msgstr "" "Birim değişiklikleri uygulandı. Ama yeniden başlatıldıktan sonra uygulanacak" -#: instances/views.py:1516 +#: instances/views.py:1517 msgid "Volume is changed successfully." msgstr "Birim başarıyla değiştirildi." -#: instances/views.py:1536 +#: instances/views.py:1537 #, python-format msgid "Disk %(dev)s is not a storage volume of this instance" msgstr "%(dev)s diski bu sanal makinenin bir depolama birimi değil" -#: instances/views.py:1541 vrtManager/instance.py:2309 +#: instances/views.py:1542 vrtManager/instance.py:2309 msgid "The VM has a saved state; start it or remove the saved state first" msgstr "" "Sanal makinenin kaydedilmiş durumu var; önce başlatın veya kaydedilmiş durumu" " kaldırın" -#: instances/views.py:1547 +#: instances/views.py:1548 #, python-format msgid "Disk %(dev)s has a pending change; delete it once the VM is shut down" msgstr "" "%(dev)s diskinin bekleyen bir değişikliği var; sanal makine kapatıldığında " "silin" -#: instances/views.py:1562 +#: instances/views.py:1563 #, python-format msgid "Volume %(vol)s is used by another VM; detach it instead" msgstr "" "%(vol)s birimi başka bir sanal makine tarafından kullanılıyor; onun yerine " "ayırın" -#: instances/views.py:1574 +#: instances/views.py:1575 #, python-format msgid "" "The guest has not released disk %(dev)s yet; volume %(vol)s was kept. Delete " @@ -6296,66 +6305,66 @@ msgstr "" "Konuk sistem %(dev)s diskini henüz bırakmadı; %(vol)s birimi korundu. Sanal " "makine kapatıldığında depolama havuzundan silin." -#: instances/views.py:1585 +#: instances/views.py:1586 #, python-format msgid "Disk %(dev)s was detached, but its volume was kept: %(err)s" msgstr "%(dev)s diski ayrıldı, ancak birimi korundu: %(err)s" -#: instances/views.py:1613 +#: instances/views.py:1614 #, python-format msgid "This VM cannot take a CD-ROM on the %(bus)s bus now" msgstr "Bu sanal makineye şu anda %(bus)s veri yolunda CD-ROM eklenemez" -#: instances/views.py:1616 +#: instances/views.py:1617 msgid "A USB CD-ROM needs an ISO image: libvirt has no empty USB drive" msgstr "USB CD-ROM bir ISO imajı ister: libvirt boş USB sürücü desteklemiyor" -#: instances/views.py:1621 +#: instances/views.py:1622 #, python-format msgid "%(image)s is already in a CD-ROM of this VM" msgstr "%(image)s bu sanal makinenin bir CD-ROM'unda zaten takılı" -#: instances/views.py:1702 +#: instances/views.py:1703 #, python-format msgid "Pool %(pool)s was not read again: %(err)s" msgstr "%(pool)s havuzu yeniden okunamadı: %(err)s" -#: instances/views.py:1723 +#: instances/views.py:1724 #, python-format msgid "Snapshot was not deleted: %(err)s" msgstr "Anlık görüntü silinmedi: %(err)s" -#: instances/views.py:1841 +#: instances/views.py:1842 msgid "Add at least one device to the boot order." msgstr "Ön yükleme sırasına en az bir aygıt ekleyin." -#: instances/views.py:1847 vrtManager/instance.py:1108 +#: instances/views.py:1848 vrtManager/instance.py:1108 msgid "Invalid Device Type for boot order" msgstr "Ön yükleme sırası için geçersiz aygıt türü" -#: instances/views.py:1858 +#: instances/views.py:1859 msgid "Boot order changed. It applies at the next start." msgstr "Ön yükleme sırası değiştirildi. Sonraki başlatmada uygulanır." -#: instances/views.py:1860 +#: instances/views.py:1861 msgid "Boot order changed successfully." msgstr "Ön yükleme sırası başarıyla değiştirildi." -#: instances/views.py:1880 +#: instances/views.py:1881 msgid "The XML is empty" msgstr "XML boş" -#: instances/views.py:1884 instances/views.py:2511 +#: instances/views.py:1885 instances/views.py:2516 #, python-format msgid "The XML is not well-formed: %(error)s" msgstr "XML düzgün biçimlendirilmemiş: %(error)s" -#: instances/views.py:1886 +#: instances/views.py:1887 #, python-format msgid "The XML must keep the VM's UUID %(uuid)s." msgstr "XML, sanal makinenin %(uuid)s UUID'sini korumalıdır." -#: instances/views.py:1890 +#: instances/views.py:1891 msgid "" "The definition has changed since the editor was opened. Reload the page to " "edit the current one." @@ -6363,40 +6372,40 @@ msgstr "" "Düzenleyici açıldığından beri tanım değişti. Geçerli tanımı düzenlemek için " "sayfayı yeniden yükleyin." -#: instances/views.py:1902 +#: instances/views.py:1903 msgid "The XML definition was saved." msgstr "XML tanımı kaydedildi." -#: instances/views.py:1904 +#: instances/views.py:1905 msgid "The XML definition was saved; the VM uses it from its next start." msgstr "" "XML tanımı kaydedildi; sanal makine onu sonraki başlatmasından itibaren " "kullanır." -#: instances/views.py:1985 +#: instances/views.py:1986 msgid "Select one network interface to change" msgstr "Değiştirilecek bir ağ arabirimi seçin" -#: instances/views.py:2023 +#: instances/views.py:2024 msgid "Network Device Config is changed. Please shutdown instance to activate." msgstr "" "Ağ aygıtı yapılandırması değiştirildi. Aktifleştirmek için lütfen sanal " "makineyi kapatın." -#: instances/views.py:2025 +#: instances/views.py:2026 msgid "Network device changed" msgstr "Ağ aygıtı değiştirildi" -#: instances/views.py:2037 +#: instances/views.py:2038 msgid "No network selected" msgstr "Ağ seçilmedi" -#: instances/views.py:2042 +#: instances/views.py:2043 #, python-format msgid "The VM already has a network device with MAC %(mac)s" msgstr "Sanal makinede %(mac)s MAC adresli bir ağ aygıtı zaten var" -#: instances/views.py:2061 +#: instances/views.py:2062 msgid "" "The running VM has no free PCI slot for another network device: shut it down " "and add the device then; Add PCIe slots on the Disks tab gives it free ones " @@ -6406,21 +6415,21 @@ msgstr "" "aygıtı sonra ekleyin; Diskler sekmesindeki PCIe yuvaları ekle, sonraki " "başlatmadan itibaren ona boş yuvalar verir." -#: instances/views.py:2102 instances/views.py:2108 +#: instances/views.py:2103 instances/views.py:2109 msgid "The VM has it" msgstr "Sanal makinede var" -#: instances/views.py:2139 +#: instances/views.py:2144 #, python-format -msgid "The host has no USB device %(device)s" -msgstr "Sunucuda %(device)s USB aygıtı yok" +msgid "The host has no USB device %(device)s; reload the page" +msgstr "Sunucuda %(device)s USB aygıtı yok; sayfayı yeniden yükleyin" -#: instances/views.py:2160 +#: instances/views.py:2165 #, python-format msgid "The host has no PCI device %(device)s" msgstr "Sunucuda %(device)s PCI aygıtı yok" -#: instances/views.py:2178 +#: instances/views.py:2183 #, python-format msgid "" "Removal of PCI device %(address)s requested: the guest has not let it go yet;" @@ -6430,20 +6439,20 @@ msgstr "" "bırakmadı; bırakana ya da sanal makine durana kadar çalışan sanal makinede " "kalır." -#: instances/views.py:2223 instances/views.py:2253 +#: instances/views.py:2228 instances/views.py:2258 msgid "Select a network interface and a QoS direction" msgstr "Bir ağ arabirimi ve bir QoS yönü seçin" -#: instances/views.py:2226 vrtManager/network.py:454 +#: instances/views.py:2231 vrtManager/network.py:454 msgid "QoS rates must be whole numbers" msgstr "QoS hızları tam sayı olmalıdır" -#: instances/views.py:2233 networks/views.py:229 +#: instances/views.py:2238 networks/views.py:229 #, python-format msgid "%(qos_dir)s QoS is set" msgstr "%(qos_dir)s QoS ayarlandı" -#: instances/views.py:2238 +#: instances/views.py:2243 #, python-format msgid "" "%(qos_dir)s QoS is set. A running VM gets it after it is powered off and on." @@ -6451,12 +6460,12 @@ msgstr "" "%(qos_dir)s QoS ayarlandı. Çalışan bir sanal makine, kapatılıp açıldıktan " "sonra bunu alır." -#: instances/views.py:2260 networks/views.py:255 +#: instances/views.py:2265 networks/views.py:255 #, python-format msgid "%(qos_dir)s QoS is deleted" msgstr "%(qos_dir)s QoS silindi" -#: instances/views.py:2265 +#: instances/views.py:2270 #, python-format msgid "" "%(qos_dir)s QoS is deleted. A running VM keeps the old limit until it is " @@ -6465,21 +6474,21 @@ msgstr "" "%(qos_dir)s QoS silindi. Çalışan bir sanal makine, kapatılıp açılana kadar " "eski sınırı korur." -#: instances/views.py:2293 +#: instances/views.py:2298 msgid "Only one owner is allowed and the one already added" msgstr "Sadece bir sahibe izin verilmiştir ve bir sahip zaten eklenmiş" -#: instances/views.py:2295 +#: instances/views.py:2300 #, python-format msgid "%(user)s is already an owner" msgstr "%(user)s zaten bir sahip" -#: instances/views.py:2340 +#: instances/views.py:2345 #, python-format msgid "Console settings were not saved: %(errors)s" msgstr "Konsol ayarları kaydedilmedi: %(errors)s" -#: instances/views.py:2362 +#: instances/views.py:2367 msgid "" "Error setting console password. You should check that your instance have an " "graphic device." @@ -6487,37 +6496,37 @@ msgstr "" "Konsol parolası ayarlanırken hata oluştu. Sanal makinenin bir grafik aygıtına" " sahip olduğundan emin olunuz." -#: instances/views.py:2409 +#: instances/views.py:2414 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:2415 +#: instances/views.py:2420 #, python-format msgid "%(quota)s: '%(instance_name)s' stays a template." msgstr "%(quota)s: '%(instance_name)s' şablon olarak kalıyor." -#: instances/views.py:2499 +#: instances/views.py:2504 msgid "The XML has no name" msgstr "XML'de ad yok" -#: instances/views.py:2513 webvirtcloud/middleware.py:156 +#: instances/views.py:2518 webvirtcloud/middleware.py:156 #, python-format msgid "libvirt Error - %(exception)s" msgstr "libvirt Hatası - %(exception)s" -#: instances/views.py:2520 +#: instances/views.py:2525 msgid "An empty disk of the size you set" msgstr "Belirlediğiniz boyutta boş bir disk" -#: instances/views.py:2521 +#: instances/views.py:2526 msgid "Volumes already in a pool" msgstr "Bir havuzda zaten bulunan birimler" -#: instances/views.py:2522 +#: instances/views.py:2527 msgid "A copy of a template volume" msgstr "Bir şablon biriminin kopyası" -#: instances/views.py:2600 +#: instances/views.py:2605 msgid "" "This host has no running storage pool for the VM's disks: add or start one on" " its Storage page." @@ -6525,29 +6534,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:2602 +#: instances/views.py:2607 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:2634 +#: instances/views.py:2639 #, 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:2661 +#: instances/views.py:2666 msgid "Flavor Created" msgstr "Flavor Oluşturuldu" -#: instances/views.py:2669 +#: instances/views.py:2674 msgid "Create Flavor" msgstr "Kullanıcı Oluştur" -#: instances/views.py:2681 +#: instances/views.py:2686 msgid "Flavor Deleted" msgstr "Flavor Silindi" -#: instances/views.py:2687 +#: instances/views.py:2692 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ı" @@ -9970,24 +9979,41 @@ msgstr "" "%(device)s, %(group)s numaralı IOMMU grubunu sunucunun kullandığı %(member)s " "(%(product)s, sürücü %(driver)s) ile paylaşıyor" -#: vrtManager/nodedevs.py:187 +#: vrtManager/nodedevs.py:195 +#, python-format +msgid "USB device %(ids)s" +msgstr "USB aygıtı %(ids)s" + +#: vrtManager/nodedevs.py:197 +#, python-format +msgid "USB device %(ids)s at %(bus)s/%(device)s" +msgstr "%(bus)s/%(device)s adresindeki USB aygıtı %(ids)s" + +#: vrtManager/nodedevs.py:200 vrtManager/nodedevs.py:215 #, python-format msgid "%(device)s is not on the host" msgstr "%(device)s sunucuda yok" -#: vrtManager/nodedevs.py:198 +#: vrtManager/nodedevs.py:203 +#, python-format +msgid "" +"the host has %(count)s of %(device)s: name the one to give by its address" +msgstr "" +"sunucuda %(count)s adet %(device)s var: verilecek olanı adresiyle belirtin" + +#: vrtManager/nodedevs.py:226 #, python-format msgid "%(device)s is a hub" msgstr "%(device)s bir hub" -#: vrtManager/nodedevs.py:202 +#: vrtManager/nodedevs.py:230 #, python-format msgid "%(device)s is on the PCI controller %(controller)s, given to %(vms)s" msgstr "" "%(device)s, %(vms)s sanal makinesine verilmiş %(controller)s PCI " "denetleyicisinde" -#: vrtManager/nodedevs.py:332 +#: vrtManager/nodedevs.py:360 #, python-format msgid "%(problems)s" msgstr "%(problems)s" diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index d984067f..26f6c53d 100644 Binary files a/locale/zh/LC_MESSAGES/django.mo and b/locale/zh/LC_MESSAGES/django.mo differ diff --git a/locale/zh/LC_MESSAGES/django.po b/locale/zh/LC_MESSAGES/django.po index 818449b6..af6170e1 100644 --- a/locale/zh/LC_MESSAGES/django.po +++ b/locale/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-11 12:16+0000\n" +"POT-Creation-Date: 2026-11-11 13:15+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -915,7 +915,7 @@ msgid "IP" msgstr "IP" #: admin/templates/admin/logs.html:56 admin/views.py:292 instances/states.py:19 -#: instances/views.py:422 instances/views.py:424 logs/views.py:18 +#: instances/views.py:423 instances/views.py:425 logs/views.py:18 msgid "Unknown" msgstr "未知" @@ -1751,8 +1751,8 @@ msgstr "已保存:%(settings)s" msgid "Nothing changed" msgstr "没有任何更改" -#: appsettings/views.py:123 vrtManager/nodedevs.py:219 -#: vrtManager/nodedevs.py:258 +#: appsettings/views.py:123 vrtManager/nodedevs.py:247 +#: vrtManager/nodedevs.py:286 msgid "Other" msgstr "其他" @@ -2589,7 +2589,7 @@ msgid "" msgstr "不支持控制台类型 '%(type)s'。请将虚拟机图形切换为 VNC。" #: instances/api/viewsets.py:149 instances/api/viewsets.py:167 -#: instances/views.py:810 instances/views.py:828 instances/views.py:1797 +#: instances/views.py:811 instances/views.py:829 instances/views.py:1798 msgid "Templates cannot be started." msgstr "模板无法启动。" @@ -2901,7 +2901,7 @@ msgstr "MAC 地址 %(mac)s 已属于此主机上另一台虚拟机的网卡" msgid "Create VM" msgstr "创建虚拟机" -#: instances/jobs.py:883 instances/jobs.py:925 instances/views.py:2501 +#: instances/jobs.py:883 instances/jobs.py:925 instances/views.py:2506 msgid "A virtual machine with this name already exists" msgstr "同名虚拟机已存在" @@ -3248,7 +3248,7 @@ msgid "Disk source" msgstr "磁盘来源" #: instances/templates/add_instance_volume.html:21 -#: instances/templates/create_instance_w2.html:134 instances/views.py:2520 +#: instances/templates/create_instance_w2.html:134 instances/views.py:2525 msgid "New disk" msgstr "新磁盘" @@ -3622,7 +3622,7 @@ msgstr "自定义 CPU 型号" msgid "Size (GiB)" msgstr "大小(GiB)" -#: instances/templates/create_instance_w2.html:161 instances/views.py:2521 +#: instances/templates/create_instance_w2.html:161 instances/views.py:2526 msgid "Existing volumes" msgstr "已有卷" @@ -3658,7 +3658,7 @@ msgstr "设备" msgid "Remove" msgstr "移除" -#: instances/templates/create_instance_w2.html:194 instances/views.py:2522 +#: instances/templates/create_instance_w2.html:194 instances/views.py:2527 msgid "Clone from template" msgstr "从模板克隆" @@ -4163,39 +4163,46 @@ msgid "The host's devices could not be read: %(error)s" msgstr "无法读取主机的设备:%(error)s" #: instances/templates/instances/host_devices_form.html:8 +#, python-format +msgid "" +"The VM does not start until this is fixed: %(problems)s. Remove the device " +"and add the one the host has." +msgstr "在修复此问题之前虚拟机无法启动:%(problems)s。请移除该设备并添加主机上现有的设备。" + +#: instances/templates/instances/host_devices_form.html:11 msgid "USB device of the host" msgstr "主机的 USB 设备" -#: instances/templates/instances/host_devices_form.html:9 +#: instances/templates/instances/host_devices_form.html:12 msgid "Choose a USB device of the host…" msgstr "选择主机的 USB 设备…" -#: instances/templates/instances/host_devices_form.html:14 +#: instances/templates/instances/host_devices_form.html:17 msgid "Add USB device" msgstr "添加 USB 设备" -#: instances/templates/instances/host_devices_form.html:17 +#: instances/templates/instances/host_devices_form.html:20 msgid "PCI device of the host" msgstr "主机的 PCI 设备" -#: instances/templates/instances/host_devices_form.html:18 +#: instances/templates/instances/host_devices_form.html:21 msgid "Choose a PCI device of the host…" msgstr "选择主机的 PCI 设备…" -#: instances/templates/instances/host_devices_form.html:20 +#: instances/templates/instances/host_devices_form.html:23 msgid "no driver" msgstr "无驱动" -#: instances/templates/instances/host_devices_form.html:23 +#: instances/templates/instances/host_devices_form.html:26 msgid "Add PCI device" msgstr "添加 PCI 设备" -#: instances/templates/instances/host_devices_form.html:25 +#: instances/templates/instances/host_devices_form.html:28 msgid "" "A paused VM, or one with a saved state, does not change its PCI devices." msgstr "已暂停或有已保存状态的虚拟机不能更改其 PCI 设备。" -#: instances/templates/instances/host_devices_form.html:26 +#: instances/templates/instances/host_devices_form.html:29 msgid "" "The device is plugged into the running VM at once and kept for its next " "start; libvirt binds it to vfio-pci. It needs a free slot: on a q35 VM a free" @@ -4204,7 +4211,7 @@ msgstr "" "设备会立即插入运行中的虚拟机,并在下次启动时保留;libvirt 会将其绑定到 vfio-pci。它需要一个空闲插槽:对于 q35 " "虚拟机,需要一个在虚拟机关机时添加的空闲 pcie-root-port。" -#: instances/templates/instances/host_devices_form.html:27 +#: instances/templates/instances/host_devices_form.html:30 msgid "" "libvirt binds the device to vfio-pci when the VM starts, and gives it back to" " the host when the VM stops; a device bound to vfio-pci before stays bound to" @@ -5709,63 +5716,63 @@ msgstr "无效的 MAC 地址" msgid "More MAC addresses than networks" msgstr "MAC 地址数量多于网络数量" -#: instances/views.py:175 +#: instances/views.py:176 msgid "Enter an IP address, a network such as 192.0.2.0/24, or a MAC address." msgstr "请输入 IP 地址、网络(如 192.0.2.0/24)或 MAC 地址。" -#: instances/views.py:181 instances/views.py:215 +#: instances/views.py:182 instances/views.py:216 msgid "Too many searches are still running; try again shortly." msgstr "仍在运行的搜索过多;请稍后再试。" -#: instances/views.py:263 +#: instances/views.py:264 #, python-format msgid "The host %(host)s of '%(name)s' cannot be reached: %(error)s" msgstr "无法连接“%(name)s”所在的主机 %(host)s:%(error)s" -#: instances/views.py:269 +#: instances/views.py:270 #, python-format msgid "The host of '%(name)s' cannot be reached right now." msgstr "目前无法连接“%(name)s”所在的主机。" -#: instances/views.py:270 +#: instances/views.py:271 msgid " Jobs on it can be followed under Jobs in the menu." msgstr " 其上的任务可在菜单的“任务”中跟踪。" -#: instances/views.py:278 +#: instances/views.py:279 #, python-format msgid "'%(name)s' is no longer on its host." msgstr "“%(name)s”已不在其主机上。" -#: instances/views.py:365 +#: instances/views.py:366 msgid "There is no other host to migrate to." msgstr "没有其他可迁移到的主机。" -#: instances/views.py:367 +#: instances/views.py:368 msgid "A VM migrates when it is running, paused or shut off." msgstr "虚拟机在运行、暂停或关机状态下均可迁移。" -#: instances/views.py:369 +#: instances/views.py:370 msgid "" "A VM with snapshots cannot be migrated: its snapshots stay on this host. " "Delete them first." msgstr "有快照的虚拟机无法迁移:其快照保留在本主机上。请先删除快照。" -#: instances/views.py:371 +#: instances/views.py:372 msgid "" "A VM with host devices cannot be migrated: the destination may not have them." " Remove them first." msgstr "有主机设备的虚拟机无法迁移:目标主机可能没有这些设备。请先移除它们。" -#: instances/views.py:583 +#: instances/views.py:584 #, python-format msgid "Disk %(dev)s has changed since the page was loaded; reload the page" msgstr "磁盘 %(dev)s 在页面加载后已更改;请刷新页面" -#: instances/views.py:658 instances/views.py:659 +#: instances/views.py:659 instances/views.py:660 msgid "The VM was moved meanwhile; try again." msgstr "该虚拟机在此期间已被移动;请重试。" -#: instances/views.py:775 +#: instances/views.py:776 msgid "" "The running VM has no free PCI slot for another disk on this bus: choose the " "scsi bus if the VM has a SCSI controller, or shut the VM down and add the " @@ -5775,7 +5782,7 @@ msgstr "" "运行中的虚拟机在此总线上没有可用 PCI 插槽来添加磁盘:如果虚拟机有 SCSI 控制器,请选择 scsi " "总线;或关闭虚拟机后再添加磁盘。“磁盘”选项卡上的“添加 PCIe 插槽”可使其从下次启动起获得可用插槽。新卷会保留在其存储池中,可作为现有卷挂载。" -#: instances/views.py:779 +#: instances/views.py:780 msgid "" "The running VM has no free PCI slot for the SCSI controller the disk needs: " "shut the VM down and add the disk then; Add PCIe slots on the Disks tab gives" @@ -5785,270 +5792,270 @@ msgstr "" "运行中的虚拟机没有可用 PCI 插槽来添加磁盘所需的 SCSI 控制器:请关闭虚拟机后再添加磁盘。“磁盘”选项卡上的“添加 PCIe " "插槽”可使其从下次启动起获得可用插槽。新卷会保留在其存储池中,可作为现有卷挂载。" -#: instances/views.py:797 +#: instances/views.py:798 #, python-format msgid "Invalid disk options: %(options)s" msgstr "无效的磁盘选项:%(options)s" -#: instances/views.py:836 +#: instances/views.py:837 msgid "The VM was forced off but did not start again: it stays off." msgstr "虚拟机已被强制关机,但没有再次启动:它保持关机状态。" -#: instances/views.py:1021 +#: instances/views.py:1022 #, python-format msgid "Set the gstfsd key of %(compute)s first (Computes, edit the host)" msgstr "请先设置 %(compute)s 的 gstfsd 密钥(计算节点,编辑该主机)" -#: instances/views.py:1028 instances/views.py:1046 instances/views.py:1055 +#: instances/views.py:1029 instances/views.py:1047 instances/views.py:1056 #, python-format msgid "gstfsd error: %(err)s" msgstr "gstfsd 错误:%(err)s" -#: instances/views.py:1056 +#: instances/views.py:1057 msgid "the reply is not signed with the key" msgstr "回复未使用该密钥签名" -#: instances/views.py:1064 +#: instances/views.py:1065 msgid "Shut the VM down, or start its QEMU guest agent, and try again" msgstr "请关闭虚拟机,或启动其 QEMU 客户机代理,然后重试" -#: instances/views.py:1077 +#: instances/views.py:1078 msgid "The change may still be made when the agent answers again." msgstr "当代理再次响应时,此更改仍可能生效。" -#: instances/views.py:1105 +#: instances/views.py:1106 msgid "Reset root password" msgstr "重置 root 密码" -#: instances/views.py:1109 +#: instances/views.py:1110 msgid "Enter a password" msgstr "请输入密码" -#: instances/views.py:1123 +#: instances/views.py:1124 msgid "Select an SSH public key" msgstr "请选择 SSH 公钥" -#: instances/views.py:1145 +#: instances/views.py:1146 #, python-format msgid "Installed new SSH public key %(keyname)s" msgstr "已安装新的 SSH 公钥 %(keyname)s" -#: instances/views.py:1165 +#: instances/views.py:1166 msgid "Enter a whole number of vCPUs" msgstr "请输入整数个 vCPU" -#: instances/views.py:1169 +#: instances/views.py:1170 msgid "Shut off the VM to change its vCPUs" msgstr "请关闭虚拟机以更改其 vCPU" -#: instances/views.py:1172 +#: instances/views.py:1173 msgid "The current vCPUs cannot be more than the maximum" msgstr "当前 vCPU 数不能超过最大值" -#: instances/views.py:1179 +#: instances/views.py:1180 #, python-format msgid "%(quota)s: cannot resize the CPU of '%(instance_name)s'." msgstr "%(quota)s:无法调整“%(instance_name)s”的 CPU。" -#: instances/views.py:1187 +#: instances/views.py:1188 #, python-format msgid "vCPUs set to %(cur)s (maximum %(max)s)" msgstr "vCPU 已设为 %(cur)s(最大 %(max)s)" -#: instances/views.py:1206 +#: instances/views.py:1207 msgid "Enter a whole number for memory" msgstr "请输入整数内存值" -#: instances/views.py:1209 +#: instances/views.py:1210 msgid "The current memory cannot be more than the maximum" msgstr "当前内存不能超过最大值" -#: instances/views.py:1213 +#: instances/views.py:1214 #, python-format msgid "%(quota)s: cannot resize the memory of '%(instance_name)s'." msgstr "%(quota)s:无法调整“%(instance_name)s”的内存。" -#: instances/views.py:1219 +#: instances/views.py:1220 #, python-format msgid "Memory set to %(cur)s MiB (maximum %(max)s MiB)" msgstr "内存已设为 %(cur)s MiB(最大 %(max)s MiB)" -#: instances/views.py:1239 +#: instances/views.py:1240 msgid "Enter disk sizes as whole GiB" msgstr "请以整数 GiB 输入磁盘大小" -#: instances/views.py:1243 +#: instances/views.py:1244 #, python-format msgid "%(dev)s is %(size)s: a disk cannot shrink" msgstr "%(dev)s 为 %(size)s:磁盘不能缩小" -#: instances/views.py:1251 +#: instances/views.py:1252 msgid "No disks were selected or valid for resizing." msgstr "未选择磁盘或没有可调整大小的有效磁盘。" -#: instances/views.py:1260 +#: instances/views.py:1261 #, python-format msgid "%(quota)s: cannot resize the disks of '%(instance_name)s'." msgstr "%(quota)s:无法调整“%(instance_name)s”的磁盘。" -#: instances/views.py:1272 +#: instances/views.py:1273 #, python-format msgid "The storage pool of %(dev)s cannot resize its volumes" msgstr "%(dev)s 所在的存储池无法调整其卷的大小" -#: instances/views.py:1274 +#: instances/views.py:1275 #, python-format msgid "Disk is resized: %(dev)s" msgstr "磁盘已调整大小:%(dev)s" -#: instances/views.py:1368 +#: instances/views.py:1369 msgid "The VM's machine has no PCIe slots to add" msgstr "该虚拟机的机器类型没有可添加的 PCIe 插槽" -#: instances/views.py:1373 +#: instances/views.py:1374 #, python-format msgid "%(count)s PCIe slots added" msgstr "已添加 %(count)s 个 PCIe 插槽" -#: instances/views.py:1375 +#: instances/views.py:1376 #, python-format msgid "%(count)s PCIe slots added: the VM gets them at its next start" msgstr "已添加 %(count)s 个 PCIe 插槽:虚拟机在下次启动时获得它们" -#: instances/views.py:1421 +#: instances/views.py:1422 #, python-format msgid "%(volume)s is already a disk of this VM" msgstr "%(volume)s 已是此虚拟机的磁盘" -#: instances/views.py:1511 +#: instances/views.py:1512 msgid "Volume changes are applied. But it will be activated after shutdown" msgstr "卷更改已应用,但将在关机后生效" -#: instances/views.py:1516 +#: instances/views.py:1517 msgid "Volume is changed successfully." msgstr "卷已成功更改。" -#: instances/views.py:1536 +#: instances/views.py:1537 #, python-format msgid "Disk %(dev)s is not a storage volume of this instance" msgstr "磁盘 %(dev)s 不是此虚拟机的存储卷" -#: instances/views.py:1541 vrtManager/instance.py:2309 +#: instances/views.py:1542 vrtManager/instance.py:2309 msgid "The VM has a saved state; start it or remove the saved state first" msgstr "虚拟机有保存的状态;请先启动它或删除保存的状态" -#: instances/views.py:1547 +#: instances/views.py:1548 #, python-format msgid "Disk %(dev)s has a pending change; delete it once the VM is shut down" msgstr "磁盘 %(dev)s 有待生效的更改;请在虚拟机关机后删除它" -#: instances/views.py:1562 +#: instances/views.py:1563 #, python-format msgid "Volume %(vol)s is used by another VM; detach it instead" msgstr "卷 %(vol)s 正被另一台虚拟机使用;请改为分离它" -#: instances/views.py:1574 +#: instances/views.py:1575 #, python-format msgid "" "The guest has not released disk %(dev)s yet; volume %(vol)s was kept. Delete " "it from the storage pool once the VM is shut down." msgstr "客户机尚未释放磁盘 %(dev)s;卷 %(vol)s 已保留。请在虚拟机关机后从存储池中删除它。" -#: instances/views.py:1585 +#: instances/views.py:1586 #, python-format msgid "Disk %(dev)s was detached, but its volume was kept: %(err)s" msgstr "磁盘 %(dev)s 已分离,但其卷已保留:%(err)s" -#: instances/views.py:1613 +#: instances/views.py:1614 #, python-format msgid "This VM cannot take a CD-ROM on the %(bus)s bus now" msgstr "该虚拟机现在无法在 %(bus)s 总线上添加 CD-ROM" -#: instances/views.py:1616 +#: instances/views.py:1617 msgid "A USB CD-ROM needs an ISO image: libvirt has no empty USB drive" msgstr "USB CD-ROM 需要 ISO 镜像:libvirt 不支持空的 USB 驱动器" -#: instances/views.py:1621 +#: instances/views.py:1622 #, python-format msgid "%(image)s is already in a CD-ROM of this VM" msgstr "%(image)s 已在此虚拟机的某个光驱中" -#: instances/views.py:1702 +#: instances/views.py:1703 #, python-format msgid "Pool %(pool)s was not read again: %(err)s" msgstr "未重新读取存储池 %(pool)s:%(err)s" -#: instances/views.py:1723 +#: instances/views.py:1724 #, python-format msgid "Snapshot was not deleted: %(err)s" msgstr "快照未删除:%(err)s" -#: instances/views.py:1841 +#: instances/views.py:1842 msgid "Add at least one device to the boot order." msgstr "请至少向启动顺序中添加一个设备。" -#: instances/views.py:1847 vrtManager/instance.py:1108 +#: instances/views.py:1848 vrtManager/instance.py:1108 msgid "Invalid Device Type for boot order" msgstr "启动顺序的设备类型无效" -#: instances/views.py:1858 +#: instances/views.py:1859 msgid "Boot order changed. It applies at the next start." msgstr "启动顺序已更改,将在下次启动时生效。" -#: instances/views.py:1860 +#: instances/views.py:1861 msgid "Boot order changed successfully." msgstr "启动顺序已成功更改。" -#: instances/views.py:1880 +#: instances/views.py:1881 msgid "The XML is empty" msgstr "XML 为空" -#: instances/views.py:1884 instances/views.py:2511 +#: instances/views.py:1885 instances/views.py:2516 #, python-format msgid "The XML is not well-formed: %(error)s" msgstr "XML 格式不正确:%(error)s" -#: instances/views.py:1886 +#: instances/views.py:1887 #, python-format msgid "The XML must keep the VM's UUID %(uuid)s." msgstr "XML 必须保留虚拟机的 UUID %(uuid)s。" -#: instances/views.py:1890 +#: instances/views.py:1891 msgid "" "The definition has changed since the editor was opened. Reload the page to " "edit the current one." msgstr "自打开编辑器以来定义已被更改。请重新加载页面以编辑当前定义。" -#: instances/views.py:1902 +#: instances/views.py:1903 msgid "The XML definition was saved." msgstr "XML 定义已保存。" -#: instances/views.py:1904 +#: instances/views.py:1905 msgid "The XML definition was saved; the VM uses it from its next start." msgstr "XML 定义已保存;虚拟机从下次启动起使用它。" -#: instances/views.py:1985 +#: instances/views.py:1986 msgid "Select one network interface to change" msgstr "请选择一个要更改的网络接口" -#: instances/views.py:2023 +#: instances/views.py:2024 msgid "Network Device Config is changed. Please shutdown instance to activate." msgstr "网络设备配置已更改。请关闭虚拟机以使其生效。" -#: instances/views.py:2025 +#: instances/views.py:2026 msgid "Network device changed" msgstr "网络设备已更改" -#: instances/views.py:2037 +#: instances/views.py:2038 msgid "No network selected" msgstr "未选择网络" -#: instances/views.py:2042 +#: instances/views.py:2043 #, python-format msgid "The VM already has a network device with MAC %(mac)s" msgstr "虚拟机已有 MAC 地址为 %(mac)s 的网络设备" -#: instances/views.py:2061 +#: instances/views.py:2062 msgid "" "The running VM has no free PCI slot for another network device: shut it down " "and add the device then; Add PCIe slots on the Disks tab gives it free ones " @@ -6056,136 +6063,136 @@ msgid "" msgstr "" "运行中的虚拟机没有可用 PCI 插槽来添加网络设备:请关机后再添加设备。“磁盘”选项卡上的“添加 PCIe 插槽”可使其从下次启动起获得可用插槽。" -#: instances/views.py:2102 instances/views.py:2108 +#: instances/views.py:2103 instances/views.py:2109 msgid "The VM has it" msgstr "虚拟机已有此设备" -#: instances/views.py:2139 +#: instances/views.py:2144 #, python-format -msgid "The host has no USB device %(device)s" -msgstr "主机上没有 USB 设备 %(device)s" +msgid "The host has no USB device %(device)s; reload the page" +msgstr "主机没有 USB 设备 %(device)s;请重新加载页面" -#: instances/views.py:2160 +#: instances/views.py:2165 #, python-format msgid "The host has no PCI device %(device)s" msgstr "主机上没有 PCI 设备 %(device)s" -#: instances/views.py:2178 +#: instances/views.py:2183 #, python-format msgid "" "Removal of PCI device %(address)s requested: the guest has not let it go yet;" " it stays in the running VM until it does or the VM stops." msgstr "已请求移除 PCI 设备 %(address)s:客户机尚未释放它;在客户机释放或虚拟机停止之前,它仍保留在运行中的虚拟机中。" -#: instances/views.py:2223 instances/views.py:2253 +#: instances/views.py:2228 instances/views.py:2258 msgid "Select a network interface and a QoS direction" msgstr "请选择网络接口和 QoS 方向" -#: instances/views.py:2226 vrtManager/network.py:454 +#: instances/views.py:2231 vrtManager/network.py:454 msgid "QoS rates must be whole numbers" msgstr "QoS 速率必须为整数" -#: instances/views.py:2233 networks/views.py:229 +#: instances/views.py:2238 networks/views.py:229 #, python-format msgid "%(qos_dir)s QoS is set" msgstr "%(qos_dir)s QoS 已设置" -#: instances/views.py:2238 +#: instances/views.py:2243 #, python-format msgid "" "%(qos_dir)s QoS is set. A running VM gets it after it is powered off and on." msgstr "%(qos_dir)s QoS 已设置。运行中的虚拟机需关机再开机后才能生效。" -#: instances/views.py:2260 networks/views.py:255 +#: instances/views.py:2265 networks/views.py:255 #, python-format msgid "%(qos_dir)s QoS is deleted" msgstr "%(qos_dir)s QoS 已删除" -#: instances/views.py:2265 +#: instances/views.py:2270 #, python-format msgid "" "%(qos_dir)s QoS is deleted. A running VM keeps the old limit until it is " "powered off and on." msgstr "%(qos_dir)s QoS 已删除。运行中的虚拟机在关机再开机之前保留旧的限制。" -#: instances/views.py:2293 +#: instances/views.py:2298 msgid "Only one owner is allowed and the one already added" msgstr "只允许一个所有者,且已添加" -#: instances/views.py:2295 +#: instances/views.py:2300 #, python-format msgid "%(user)s is already an owner" msgstr "%(user)s 已是所有者" -#: instances/views.py:2340 +#: instances/views.py:2345 #, python-format msgid "Console settings were not saved: %(errors)s" msgstr "控制台设置未保存:%(errors)s" -#: instances/views.py:2362 +#: instances/views.py:2367 msgid "" "Error setting console password. You should check that your instance have an " "graphic device." msgstr "设置控制台密码出错。请检查虚拟机是否有图形设备。" -#: instances/views.py:2409 +#: instances/views.py:2414 msgid "Shut the VM down to change whether it is a template." msgstr "请关闭虚拟机以更改其是否为模板。" -#: instances/views.py:2415 +#: instances/views.py:2420 #, python-format msgid "%(quota)s: '%(instance_name)s' stays a template." msgstr "%(quota)s:“%(instance_name)s”仍为模板。" -#: instances/views.py:2499 +#: instances/views.py:2504 msgid "The XML has no name" msgstr "XML 中没有名称" -#: instances/views.py:2513 webvirtcloud/middleware.py:156 +#: instances/views.py:2518 webvirtcloud/middleware.py:156 #, python-format msgid "libvirt Error - %(exception)s" msgstr "libvirt 错误 - %(exception)s" -#: instances/views.py:2520 +#: instances/views.py:2525 msgid "An empty disk of the size you set" msgstr "按设定大小创建的空磁盘" -#: instances/views.py:2521 +#: instances/views.py:2526 msgid "Volumes already in a pool" msgstr "存储池中已有的卷" -#: instances/views.py:2522 +#: instances/views.py:2527 msgid "A copy of a template volume" msgstr "模板卷的副本" -#: instances/views.py:2600 +#: instances/views.py:2605 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:2602 +#: instances/views.py:2607 msgid "This host has no network for the VM: add one on its Networks page." msgstr "此主机没有可供虚拟机使用的网络:请在其“网络”页面添加一个。" -#: instances/views.py:2634 +#: instances/views.py:2639 #, python-format msgid "The machine type is q35, not %(machine)s: UEFI Secure Boot needs it" msgstr "机器类型为 q35,而不是 %(machine)s:UEFI 安全启动需要它" -#: instances/views.py:2661 +#: instances/views.py:2666 msgid "Flavor Created" msgstr "规格已创建" -#: instances/views.py:2669 +#: instances/views.py:2674 msgid "Create Flavor" msgstr "创建规格" -#: instances/views.py:2681 +#: instances/views.py:2686 msgid "Flavor Deleted" msgstr "规格已删除" -#: instances/views.py:2687 +#: instances/views.py:2692 msgid "Only the size template goes; VMs made from it keep their size." msgstr "仅删除此规格;由它创建的虚拟机保持其大小。" @@ -9385,22 +9392,38 @@ msgstr "" "%(device)s 与 %(member)s (%(product)s) 共享 IOMMU 组 %(group)s,后者正被主机(驱动 " "%(driver)s)使用" -#: vrtManager/nodedevs.py:187 +#: vrtManager/nodedevs.py:195 +#, python-format +msgid "USB device %(ids)s" +msgstr "USB 设备 %(ids)s" + +#: vrtManager/nodedevs.py:197 +#, python-format +msgid "USB device %(ids)s at %(bus)s/%(device)s" +msgstr "位于 %(bus)s/%(device)s 的 USB 设备 %(ids)s" + +#: vrtManager/nodedevs.py:200 vrtManager/nodedevs.py:215 #, python-format msgid "%(device)s is not on the host" msgstr "%(device)s 不在主机上" -#: vrtManager/nodedevs.py:198 +#: vrtManager/nodedevs.py:203 +#, python-format +msgid "" +"the host has %(count)s of %(device)s: name the one to give by its address" +msgstr "主机上有 %(count)s 个 %(device)s:请按地址指定要分配的那个" + +#: vrtManager/nodedevs.py:226 #, python-format msgid "%(device)s is a hub" msgstr "%(device)s 是集线器" -#: vrtManager/nodedevs.py:202 +#: vrtManager/nodedevs.py:230 #, python-format msgid "%(device)s is on the PCI controller %(controller)s, given to %(vms)s" msgstr "%(device)s 位于已分配给 %(vms)s 的 PCI 控制器 %(controller)s 上" -#: vrtManager/nodedevs.py:332 +#: vrtManager/nodedevs.py:360 #, python-format msgid "%(problems)s" msgstr "%(problems)s" diff --git a/vrtManager/nodedevs.py b/vrtManager/nodedevs.py index b92d0465..880d7b53 100644 --- a/vrtManager/nodedevs.py +++ b/vrtManager/nodedevs.py @@ -68,13 +68,24 @@ def host_resources(name, nodes, children): return found +def usb_id(text): + """A USB vendor or product ID of a definition, read as libvirt reads it + (C's strtoul: 0x hex, a leading 0 octal, else decimal) and written as a + node device writes it (0x0627); empty when not given.""" + text = text.strip().removeprefix("+") + if not text: + return "" + base = 16 if text.lower().startswith("0x") else 8 if text.startswith("0") and text != "0" else 10 + return f"0x{int(text, base):04x}" + + def usb_selector(source): """(vendor, product, (bus, device) or None) of a USB 's , the parts libvirt picks a device by. An address libvirt resolved for a running VM (autoAddress, in its migratable XML) is not one of them.""" address = source.find("address") given = address is not None and source.get("autoAddress") != "yes" - return (source.xpath("string(vendor/@id)").lower(), source.xpath("string(product/@id)").lower(), + return (usb_id(source.xpath("string(vendor/@id)")), usb_id(source.xpath("string(product/@id)")), (int(address.get("bus")), int(address.get("device"))) if given else None) @@ -177,6 +188,50 @@ def pci_problems(vm, device, by_address, managed): return problems +USB_SOURCES = "devices/hostdev[@mode='subsystem'][@type='usb']/source" + + +def usb_picked(source, usb): + """The selector (usb_selector) libvirt picks a device of the host's usb by + for a USB 's : an address it resolved before + (autoAddress) while a device of the model is still there, else the model.""" + vendor, product, given = usb_selector(source) + address = source.find("address") + if given is None and address is not None: + at = (int(address.get("bus")), int(address.get("device"))) + if any(usb_named((vendor, product, at), device["model"], (device["bus"], device["device"])) for device in usb): + return vendor, product, at + return vendor, product, given + + +def usb_unmatched(trees, usb, restore=False): + """Why the host cannot give the USB devices the definitions trees name + as they name them (libvirt then does not start the VM): a device it does + not have, unless optional, or requisite on a restore (a saved state or a + snapshot), as libvirt drops those; or a model it has more than one of, + named without an address (usb_picked).""" + dropped = ("optional", "requisite") if restore else ("optional",) + problems = [] + for tree in trees: + for source in tree.xpath(USB_SOURCES): + picked = usb_picked(source, usb) + matches = [device for device in usb if usb_named(picked, device["model"], (device["bus"], device["device"]))] + vendor, product, given = usb_selector(source) + ids = f"{vendor[2:]}:{product[2:]}" + if given is None: + label = [util.message(gettext_noop("USB device %(ids)s"), ids=ids)] + else: + label = [util.message(gettext_noop("USB device %(ids)s at %(bus)s/%(device)s"), ids=ids, + bus=given[0], device=given[1])] + if not matches and source.get("startupPolicy") not in dropped: + problems.append(util.message(gettext_noop("%(device)s is not on the host"), device=label)) + elif len(matches) > 1: + problems.append(util.message(gettext_noop( + "the host has %(count)s of %(device)s: name the one to give by its address"), + device=label, count=len(matches))) + return problems + + def hostdev_problems(vm, pci, usb, wanted_pci, wanted_usb, managed=frozenset()): """Why the host's devices pci and usb (get_node_devices) that a definition of the VM named vm wants (hostdev_users; managed_pci) cannot be given to @@ -316,17 +371,19 @@ def device_names(conn): return names -def check_hostdevs(conn, vm, trees): +def check_hostdevs(conn, vm, trees, restore=False): """Refuses the host devices the definitions trees give the VM named vm, on the host of conn, when they cannot be (hostdev_problems): each - definition on its own, as the VM starts from one of them.""" + definition on its own, as the VM starts from one of them, restored from + it when restore (usb_unmatched).""" wanted = [(tree, hostdev_users([tree])) for tree in trees] if not any(pci or usb for tree, (pci, usb) in wanted): return pci, usb = node_devices(conn) - problems = [] - for tree, (wanted_pci, wanted_usb) in wanted: - problems += hostdev_problems(vm, pci, usb, wanted_pci, wanted_usb, managed_pci(tree)) + problems = usb_unmatched(trees, usb, restore) + for tree, (wanted_pci, _selectors) in wanted: + picked = [usb_picked(source, usb) for source in tree.xpath(USB_SOURCES)] + problems += hostdev_problems(vm, pci, usb, wanted_pci, picked, managed_pci(tree)) if problems: unique = list({util.render(m["text"], m["values"], str): m for m in problems}.values()) raise util.OperationError(gettext_noop("%(problems)s"), problems=unique) diff --git a/vrtManager/tests/test_nodedevs.py b/vrtManager/tests/test_nodedevs.py index 6655fe1c..65ff5c1e 100644 --- a/vrtManager/tests/test_nodedevs.py +++ b/vrtManager/tests/test_nodedevs.py @@ -6,11 +6,12 @@ is a mock, libvirt's test driver has no node devices.""" from unittest.mock import MagicMock import libvirt +from lxml import etree from django.test import SimpleTestCase from vrtManager import util from vrtManager.connection import wvmConnect -from vrtManager.nodedevs import hostdev_problems, node_devices, pci_address +from vrtManager.nodedevs import check_hostdevs, hostdev_problems, node_devices, pci_address, usb_unmatched from vrtManager.tests.fakes import NODES, PCI_0A, USB_1_3, node, pci, vm PCI_01 = "
" @@ -26,6 +27,61 @@ def devices(nodes=NODES, domains=()): return node_devices(conn) +class UsbUnmatchedTests(SimpleTestCase): + """libvirt does not start a VM whose USB device the host does not have + as named: one replugged gets another address, a second of a model makes + a model-only name ambiguous.""" + + def problems(self, source, restore=False): + tree = etree.fromstring(f"{source}") + return [util.render(m["text"], m["values"], str) for m in usb_unmatched([tree], devices()[1], restore)] + + def test_a_device_named_as_the_host_has_it_is_fine(self): + self.assertEqual(self.problems(USB_1_3), []) + + def test_a_device_not_at_its_address_is_not_on_the_host(self): + gone = USB_MODEL.replace("", "
") + self.assertEqual(self.problems(gone), ["USB device 0627:0001 at 1/9 is not on the host"]) + optional = gone.replace("", "") + self.assertEqual(self.problems(optional), []) + + def test_a_model_the_host_has_two_of_needs_an_address(self): + self.assertEqual(self.problems(USB_MODEL), + ["the host has 2 of USB device 0627:0001: name the one to give by its address"]) + + def test_a_restore_drops_a_missing_requisite_device(self): + requisite = USB_MODEL.replace("", "") + requisite = requisite.replace("", "
") + self.assertEqual(self.problems(requisite), ["USB device 0627:0001 at 1/9 is not on the host"]) + self.assertEqual(self.problems(requisite, restore=True), []) + + def test_an_address_libvirt_found_is_tried_then_the_model(self): + found = USB_MODEL.replace("", "") + self.assertEqual(self.problems(found.replace("", "
")), []) + self.assertEqual(self.problems(found.replace("", "
")), + ["the host has 2 of USB device 0627:0001: name the one to give by its address"]) + + def test_a_found_address_still_there_is_the_device_checked(self): + conn = wvmConnect.__new__(wvmConnect) + conn.wvm = MagicMock(**{"listAllDevices.return_value": [node(*n) for n in NODES], + "listAllDomains.return_value": [vm("db-1", USB_1_3)]}) + found = USB_MODEL.replace("", "").replace("", "
") + check_hostdevs(conn, "kiosk-1", [etree.fromstring(f"{found}")], restore=True) + + def test_ids_in_decimal_are_read_as_libvirt_reads_them(self): + decimal = "" \ + "
" + self.assertEqual(self.problems(decimal), []) + self.assertEqual(self.problems(decimal.replace("'1575'", "' +0x0627'")), []) + + def test_a_revert_checks_them_too(self): + conn = wvmConnect.__new__(wvmConnect) + conn.wvm = MagicMock(**{"listAllDevices.return_value": [node(*n) for n in NODES], "listAllDomains.return_value": []}) + tree = etree.fromstring(f"{USB_MODEL}") + with self.assertRaisesRegex(util.OperationError, "the host has 2 of USB device 0627:0001"): + check_hostdevs(conn, "kiosk-1", [tree]) + + class NodeDevicesTests(SimpleTestCase): def test_pci_devices_by_group_with_what_the_host_has_on_them(self): pci_devices, _ = devices()