Skip to content
Snippets Groups Projects
Commit af03cc29 authored by Release Webservice's avatar Release Webservice
Browse files

Finished release 0.37.

parents 444f45c8 40674038
No related branches found
No related tags found
No related merge requests found
......@@ -7,3 +7,4 @@ coverage.xml
.coverage
.tox
htmlcov
dist
......@@ -53,4 +53,5 @@
0.34: POL1-135: initial support for service category api
DBOARD3-203: omit 'inactive' interfaces
0.35: POL1-135: added customer(user) info to service category api response
0.36: DBOARD3-218: added project name to circuit info
\ No newline at end of file
0.36: DBOARD3-218: added project name to circuit info
0.37: DBOARD3-220: make redis/sentinel socket timeouts configurable
\ No newline at end of file
......@@ -16,7 +16,11 @@ CONFIG_SCHEMA = {
},
"required": ["hostname", "dbname", "username", "password"],
"additionalProperties": False
},
"timeout": {
"type": "number",
"maximum": 10, # sanity
"exclusiveMinimum": 0
}
},
......@@ -37,7 +41,8 @@ CONFIG_SCHEMA = {
"type": "object",
"properties": {
"hostname": {"type": "string"},
"port": {"type": "integer"}
"port": {"type": "integer"},
"socket_timeout": {"$ref": "#/definitions/timeout"}
},
"required": ["hostname", "port"],
"additionalProperties": False
......@@ -47,7 +52,9 @@ CONFIG_SCHEMA = {
"properties": {
"hostname": {"type": "string"},
"port": {"type": "integer"},
"name": {"type": "string"}
"name": {"type": "string"},
"redis_socket_timeout": {"$ref": "#/definitions/timeout"},
"sentinel_socket_timeout": {"$ref": "#/definitions/timeout"}
},
"required": ["hostname", "port", "name"],
"additionalProperties": False
......
......@@ -7,6 +7,9 @@ import redis.sentinel
logger = logging.getLogger(__name__)
DEFAULT_REDIS_SENTINEL_TIMEOUT = 0.1
DEFAULT_SENTINEL_SOCKET_TIMEOUT = 0.1
DB_LATCH_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
......@@ -102,19 +105,23 @@ def _get_redis(config, dbid=None):
dbid = min(config['redis-databases'])
kwargs = {
'db': dbid,
'socket_timeout': 0.1
'db': dbid
}
if 'sentinel' in config:
kwargs['socket_timeout'] = config['sentinel'].get(
'sentinel_socket_timeout', DEFAULT_SENTINEL_SOCKET_TIMEOUT)
sentinel = redis.sentinel.Sentinel([(
config['sentinel']['hostname'],
config['sentinel']['port'])],
**kwargs)
return sentinel.master_for(
config['sentinel']['name'],
socket_timeout=0.1)
socket_timeout=config['sentinel'].get(
'redis_socket_timeout', DEFAULT_REDIS_SENTINEL_TIMEOUT))
else:
kwargs['socket_timeout'] = config['redis'].get(
'socket_timeout', DEFAULT_REDIS_SENTINEL_TIMEOUT)
return redis.StrictRedis(
host=config['redis']['hostname'],
port=config['redis']['port'],
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='inventory-provider',
version="0.36",
version="0.37",
author='GEANT',
author_email='swd@geant.org',
description='Dashboard inventory provider',
......@@ -13,7 +13,7 @@ setup(
'click',
'mysql-connector',
'pysnmp',
'jsonschema',
'jsonschema==3.2.0',
'paramiko',
'flask',
'redis==3.2.1',
......
......@@ -38,7 +38,8 @@ def data_config_filename():
},
"redis": {
"hostname": "xxxxxx",
"port": 6379
"port": 6379,
"socket_timeout": 2.8
},
"redis-databases": [0, 7],
"junosspace": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment