1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 11:16:47 +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

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-06 20:48+0000\n"
"POT-Creation-Date: 2026-11-06 21:10+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"
@ -2120,7 +2120,6 @@ msgstr "Yeni sanal makine"
#: computes/templates/computes/instances.html:30
#, python-format
#| msgid "Problem occurred with host"
msgid "Problem occurred with host %(name)s: %(error)s"
msgstr "%(name)s sunucusuyla ilgili bir sorun oluştu: %(error)s"
@ -2393,7 +2392,6 @@ msgstr ""
"eklenirse geri gelir."
#: console/refusals.py:6
#| msgid "The device is not on this host"
msgid "The serial console is turned off on this server"
msgstr "Seri konsol bu sunucuda kapalı"
@ -2406,7 +2404,6 @@ msgstr ""
" yeniden yükleyin"
#: console/refusals.py:8
#| msgid "The console starts scaled to its window"
msgid "The console of this VM is open in another window"
msgstr "Bu sanal makinenin konsolu başka bir pencerede açık"
@ -7653,7 +7650,6 @@ msgid "%(phase)s (over its time limit)"
msgstr "%(phase)s (süre sınırını aştı)"
#: operations/jobs.py:151
#| msgid "The form has no valid submission key; reload the page"
msgid "This form was already submitted for another request; reload the page"
msgstr ""
"Bu form başka bir istek için zaten gönderildi; sayfayı yeniden yükleyin"
@ -8044,22 +8040,18 @@ msgid "Upload ISO image"
msgstr "ISO imajı yükle"
#: storages/jobs.py:118
#| msgid "Invalid file size."
msgid "Invalid file name"
msgstr "Geçersiz dosya adı"
#: storages/jobs.py:120
#| msgid "Only .iso files can be uploaded."
msgid "Only .iso files can be uploaded"
msgstr "Yalnızca .iso dosyaları yüklenebilir"
#: storages/jobs.py:122
#| msgid "Invalid file size."
msgid "Invalid file size"
msgstr "Geçersiz dosya boyutu"
#: storages/jobs.py:124
#| msgid "Invalid chunk index or total chunks."
msgid "Invalid chunk index or total chunks"
msgstr "Geçersiz parça dizini veya toplam parça sayısı"
@ -8889,6 +8881,12 @@ msgstr "Bağlantı kapandı (%(reason)s)"
msgid "Connection Failed: %(host)s is not connected"
msgstr "Bağlantı başarısız: %(host)s bağlı değil"
#: vrtManager/connection.py:502
#, python-format
#| msgid "This host has no secrets."
msgid "This host has no architecture %(arch)s"
msgstr "Bu sunucuda %(arch)s mimarisi yok"
#: vrtManager/instance.py:138
msgid "A running or paused VM cannot be migrated offline"
msgstr "Çalışan veya duraklatılmış bir sanal makine çevrimdışı taşınamaz"

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-06 20:48+0000\n"
"POT-Creation-Date: 2026-11-06 21:10+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -2051,7 +2051,6 @@ msgstr "新建虚拟机"
#: computes/templates/computes/instances.html:30
#, python-format
#| msgid "Problem occurred with host"
msgid "Problem occurred with host %(name)s: %(error)s"
msgstr "主机 %(name)s 出现问题:%(error)s"
@ -2313,7 +2312,6 @@ msgid ""
msgstr "其虚拟机继续在主机上运行并离开面板;其所有者在“已移除的虚拟机”页面保留 %(days)s 天,如果再次添加该主机则会恢复。"
#: console/refusals.py:6
#| msgid "The device is not on this host"
msgid "The serial console is turned off on this server"
msgstr "此服务器已关闭串行控制台"
@ -2324,7 +2322,6 @@ msgid ""
msgstr "控制台链接已过期,或您已无权打开此控制台:请重新加载页面"
#: console/refusals.py:8
#| msgid "The console starts scaled to its window"
msgid "The console of this VM is open in another window"
msgstr "此虚拟机的控制台已在另一个窗口中打开"
@ -7249,7 +7246,6 @@ msgid "%(phase)s (over its time limit)"
msgstr "%(phase)s(已超出时间限制)"
#: operations/jobs.py:151
#| msgid "The form has no valid submission key; reload the page"
msgid "This form was already submitted for another request; reload the page"
msgstr "此表单已为另一个请求提交过;请重新加载页面"
@ -7623,22 +7619,18 @@ msgid "Upload ISO image"
msgstr "上传 ISO 镜像"
#: storages/jobs.py:118
#| msgid "Invalid file size."
msgid "Invalid file name"
msgstr "文件名无效"
#: storages/jobs.py:120
#| msgid "Only .iso files can be uploaded."
msgid "Only .iso files can be uploaded"
msgstr "只能上传 .iso 文件"
#: storages/jobs.py:122
#| msgid "Invalid file size."
msgid "Invalid file size"
msgstr "文件大小无效"
#: storages/jobs.py:124
#| msgid "Invalid chunk index or total chunks."
msgid "Invalid chunk index or total chunks"
msgstr "分块索引或分块总数无效"
@ -8427,6 +8419,12 @@ msgstr "连接已关闭(%(reason)s)"
msgid "Connection Failed: %(host)s is not connected"
msgstr "连接失败:%(host)s 未连接"
#: vrtManager/connection.py:502
#, python-format
#| msgid "This host has no secrets."
msgid "This host has no architecture %(arch)s"
msgstr "此主机没有 %(arch)s 架构"
#: vrtManager/instance.py:138
msgid "A running or paused VM cannot be migrated offline"
msgstr "运行中或已暂停的虚拟机不能离线迁移"

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