1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-03-20 06:50:23 +03:00

* Now if notifyReadyFromOsManager raises an error, puts the machine on

"error" state
* Fixed L2 cache on oVirt, that was not working correctly con 4.x
versions
This commit is contained in:
Adolfo Gómez García 2017-03-22 15:04:19 +01:00
parent 315dd77a5a
commit f715f48a7b
2 changed files with 22 additions and 16 deletions

View File

@ -51,7 +51,7 @@ import requests
import json
import logging
__updated__ = '2017-01-26'
__updated__ = '2017-03-22'
logger = logging.getLogger(__name__)
traceLogger = logging.getLogger('traceLog')
@ -441,17 +441,22 @@ class UserServiceManager(object):
uService.remove()
def notifyReadyFromOsManager(self, uService, data):
ui = uService.getInstance()
logger.debug('Notifying user service ready state')
state = ui.notifyReadyFromOsManager(data)
logger.debug('State: {0}'.format(state))
uService.updateData(ui)
if state == State.FINISHED:
logger.debug('Service is now ready')
uService.save()
elif uService.state in (State.USABLE, State.PREPARING): # We don't want to get active deleting or deleted machines...
uService.setState(State.PREPARING)
UserServiceOpChecker.makeUnique(uService, ui, state)
try:
ui = uService.getInstance()
logger.debug('Notifying user service ready state')
state = ui.notifyReadyFromOsManager(data)
logger.debug('State: {0}'.format(state))
uService.updateData(ui)
if state == State.FINISHED:
logger.debug('Service is now ready')
uService.save()
elif uService.state in (State.USABLE, State.PREPARING): # We don't want to get active deleting or deleted machines...
uService.setState(State.PREPARING)
UserServiceOpChecker.makeUnique(uService, ui, state)
except Exception as e:
logger.exception('Unhandled exception on notyfyReady: {}'.format(e))
UserService.setState(State.ERROR)
return
def getService(self, user, srcIp, idService, idTransport, doTest=True):
'''

View File

@ -46,6 +46,7 @@ logger = logging.getLogger(__name__)
opCreate, opStart, opStop, opSuspend, opRemove, opWait, opError, opFinish, opRetry, opChangeMac = range(10)
NO_MORE_NAMES = 'NO-NAME-ERROR'
UP_STATES = ('up', 'reboot_in_progress', 'powering_up', 'restoring_state')
class OVirtLinkedDeployment(UserDeployment):
@ -177,7 +178,7 @@ class OVirtLinkedDeployment(UserDeployment):
if state == 'unknown':
return self.__error('Machine is not available anymore')
if state not in ('up', 'powering_up', 'restoring_state'):
if state not in UP_STATES:
self._queue = [opStart, opFinish]
return self.__executeQueue()
@ -231,7 +232,7 @@ class OVirtLinkedDeployment(UserDeployment):
return self.__error('Machine not found')
ret = State.RUNNING
if type(chkState) is list:
if isinstance(chkState, (list, tuple)):
for cks in chkState:
if state == cks:
ret = State.FINISHED
@ -368,7 +369,7 @@ class OVirtLinkedDeployment(UserDeployment):
if state == 'unknown':
raise Exception('Machine not found')
if state in ('up',): # Already started, return
if state in UP_STATES: # Already started, return
return
if state != 'down' and state != 'suspended':
@ -429,7 +430,7 @@ class OVirtLinkedDeployment(UserDeployment):
'''
Checks if machine has started
'''
return self.__checkMachineState('up')
return self.__checkMachineState(UP_STATES)
def __checkStop(self):
'''