diff --git a/server/src/tests/services/proxmox/test_client.py b/server/src/tests/services/proxmox/test_client.py index db2b02a8d..3d6d87deb 100644 --- a/server/src/tests/services/proxmox/test_client.py +++ b/server/src/tests/services/proxmox/test_client.py @@ -264,20 +264,20 @@ class TestProxmoxClient(UDSTransactionTestCase): with self._create_test_vm() as vm: self.pclient.enable_vm_ha(vm.id, started=False, group=self.hagroup) # Ensure it's enabled - vminfo = self.pclient.get_vm_info(vm.id) + vminfo = self.pclient.get_vm_info(vm.id, force=True) self.assertEqual(vminfo.ha.group, self.hagroup) # Disable it self.pclient.disable_vm_ha(vm.id) - vminfo = self.pclient.get_vm_info(vm.id) + vminfo = self.pclient.get_vm_info(vm.id, force=True) self.assertEqual(vminfo.ha.group, '') def test_set_vm_protection(self) -> None: with self._create_test_vm() as vm: self.pclient.set_vm_protection(vm.id, protection=True) - vmconfig = self.pclient.get_vm_config(vm.id) + vmconfig = self.pclient.get_vm_config(vm.id, force=True) self.assertTrue(vmconfig.protection) self.pclient.set_vm_protection(vm.id, protection=False) - vmconfig = self.pclient.get_vm_config(vm.id) + vmconfig = self.pclient.get_vm_config(vm.id, force=True) self.assertFalse(vmconfig.protection) def test_get_guest_ip_address(self) -> None: diff --git a/server/src/uds/services/Proxmox/proxmox/client.py b/server/src/uds/services/Proxmox/proxmox/client.py index 9f4ed96a1..1de7f8f67 100644 --- a/server/src/uds/services/Proxmox/proxmox/client.py +++ b/server/src/uds/services/Proxmox/proxmox/client.py @@ -664,7 +664,8 @@ class ProxmoxClient: raise exceptions.ProxmoxNotFound(f'VM {vmid} not found') - def get_vm_config(self, vmid: int, node: typing.Optional[str] = None) -> types.VMConfiguration: + @cached('vmc', consts.CACHE_VM_INFO_DURATION, key_helper=caching_key_helper) + def get_vm_config(self, vmid: int, node: typing.Optional[str] = None, **kwargs: typing.Any) -> types.VMConfiguration: node = node or self.get_vm_info(vmid).node return types.VMConfiguration.from_dict( self.do_get(f'nodes/{node}/qemu/{vmid}/config', node=node)['data']