forked from shaba/openuds
Removed "erroring" machine is it has any exception on connection
This commit is contained in:
parent
21c221a6db
commit
10805ded7e
@ -204,16 +204,21 @@ class OVirtLinkedDeployment(services.UserDeployment):
|
||||
if self.cache.get('ready') == '1':
|
||||
return State.FINISHED
|
||||
|
||||
state = self.service().getMachineState(self._vmid)
|
||||
try:
|
||||
state = self.service().getMachineState(self._vmid)
|
||||
|
||||
if state == 'unknown':
|
||||
return self.__error('Machine is not available anymore')
|
||||
if state == 'unknown':
|
||||
return self.__error('Machine is not available anymore')
|
||||
|
||||
if state not in UP_STATES:
|
||||
self._queue = [opStart, opFinish]
|
||||
return self.__executeQueue()
|
||||
if state not in UP_STATES:
|
||||
self._queue = [opStart, opFinish]
|
||||
return self.__executeQueue()
|
||||
|
||||
self.cache.put('ready', '1')
|
||||
except Exception as e:
|
||||
self.doLog(log.ERROR, 'Error on setReady: {}'.format(e))
|
||||
# Treat as operation done, maybe the machine is ready and we can continue
|
||||
|
||||
self.cache.put('ready', '1')
|
||||
return State.FINISHED
|
||||
|
||||
def reset(self) -> None:
|
||||
|
@ -131,14 +131,19 @@ class LiveDeployment(UserDeployment): # pylint: disable=too-many-public-methods
|
||||
if self.cache.get('ready') == '1':
|
||||
return State.FINISHED
|
||||
|
||||
state = self.service().getMachineState(self._vmid)
|
||||
try:
|
||||
state = self.service().getMachineState(self._vmid)
|
||||
|
||||
if state == on.types.VmState.UNKNOWN: # @UndefinedVariable
|
||||
return self.__error('Machine is not available anymore')
|
||||
if state == on.types.VmState.UNKNOWN: # @UndefinedVariable
|
||||
return self.__error('Machine is not available anymore')
|
||||
|
||||
self.service().startMachine(self._vmid)
|
||||
self.service().startMachine(self._vmid)
|
||||
|
||||
self.cache.put('ready', '1')
|
||||
except Exception as e:
|
||||
self.doLog(log.ERROR, 'Error on setReady: {}'.format(e))
|
||||
# Treat as operation done, maybe the machine is ready and we can continue
|
||||
|
||||
self.cache.put('ready', '1')
|
||||
return State.FINISHED
|
||||
|
||||
def reset(self) -> None:
|
||||
|
@ -142,19 +142,24 @@ class LiveDeployment(UserDeployment): # pylint: disable=too-many-public-methods
|
||||
if self.cache.get('ready') == '1':
|
||||
return State.FINISHED
|
||||
|
||||
status = self.service().getMachineState(self._vmid)
|
||||
try:
|
||||
status = self.service().getMachineState(self._vmid)
|
||||
|
||||
if openstack.statusIsLost(status):
|
||||
return self.__error('Machine is not available anymore')
|
||||
if openstack.statusIsLost(status):
|
||||
return self.__error('Machine is not available anymore')
|
||||
|
||||
if status == openstack.PAUSED:
|
||||
self.service().resumeMachine(self._vmid)
|
||||
elif status in (openstack.STOPPED, openstack.SHUTOFF):
|
||||
self.service().startMachine(self._vmid)
|
||||
if status == openstack.PAUSED:
|
||||
self.service().resumeMachine(self._vmid)
|
||||
elif status in (openstack.STOPPED, openstack.SHUTOFF):
|
||||
self.service().startMachine(self._vmid)
|
||||
|
||||
# Right now, we suppose the machine is ready
|
||||
# Right now, we suppose the machine is ready
|
||||
|
||||
self.cache.put('ready', '1')
|
||||
except Exception as e:
|
||||
self.doLog(log.ERROR, 'Error on setReady: {}'.format(e))
|
||||
# Treat as operation done, maybe the machine is ready and we can continue
|
||||
|
||||
self.cache.put('ready', '1')
|
||||
return State.FINISHED
|
||||
|
||||
def reset(self) -> None:
|
||||
|
@ -172,16 +172,18 @@ class ProxmoxDeployment(services.UserDeployment):
|
||||
|
||||
try:
|
||||
vmInfo = self.service().getMachineInfo(int(self._vmid))
|
||||
if vmInfo.status == 'stopped':
|
||||
self._queue = [opStart, opFinish]
|
||||
return self.__executeQueue()
|
||||
|
||||
self.cache.put('ready', '1')
|
||||
except client.ProxmoxConnectionError:
|
||||
raise # If connection fails, let it fail on parent
|
||||
except Exception:
|
||||
return self.__error('Machine not found')
|
||||
except Exception as e:
|
||||
self.doLog(log.ERROR, 'Error on setReady: {}'.format(e))
|
||||
# Treat as operation done, maybe the machine is ready and we can continue
|
||||
# return self.__error('Machine not found')
|
||||
|
||||
if vmInfo.status == 'stopped':
|
||||
self._queue = [opStart, opFinish]
|
||||
return self.__executeQueue()
|
||||
|
||||
self.cache.put('ready', '1')
|
||||
return State.FINISHED
|
||||
|
||||
def reset(self) -> None:
|
||||
|
@ -141,14 +141,21 @@ class XenLinkedDeployment(UserDeployment):
|
||||
return self._ip
|
||||
|
||||
def setReady(self) -> str:
|
||||
if self.cache.get('ready') == '1':
|
||||
return State.FINISHED
|
||||
|
||||
try:
|
||||
state = self.service().getVMPowerState(self._vmid)
|
||||
|
||||
if state != XenPowerState.running:
|
||||
self._queue = [opStart, opFinish]
|
||||
return self.__executeQueue()
|
||||
except Exception:
|
||||
return self.__error('Machine is not available anymore')
|
||||
|
||||
self.cache.put('ready', '1', 30)
|
||||
except Exception as e:
|
||||
# On case of exception, log an an error and return as if the operation was executed
|
||||
self.doLog(log.ERROR, 'Error setting machine state: {}'.format(e))
|
||||
# return self.__error('Machine is not available anymore')
|
||||
|
||||
return State.FINISHED
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user