Coverage for curator/defaults/client_defaults.py: 100%

1"""Define valid schemas for client configuration validation"""

2 from six import string_types

3 from voluptuous import All, Any, Boolean, Coerce, Optional, Range

4

5# Configuration file: client

6# pylint: disable=no-value-for-parameter

7 def config_client():

8 """Client schema"""

9 return {

10 Optional('hosts', default='127.0.0.1'): Any(None, list, *string_types),

11 Optional('port', default=9200): Any(None, All(Coerce(int), Range(min=1, max=65535))),

12 Optional('url_prefix', default=''): Any(None, *string_types),

13 Optional('use_ssl', default=False): Boolean(),

14 Optional('certificate', default=None): Any(None, *string_types),

15 Optional('client_cert', default=None): Any(None, *string_types),

16 Optional('client_key', default=None): Any(None, *string_types),

17 Optional('aws_key', default=None): Any(None, *string_types),

18 Optional('aws_secret_key', default=None): Any(None, *string_types),

19 Optional('aws_token', default=None): Any(None, *string_types),

20 Optional('aws_sign_request', default=False): Boolean(),

21 Optional('aws_region'): Any(None, *string_types),

22 Optional('ssl_no_validate', default=False): Boolean(),

23 Optional('username', default=None): Any(None, *string_types),

24 Optional('password', default=None): Any(None, *string_types),

25 Optional('http_auth', default=None): Any(None, *string_types),

26 Optional('timeout', default=30): All(Coerce(int), Range(min=1, max=86400)),

27 Optional('master_only', default=False): Boolean(),

28 Optional('api_key', default=None): Any(None, *string_types),

29 Optional('apikey_auth', default=None): Any(None, *string_types),

30 }

31

32# Configuration file: logging

33 def config_logging():

34 """Logging schema"""

35 return {

36 Optional('loglevel', default='INFO'):

37 Any(None, 'NOTSET', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL',

38 All(Coerce(int), Any(0, 10, 20, 30, 40, 50))

39 ),

40 Optional('logfile', default=None): Any(None, *string_types),

41 Optional('logformat', default='default'):

42 Any(None, All(Any(*string_types), Any('default', 'json', 'logstash', 'ecs'))),

43 Optional('blacklist', default=['elasticsearch', 'urllib3']): Any(None, list),

44 }