Skip to content
Snippets Groups Projects
Commit 4b7f3c8c authored by Neda Moeini's avatar Neda Moeini
Browse files

Fixed the flake8 errors.

parent fdd123bc
No related branches found
No related tags found
1 merge request!11Added redis auth credentials to inventory config schema and updated _get_redis wrapper.
......@@ -180,18 +180,20 @@ def _get_redis(config, dbid=None):
if 'sentinel' in config:
sentinel_kwargs = {
'password': config['sentinel'].get('password'),
'socket_timeout': config['sentinel'].get('redis_socket_timeout', DEFAULT_REDIS_SENTINEL_TIMEOUT),
'socket_timeout': config['sentinel'].get(
'redis_socket_timeout', DEFAULT_REDIS_SENTINEL_TIMEOUT),
}
sentinel = redis.sentinel.Sentinel([(
config['sentinel']['hostname'],
config['sentinel']['port'])],
**kwargs)
return sentinel.master_for(
config['sentinel']['name'],**sentinel_kwargs)
config['sentinel']['name'], **sentinel_kwargs)
else:
redis_kwargs = {
'password': config['redis'].get('password'),
'socket_timeout': config['redis'].get('socket_timeout', DEFAULT_REDIS_SENTINEL_TIMEOUT),
'socket_timeout': config['redis'].get(
'socket_timeout', DEFAULT_REDIS_SENTINEL_TIMEOUT),
}
return redis.StrictRedis(
host=config['redis']['hostname'],
......
......@@ -41,7 +41,8 @@ def test_config_validation_include_sentinel(config):
'name': 'mymaster'
}
assert not validate_config(config)
# Configuration validation failed. One of the redis and sentinel should exist in the config.
# Configuration validation failed.
# One of the redis and sentinel should exist in the config.
del config['redis']
assert validate_config(config) # Configuration validation successful.
......
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