From aa3f09743ca4cc48b7efe5a6a5c4d0fb30b15ea6 Mon Sep 17 00:00:00 2001 From: Christian Dahlqvist Date: Wed, 12 Sep 2018 15:56:15 +0100 Subject: [PATCH] Fixed path error for create index runner and Kibana parameter source. (#27) --- .../parameter_sources/elasticlogs_kibana_source.py | 3 ++- eventdata/runners/createindex_runner.py | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/eventdata/parameter_sources/elasticlogs_kibana_source.py b/eventdata/parameter_sources/elasticlogs_kibana_source.py index ce29c04815339..84d3583925dab 100755 --- a/eventdata/parameter_sources/elasticlogs_kibana_source.py +++ b/eventdata/parameter_sources/elasticlogs_kibana_source.py @@ -82,7 +82,8 @@ def __init__(self, track, params, **kwargs): if params['query_string'] in gs.global_config.keys(): self._query_string_list = gs.global_config[params['query_string']] else: - self._query_string_list = json.loads(open(os.path.expandvars(params['query_string']), 'rt', encoding="utf-8").read()) + cwd = os.path.dirname(__file__) + self._query_string_list = json.loads(open(os.path.join(cwd, "..", params['query_string']), 'rt', encoding="utf-8").read()) gs.global_config[params['query_string']] = self._query_string_list else: self._query_string_list = params['query_string'] diff --git a/eventdata/runners/createindex_runner.py b/eventdata/runners/createindex_runner.py index a3ecb0984c001..2ad5510472b25 100755 --- a/eventdata/runners/createindex_runner.py +++ b/eventdata/runners/createindex_runner.py @@ -21,15 +21,16 @@ def createindex(es, params): """ if 'index_template_body' in params: if 'index_template_name' in params: - template_name = params['index_template_name'] + template_name = params['index_template_name'] else: - template_name = 'elasticlogs' + template_name = 'elasticlogs' if 'mappings' in params['index_template_body'] and isinstance(params['index_template_body']['mappings'], str): if params['index_template_body']['mappings'] in gs.global_config.keys(): mapping = gs.global_config[params['index_template_body']['mappings']] else: - mapping_path = os.path.expandvars(params['index_template_body']['mappings']) + cwd = os.path.dirname(__file__) + mapping_path = os.path.join(cwd, "..", params['index_template_body']['mappings']) logger.info("[createindex] Use mapping file: %s", mapping_path) mapping = json.loads(open(mapping_path, 'rt', encoding="utf-8").read()) gs.global_config[params['index_template_body']['mappings']] = mapping @@ -41,8 +42,8 @@ def createindex(es, params): es.indices.put_template(name=template_name, body=params['index_template_body']) if 'alias' in params: - b = { 'aliases': {} } - b['aliases'][params['alias']] = {} + b = { 'aliases': {} } + b['aliases'][params['alias']] = {} else: b = { 'aliases': { 'elasticlogs_write': {} } } @@ -57,4 +58,4 @@ def createindex(es, params): es.indices.create(index=index_name, body=b, ignore=400) return 1, "ops" - \ No newline at end of file +