mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-12 09:17:56 +03:00
Added default implementatio of remove_and_free_machine (very common...)
This commit is contained in:
parent
fedd6507ae
commit
0322df85d5
server/src/uds
@ -177,13 +177,15 @@ class FixedService(services.Service, abc.ABC): # pylint: disable=too-many-publi
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@abc.abstractmethod
|
# default implementation, should be sufficient for most cases
|
||||||
def remove_and_free_machine(self, vmid: str) -> str:
|
def remove_and_free_machine(self, vmid: str) -> str:
|
||||||
"""
|
try:
|
||||||
Removes and frees a machine
|
with self._assigned_machines_access() as assigned:
|
||||||
Returns an state (State.FINISHED is nothing to do left)
|
assigned.remove(vmid)
|
||||||
"""
|
return types.states.State.FINISHED
|
||||||
raise NotImplementedError()
|
except Exception as e:
|
||||||
|
logger.warning('Cound not save assigned machines on fixed pool: %s', e)
|
||||||
|
raise
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_first_network_mac(self, vmid: str) -> str:
|
def get_first_network_mac(self, vmid: str) -> str:
|
||||||
|
@ -216,12 +216,3 @@ class ProxmoxServiceFixed(FixedService): # pylint: disable=too-many-public-meth
|
|||||||
|
|
||||||
def get_machine_name(self, vmid: str) -> str:
|
def get_machine_name(self, vmid: str) -> str:
|
||||||
return self.provider().get_machine_info(int(vmid)).name or ''
|
return self.provider().get_machine_info(int(vmid)).name or ''
|
||||||
|
|
||||||
def remove_and_free_machine(self, vmid: str) -> str:
|
|
||||||
try:
|
|
||||||
with self._assigned_machines_access() as assigned_vms:
|
|
||||||
assigned_vms.remove(vmid)
|
|
||||||
return types.states.State.FINISHED
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning('Cound not save assigned machines on fixed pool: %s', e)
|
|
||||||
raise
|
|
||||||
|
Loading…
Reference in New Issue
Block a user