mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(vrtManager): the libvirt layer's messages show in the reader's language
vrtManager's errors (some 140: a disk that does not move, a network address outside its subnet, a host device given to another VM, the disks a migration cannot copy) were English f-strings, so no catalog could translate them, on pages or in jobs. They are marked texts with their values now; a variant that differs by a word (internal or external, running or persistent, with a subnet or without) is a whole message of its own, and a list of problems is a list of messages. OperationError reads in the active language, so the pages that show one translate it as they are; its args stay English, and so do the logs and the audit log. Host device problems and the Migrate tab's reasons a disk is not copied are messages too.
This commit is contained in:
parent
1e66367bb4
commit
491819ed64
21 changed files with 2371 additions and 420 deletions
|
|
@ -14,6 +14,7 @@ from django.urls import reverse
|
|||
from instances.models import Instance
|
||||
from lxml import html
|
||||
from vrtManager.connection import wvmConnect
|
||||
from vrtManager import util
|
||||
from vrtManager.nodedevs import hostdev_problems, node_devices, pci_address
|
||||
|
||||
|
||||
|
|
@ -116,7 +117,8 @@ class NodeDevicesTests(SimpleTestCase):
|
|||
|
||||
def test_a_usb_device_on_a_controller_given_to_a_vm_is_not_given_to_another(self):
|
||||
pci_devices, usb_devices = devices(domains=[vm("db-1", PCI_01)])
|
||||
reasons = hostdev_problems("kiosk-1", pci_devices, usb_devices, set(), [("0x0627", "0x0001", (1, 2))])
|
||||
reasons = [util.render(m["text"], m["values"], str) for m in hostdev_problems(
|
||||
"kiosk-1", pci_devices, usb_devices, set(), [("0x0627", "0x0001", (1, 2))])]
|
||||
self.assertIn("USB device 1/2 (QEMU Tablet) is on the PCI controller 0000:00:01.0, given to db-1", reasons)
|
||||
|
||||
def test_a_usb_device_is_named_as_libvirt_picks_one(self):
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from unittest.mock import MagicMock
|
|||
|
||||
from django.test import SimpleTestCase
|
||||
from lxml import etree
|
||||
from vrtManager import util
|
||||
from vrtManager.nodedevs import _pci, check_hostdevs, hostdev_problems, pci_problems
|
||||
from vrtManager.util import OperationError
|
||||
|
||||
|
|
@ -60,7 +61,8 @@ def inventory(vms=()):
|
|||
|
||||
def problems(address, managed=(), vms=()):
|
||||
devices = {d["address"]: d for d in inventory(vms)}
|
||||
return " ".join(pci_problems("web-1", devices[address], devices, {address, *managed}))
|
||||
return " ".join(util.render(m["text"], m["values"], str)
|
||||
for m in pci_problems("web-1", devices[address], devices, {address, *managed}))
|
||||
|
||||
|
||||
def hostdev(slot, managed="yes"):
|
||||
|
|
@ -107,7 +109,8 @@ class PciRulesTests(SimpleTestCase):
|
|||
self.assertEqual(problems("0000:00:07.0", vms=[("web-1", {"0000:00:07.0"})]), "") # its own
|
||||
|
||||
def test_a_device_the_host_does_not_have_can_not(self):
|
||||
reasons = hostdev_problems("web-1", inventory(), [], {"0000:00:1f.0"}, [])
|
||||
reasons = [util.render(m["text"], m["values"], str)
|
||||
for m in hostdev_problems("web-1", inventory(), [], {"0000:00:1f.0"}, [])]
|
||||
self.assertEqual(reasons, ["PCI device 0000:00:1f.0 is not on the host"])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue