fixed timeout on actor (too high)

This commit is contained in:
Adolfo Gómez García 2020-01-20 16:55:06 +01:00
parent b3324eec91
commit 7cc6c6d3b8
6 changed files with 15 additions and 6 deletions

View File

@ -42,6 +42,9 @@ from .info import VERSION
# Default public listen port
LISTEN_PORT = 43910
# Default timeout
TIMEOUT = 5 # 5 seconds is more than enought
class RESTError(Exception):
ERRCODE = 0
@ -99,7 +102,7 @@ class UDSApi: # pylint: disable=too-few-public-methods
) -> typing.Any:
headers = headers or self._headers
try:
result = requests.post(self._apiURL(method), data=json.dumps(payLoad), headers=headers, verify=self._validateCert)
result = requests.post(self._apiURL(method), data=json.dumps(payLoad), headers=headers, verify=self._validateCert, timeout=TIMEOUT)
if result.ok:
j = result.json()
if not j.get('error', None):

View File

@ -189,7 +189,7 @@ class ServicesPools(ModelHandler):
val['pool_group_id'] = poolGroupId
val['pool_group_name'] = poolGroupName
val['pool_group_thumb'] = poolGroupThumb
val['usage'] = item.usage()
val['usage'] = str(item.usage()) + '%'
if item.osmanager:
val['osmanager_id'] = item.osmanager.uuid

View File

@ -32,5 +32,5 @@
"""
# pylint: disable=unused-import
from .common import ACTIVE, REMOVABLE, REMOVING, REMOVED # @UnusedImport
from .common import ACTIVE, REMOVABLE, REMOVING, REMOVED, INFO_STATES, VALID_STATES # @UnusedImport

View File

@ -229,7 +229,7 @@ class ServicePool(UUIDModel, TaggingMixin): # type: ignore
# Return the date
try:
if activePub and activePub.id != self.assignedUserServices().filter(user=forUser)[0].publication.id:
if activePub and activePub.id != self.assignedUserServices().filter(user=forUser, state__in=states.servicePool.VALID_STATES)[0].publication.id:
ret = self.recoverValue('toBeReplacedIn')
if ret:
return pickle.loads(ret)
@ -506,7 +506,7 @@ class ServicePool(UUIDModel, TaggingMixin): # type: ignore
if maxs <= 0:
return 0
return 100 * self.assignedUserServices().count() // maxs
return 100 * self.assignedUserServices().filter(state__in=states.servicePool.VALID_STATES).count() // maxs
def testServer(self, host, port, timeout=4) -> bool:
return self.service.testServer(host, port, timeout)

View File

@ -101,7 +101,8 @@ class XenProvider(ServiceProvider): # pylint: disable=too-many-public-methods
macsRange = gui.TextField(length=36, label=_('Macs range'), defvalue='02:46:00:00:00:00-02:46:00:FF:FF:FF', order=90, rdonly=True,
tooltip=_('Range of valid macs for created machines'), required=True, tab=gui.ADVANCED_TAB)
verifySSL = gui.CheckBoxField(label=_('Verify Certificate'), order=91,
tooltip=_('If selected, certificate will be checked against system valid certificate providers'), required=True, tab=gui.ADVANCED_TAB)
tooltip=_('If selected, certificate will be checked against system valid certificate providers'), required=True,
tab=gui.ADVANCED_TAB, defvalue=gui.FALSE)
_api: typing.Optional[XenServer]

View File

@ -165,10 +165,15 @@ class XenServer: # pylint: disable=too-many-public-methods
# We recalculate here url, because we can "switch host" on any moment
self._url = self._protocol + self._host + ':' + self._port
transport = None
if self._useSSL:
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
if self._verifySSL is False:
context.verify_mode = ssl.CERT_NONE
else:
context.verify_mode = ssl.CERT_REQUIRED
context.check_hostname = True
transport = xmlrpc.client.SafeTransport(context=context)
logger.debug('Transport: %s', transport)