From 2bdaf2bfb08cb35baf5b8f7704cf341af09f7475 Mon Sep 17 00:00:00 2001 From: Alvaro del Castillo Date: Sat, 27 Jan 2018 23:51:22 +0100 Subject: [PATCH] [task_panels] Improve the build of Kibiter URL to create the .kibana index Use global constants to define the Kibiter URL to create the .kibana index. Manage the exception if the URL call fails. --- mordred/task_panels.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mordred/task_panels.py b/mordred/task_panels.py index 8796e06d..bc1b4ef7 100644 --- a/mordred/task_panels.py +++ b/mordred/task_panels.py @@ -38,6 +38,8 @@ # Header mandatory in Ellasticsearc 6 (optional in earlier versions) ES6_HEADER = {"Content-Type": "application/json"} +ES6_KIBANA_INIT_DATA = '{"value": "*"}' +ES6_KIBANA_INIT_URL_PATH = "/api/kibana/settings/indexPattern:placeholder" def es_version(url): @@ -172,17 +174,16 @@ def __configure_kibiter(self): # Force the creation of the .kibana index # We don't have this data so it just works for this value k6_init_url = self.conf['panels']["kibiter_url"] - k6_init_url += "/api/kibana/settings/indexPattern:placeholder" - k6_init_data = '{"value": "*"}' + k6_init_url += ES6_KIBANA_INIT_URL_PATH k6_init_headers = { "Accept": "application/json", "Content-Type": "application/json", "kbn-version": self.conf['panels']['kibiter_version'] } - res = requests.post(k6_init_url, headers=k6_init_headers, - data=k6_init_data) try: + res = requests.post(k6_init_url, headers=k6_init_headers, + data=ES6_KIBANA_INIT_DATA) res.raise_for_status() except Exception as ex: logger.error("Can not create the .kibana in ES6 %s", ex)