in api/plugins/database.py [0:0]
def __init__(self, config):
self.config = config
# sqlite driver?
if self.config['database']['driver'] == 'sqlite':
self.dbtype = 'sqlite'
self.sqlite = WarbleSqlite(self.config['database']['path'])
# ES driver?
if self.config['database']['driver'] == 'elasticsearch':
import elasticsearch
self.dbtype = 'elasticsearch'
self.dbname = config['elasticsearch']['dbname']
self.ES = elasticsearch.Elasticsearch([{
'host': config['elasticsearch']['host'],
'port': int(config['elasticsearch']['port']),
'use_ssl': config['elasticsearch']['ssl'],
'verify_certs': False,
'url_prefix': config['elasticsearch']['uri'] if 'uri' in config['elasticsearch'] else '',
'http_auth': config['elasticsearch']['auth'] if 'auth' in config['elasticsearch'] else None
}],
max_retries=5,
retry_on_timeout=True
)
# IMPORTANT BIT: Figure out if this is ES 6.x or newer.
# If so, we're using the new ES DB mappings, and need to adjust ALL
# ES calls to match this.
es6 = True if int(self.ES.info()['version']['number'].split('.')[0]) >= 6 else False
if es6:
self.ES = WarbleESWrapper(self.ES)