mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Added default implementatio of remove_and_free_machine (very common...)
This commit is contained in:
parent
fedd6507ae
commit
0322df85d5
@ -177,13 +177,15 @@ class FixedService(services.Service, abc.ABC): # pylint: disable=too-many-publi
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
# default implementation, should be sufficient for most cases
|
||||
def remove_and_free_machine(self, vmid: str) -> str:
|
||||
"""
|
||||
Removes and frees a machine
|
||||
Returns an state (State.FINISHED is nothing to do left)
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
try:
|
||||
with self._assigned_machines_access() as assigned:
|
||||
assigned.remove(vmid)
|
||||
return types.states.State.FINISHED
|
||||
except Exception as e:
|
||||
logger.warning('Cound not save assigned machines on fixed pool: %s', e)
|
||||
raise
|
||||
|
||||
@abc.abstractmethod
|
||||
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:
|
||||
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