1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-02-02 09:47:13 +03:00

Added "is_deleted" to proxmox

This commit is contained in:
Adolfo Gómez García 2024-09-04 22:24:11 +02:00
parent 8e5418d792
commit e90099bcac
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 16 additions and 0 deletions

View File

@ -30,6 +30,7 @@
"""
Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import random
import typing
from unittest import mock
@ -72,6 +73,14 @@ class TestProxmovLinkedService(UDSTestCase):
# Now should return False as we have reset the cache
self.assertFalse(service.is_avaliable())
api.test.assert_called_with()
def test_service_is_deleted(self) -> None:
with fixtures.patched_provider() as provider:
service = fixtures.create_service_linked(provider=provider)
vm = random.choice(fixtures.VMINFO_LIST)
self.assertFalse(service.is_deleted(str(vm.id)))
self.assertTrue(service.is_deleted('non_existent'))
def test_service_methods_1(self) -> None:
with fixtures.patched_provider() as provider:

View File

@ -323,3 +323,10 @@ class ProxmoxServiceLinked(DynamicService):
# All removals are deferred, so we can do it async
# Try to stop it if already running... Hard stop
self.provider().api.delete_vm(int(vmid))
def is_deleted(self, vmid: str) -> bool:
try:
self.provider().api.get_vm_info(int(vmid))
return False
except Exception:
return True