forked from Yelp/elastalert
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend ElasticSearch and move elasticsearch version checks into extended
class elasticsearch_test - test api calls against elasticsearch
- Loading branch information
Showing
8 changed files
with
254 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
from elasticsearch import Elasticsearch, RequestsHttpConnection | ||
|
||
|
||
class ElasticSearchClient(Elasticsearch): | ||
|
||
def __init__(self, conf): | ||
super(ElasticSearchClient, self).__init__(host=conf['es_host'], | ||
port=conf['es_port'], | ||
url_prefix=conf['es_url_prefix'], | ||
use_ssl=conf['use_ssl'], | ||
verify_certs=conf['verify_certs'], | ||
ca_certs=conf['ca_certs'], | ||
connection_class=RequestsHttpConnection, | ||
http_auth=conf['http_auth'], | ||
timeout=conf['es_conn_timeout'], | ||
send_get_body_as=conf['send_get_body_as'], | ||
client_cert=conf['client_cert'], | ||
client_key=conf['client_key']) | ||
self._conf = conf | ||
self._es_version = None | ||
|
||
@property | ||
def conf(self): | ||
return self._conf | ||
|
||
@property | ||
def es_version(self): | ||
if self._es_version is None: | ||
self._es_version = self.info()['version']['number'] | ||
return self._es_version | ||
|
||
def is_atleastfive(self): | ||
return int(self.es_version.split(".")[0]) >= 5 | ||
|
||
def is_atleastsix(self): | ||
return int(self.es_version.split(".")[0]) >= 6 | ||
|
||
def is_atleastsixsix(self): | ||
major, minor = map(int, self.es_version.split(".")[:2]) | ||
return major > 6 or (major == 6 and minor >= 6) | ||
|
||
def is_atleastseven(self): | ||
return int(self.es_version.split(".")[0]) >= 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.