mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-23 17:34:17 +03:00
Merge remote-tracking branch 'origin/v2.1'
This commit is contained in:
commit
d838c8c9fe
@ -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')
|
||||
@ -472,17 +472,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):
|
||||
'''
|
||||
|
@ -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):
|
||||
'''
|
||||
|
@ -38,7 +38,7 @@ from datetime import datetime
|
||||
import logging
|
||||
|
||||
|
||||
__updated__ = '2015-05-14'
|
||||
__updated__ = '2017-03-22'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -111,7 +111,18 @@ class OVirtPublication(Publication):
|
||||
if self._state == 'error':
|
||||
return State.ERROR
|
||||
|
||||
self._state = self.service().getTemplateState(self._templateId)
|
||||
try:
|
||||
self._state = self.service().getTemplateState(self._templateId)
|
||||
except Exception as e:
|
||||
self._state = 'error'
|
||||
self._reason = str(e)
|
||||
return State.ERROR
|
||||
|
||||
|
||||
if self._state == 'removed':
|
||||
self._state = 'error'
|
||||
self._reason = 'Template has been removed!'
|
||||
return State.ERROR
|
||||
|
||||
# If publication os done (template is ready), and cancel was requested, do it just after template becomes ready
|
||||
if self._state == 'ok':
|
||||
|
Loading…
Reference in New Issue
Block a user