forked from shaba/openuds
Merge remote-tracking branch 'origin/v3.5'
This commit is contained in:
commit
a0365e1277
@ -53,9 +53,10 @@ if typing.TYPE_CHECKING:
|
|||||||
cache = Cache('StatsDispatcher')
|
cache = Cache('StatsDispatcher')
|
||||||
|
|
||||||
# Enclosed methods under /stats path
|
# Enclosed methods under /stats path
|
||||||
POINTS = 300
|
POINTS = 150
|
||||||
SINCE = 30 # Days, if higer values used, ensure mysql/mariadb has a bigger sort buffer
|
SINCE = 30 # Days, if higer values used, ensure mysql/mariadb has a bigger sort buffer
|
||||||
USE_MAX = True
|
USE_MAX = True
|
||||||
|
CACHE_TIME = SINCE * 24 * 3600 // POINTS
|
||||||
|
|
||||||
|
|
||||||
def getServicesPoolsCounters(
|
def getServicesPoolsCounters(
|
||||||
@ -93,7 +94,7 @@ def getServicesPoolsCounters(
|
|||||||
val.append({'stamp': x[0], 'value': int(x[1])})
|
val.append({'stamp': x[0], 'value': int(x[1])})
|
||||||
logger.debug('val: %s', val)
|
logger.debug('val: %s', val)
|
||||||
if len(val) >= 2:
|
if len(val) >= 2:
|
||||||
cache.put(cacheKey, codecs.encode(pickle.dumps(val), 'zip'), 600)
|
cache.put(cacheKey, codecs.encode(pickle.dumps(val), 'zip'), CACHE_TIME*2)
|
||||||
else:
|
else:
|
||||||
val = [{'stamp': since, 'value': 0}, {'stamp': to, 'value': 0}]
|
val = [{'stamp': since, 'value': 0}, {'stamp': to, 'value': 0}]
|
||||||
else:
|
else:
|
||||||
|
@ -204,6 +204,7 @@ class OVirtLinkedDeployment(services.UserDeployment):
|
|||||||
if self.cache.get('ready') == '1':
|
if self.cache.get('ready') == '1':
|
||||||
return State.FINISHED
|
return State.FINISHED
|
||||||
|
|
||||||
|
try:
|
||||||
state = self.service().getMachineState(self._vmid)
|
state = self.service().getMachineState(self._vmid)
|
||||||
|
|
||||||
if state == 'unknown':
|
if state == 'unknown':
|
||||||
@ -214,6 +215,10 @@ class OVirtLinkedDeployment(services.UserDeployment):
|
|||||||
return self.__executeQueue()
|
return self.__executeQueue()
|
||||||
|
|
||||||
self.cache.put('ready', '1')
|
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
|
||||||
|
|
||||||
return State.FINISHED
|
return State.FINISHED
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
|
@ -131,6 +131,7 @@ class LiveDeployment(UserDeployment): # pylint: disable=too-many-public-methods
|
|||||||
if self.cache.get('ready') == '1':
|
if self.cache.get('ready') == '1':
|
||||||
return State.FINISHED
|
return State.FINISHED
|
||||||
|
|
||||||
|
try:
|
||||||
state = self.service().getMachineState(self._vmid)
|
state = self.service().getMachineState(self._vmid)
|
||||||
|
|
||||||
if state == on.types.VmState.UNKNOWN: # @UndefinedVariable
|
if state == on.types.VmState.UNKNOWN: # @UndefinedVariable
|
||||||
@ -139,6 +140,10 @@ class LiveDeployment(UserDeployment): # pylint: disable=too-many-public-methods
|
|||||||
self.service().startMachine(self._vmid)
|
self.service().startMachine(self._vmid)
|
||||||
|
|
||||||
self.cache.put('ready', '1')
|
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
|
||||||
|
|
||||||
return State.FINISHED
|
return State.FINISHED
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
|
@ -142,6 +142,7 @@ class LiveDeployment(UserDeployment): # pylint: disable=too-many-public-methods
|
|||||||
if self.cache.get('ready') == '1':
|
if self.cache.get('ready') == '1':
|
||||||
return State.FINISHED
|
return State.FINISHED
|
||||||
|
|
||||||
|
try:
|
||||||
status = self.service().getMachineState(self._vmid)
|
status = self.service().getMachineState(self._vmid)
|
||||||
|
|
||||||
if openstack.statusIsLost(status):
|
if openstack.statusIsLost(status):
|
||||||
@ -155,6 +156,10 @@ class LiveDeployment(UserDeployment): # pylint: disable=too-many-public-methods
|
|||||||
# Right now, we suppose the machine is ready
|
# Right now, we suppose the machine is ready
|
||||||
|
|
||||||
self.cache.put('ready', '1')
|
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
|
||||||
|
|
||||||
return State.FINISHED
|
return State.FINISHED
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
|
@ -174,8 +174,8 @@ class ProxmoxDeployment(services.UserDeployment):
|
|||||||
vmInfo = self.service().getMachineInfo(int(self._vmid))
|
vmInfo = self.service().getMachineInfo(int(self._vmid))
|
||||||
except client.ProxmoxConnectionError:
|
except client.ProxmoxConnectionError:
|
||||||
raise # If connection fails, let it fail on parent
|
raise # If connection fails, let it fail on parent
|
||||||
except Exception:
|
except Exception as e:
|
||||||
return self.__error('Machine not found')
|
return self.__error('Machine not found: {}'.format(e))
|
||||||
|
|
||||||
if vmInfo.status == 'stopped':
|
if vmInfo.status == 'stopped':
|
||||||
self._queue = [opStart, opFinish]
|
self._queue = [opStart, opFinish]
|
||||||
|
@ -141,14 +141,21 @@ class XenLinkedDeployment(UserDeployment):
|
|||||||
return self._ip
|
return self._ip
|
||||||
|
|
||||||
def setReady(self) -> str:
|
def setReady(self) -> str:
|
||||||
|
if self.cache.get('ready') == '1':
|
||||||
|
return State.FINISHED
|
||||||
|
|
||||||
try:
|
try:
|
||||||
state = self.service().getVMPowerState(self._vmid)
|
state = self.service().getVMPowerState(self._vmid)
|
||||||
|
|
||||||
if state != XenPowerState.running:
|
if state != XenPowerState.running:
|
||||||
self._queue = [opStart, opFinish]
|
self._queue = [opStart, opFinish]
|
||||||
return self.__executeQueue()
|
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
|
return State.FINISHED
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user