mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 19:26:48 +00:00
fix(instances): the create page offers the UEFI loader of the chosen machine
create_instance passed the loader list where find_uefi_path_for_arch expects the machine type. The domain capabilities were then read for the default machine (pc) instead of the chosen one: on a RHEL host a q35 VM was offered /usr/share/OVMF/OVMF_CODE.secboot.fd, which q35 does not list, instead of /usr/share/edk2/ovmf/OVMF_CODE.fd. The machine type is passed now. The page also read dom_caps["loader_enums"] into an unused variable; on a host without loader support the key is missing and the page failed with a KeyError. The line is removed. A unit test covers the call and the host without loader support (it fails on the previous code). A live test creates a q35 VM with the offered UEFI firmware, checks that libvirt lists that loader for q35 and starts the VM; it fails on the previous code.
This commit is contained in:
parent
16e1a334d0
commit
cdbff38223
3 changed files with 45 additions and 2 deletions
|
|
@ -62,3 +62,30 @@ class CreateInstanceViewTests(TestCase):
|
|||
fetch_redirect_response=False,
|
||||
)
|
||||
conn.create_instance.assert_called_once()
|
||||
|
||||
@patch("instances.views.wvmCreate")
|
||||
def test_firmware_list_uses_the_chosen_machine_type(self, connection_class):
|
||||
user = get_user_model().objects.create_superuser(
|
||||
username="create-fw-admin", password="password", email="fw@example.com"
|
||||
)
|
||||
self.client.force_login(user)
|
||||
compute = Compute.objects.create(
|
||||
name="create-fw-compute", hostname="localhost", type=4, login="", password="",
|
||||
)
|
||||
conn = connection_class.return_value
|
||||
conn.get_instances.return_value = []
|
||||
conn.get_storages.return_value = []
|
||||
conn.get_networks.return_value = []
|
||||
conn.get_nwfilters.return_value = []
|
||||
conn.get_cache_modes.return_value = {}
|
||||
# A host without loader support has no "loaders"/"loader_enums" keys
|
||||
conn.get_dom_capabilities.return_value = {"loader_support": "no"}
|
||||
conn.get_capabilities.return_value = {}
|
||||
conn.label_for_firmware_path.return_value = None
|
||||
conn.find_uefi_path_for_arch.return_value = None
|
||||
|
||||
response = self.client.get(reverse("instances:create_instance", args=[compute.id, "x86_64", "q35"]))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
conn.find_uefi_path_for_arch.assert_called_once_with("x86_64", "q35")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue