1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-03 01:17:56 +03:00

chore: Update get_vm_config method to include force parameter from cache decorator

This commit is contained in:
Adolfo Gómez García 2024-08-23 20:46:49 +02:00
parent 022b620edc
commit 708a3e22af
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 6 additions and 5 deletions

View File

@ -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:

View File

@ -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']