mirror of https://github.com/jumpserver/jumpserver
perf: ES connect error detail
parent
a822905ae7
commit
29f10bf10e
|
@ -117,13 +117,16 @@ def get_es_client_version(**kwargs):
|
|||
return version
|
||||
except SSLError:
|
||||
raise InvalidElasticsearchSSL
|
||||
except Exception:
|
||||
raise InvalidElasticsearch
|
||||
except Exception as e:
|
||||
raise InvalidElasticsearch(e)
|
||||
|
||||
|
||||
class ES(object):
|
||||
|
||||
def __init__(self, config, properties, keyword_fields, exact_fields=None, fuzzy_fields=None, match_fields=None, **kwargs):
|
||||
def __init__(
|
||||
self, config, properties, keyword_fields,
|
||||
exact_fields=None, fuzzy_fields=None, match_fields=None, **kwargs
|
||||
):
|
||||
self.version = 7
|
||||
self.config = config
|
||||
hosts = self.config.get('HOSTS')
|
||||
|
@ -132,7 +135,10 @@ class ES(object):
|
|||
ignore_verify_certs = kwargs.pop('IGNORE_VERIFY_CERTS', False)
|
||||
if ignore_verify_certs:
|
||||
kwargs['verify_certs'] = None
|
||||
try:
|
||||
self.client = ESClient(hosts=hosts, max_retries=0, **kwargs)
|
||||
except Exception as e:
|
||||
raise InvalidElasticsearch(e)
|
||||
self.es = self.client.es
|
||||
self.index_prefix = self.config.get('INDEX') or 'jumpserver'
|
||||
self.is_index_by_date = bool(self.config.get('INDEX_BY_DATE', False))
|
||||
|
|
Loading…
Reference in New Issue