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:
parent
8e5418d792
commit
e90099bcac
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user