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

fix(vrtManager): an architecture the host does not run is refused, not a 500

The create page and the API's create take the architecture from the
URL. One the host's capabilities do not list raised a KeyError in
get_dom_cap_xml: an HTML 500 for both. It is now "This host has no
architecture noarch": the page shows it, the API answers 400.
This commit is contained in:
catborise 2026-11-07 00:10:06 +03:00
parent 6d22a18ba7
commit 9d22d48a85
6 changed files with 24 additions and 19 deletions

View file

@ -497,7 +497,10 @@ class wvmConnect(object):
def get_dom_cap_xml(self, arch, machine):
""" Return domain capabilities xml"""
emulatorbin = self.get_emulator(arch)
virttype = "kvm" if "kvm" in self.get_hypervisors_domain_types()[arch] else "qemu"
domain_types = self.get_hypervisors_domain_types().get(arch)
if domain_types is None: # the architecture comes from the URL
raise util.OperationError(gettext_noop("This host has no architecture %(arch)s"), arch=arch)
virttype = "kvm" if "kvm" in domain_types else "qemu"
machine_types = self.get_machine_types(arch)
if not machine or machine not in machine_types:

View file

@ -20,6 +20,7 @@ from libvirt import (
VIR_ERR_XML_ERROR,
libvirtError,
)
from vrtManager import util
from vrtManager.connection import wvmConnect
from vrtManager.hostdetails import wvmHostDetails
from vrtManager.storage import wvmStorage, wvmStorages
@ -90,6 +91,11 @@ class CapabilitiesOnceTestCase(unittest.TestCase):
["capabilities", ("/usr/bin/qemu-kvm", "x86_64", "q35", "kvm"), ("/usr/bin/qemu-kvm", "x86_64", "pc", "kvm")],
)
def test_an_architecture_the_host_does_not_run_is_refused_with_its_name(self):
# the create page and the API take it from the URL: it was a KeyError, a 500
with self.assertRaisesRegex(util.OperationError, "This host has no architecture noarch"):
connection().get_dom_cap_xml("noarch", "q35")
def test_the_overview_reads_the_info_once_and_the_free_memory_each_time(self):
conn = connection(wvmHostDetails)
conn.get_node_info()