From c523533a71698a34d7a0a08670a3c29931175473 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Tue, 18 Oct 2016 15:00:01 +0800 Subject: make elastic index configurable rather than settled in code JIRA: FUNCTEST-519 Change-Id: I4c97c01492ed47b589b0e8981dcfb431ca0838ae Signed-off-by: SerenaFeng --- dashboard/dashboard/conf/config.py | 6 ++++++ dashboard/dashboard/elastic2kibana/main.py | 8 +++----- dashboard/dashboard/mongo2elastic/main.py | 13 ++++--------- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'dashboard/dashboard') diff --git a/dashboard/dashboard/conf/config.py b/dashboard/dashboard/conf/config.py index 44cf797..6114e90 100644 --- a/dashboard/dashboard/conf/config.py +++ b/dashboard/dashboard/conf/config.py @@ -1,5 +1,6 @@ #! /usr/bin/env python +import urlparse from ConfigParser import SafeConfigParser, NoOptionError @@ -27,6 +28,7 @@ class APIConfig: self.es_creds = None self.kibana_url = None self.js_path = None + self.index_url = None def _get_str_parameter(self, section, param): try: @@ -67,6 +69,8 @@ class APIConfig: obj.es_creds = obj._get_str_parameter("elastic", "creds") obj.kibana_url = obj._get_str_parameter("kibana", "url") obj.js_path = obj._get_str_parameter("kibana", "js_path") + index = obj._get_str_parameter("elastic", "index") + obj.index_url = urlparse.urljoin(obj.es_url, index) return obj @@ -74,7 +78,9 @@ class APIConfig: return "elastic_url = %s \n" \ "elastic_creds = %s \n" \ "kibana_url = %s \n" \ + "index_url = %s \n" \ "js_path = %s \n" % (self.es_url, self.es_creds, self.kibana_url, + self.index_url, self.js_path) diff --git a/dashboard/dashboard/elastic2kibana/main.py b/dashboard/dashboard/elastic2kibana/main.py index 5af512e..112d222 100644 --- a/dashboard/dashboard/elastic2kibana/main.py +++ b/dashboard/dashboard/elastic2kibana/main.py @@ -1,6 +1,5 @@ #! /usr/bin/env python import json -import urlparse import argparse @@ -131,10 +130,9 @@ class KibanaConstructor(object): } }) - elastic_data = elastic_access.get_docs( - urlparse.urljoin(CONF.es_url, '/testapi/results'), - CONF.es_creds, - query) + elastic_data = elastic_access.get_docs(CONF.index_url, + CONF.es_creds, + query) pods_and_scenarios = {} diff --git a/dashboard/dashboard/mongo2elastic/main.py b/dashboard/dashboard/mongo2elastic/main.py index c2a8d11..688f55f 100644 --- a/dashboard/dashboard/mongo2elastic/main.py +++ b/dashboard/dashboard/mongo2elastic/main.py @@ -5,7 +5,6 @@ import json import os import subprocess import traceback -import urlparse import uuid import argparse @@ -188,7 +187,7 @@ class DocumentsPublisher(object): self._remove() exit(-1) - def get_existed_docs(self): + def get_exists(self): if self.days == 0: body = '''{{ "query": {{ @@ -242,10 +241,6 @@ class DocumentsPublisher(object): def main(): - base_elastic_url = urlparse.urljoin(CONF.es_url, '/testapi/results') - days = args.latest_days - es_creds = CONF.es_creds - for project, case_dicts in testcases.testcases_yaml.items(): for case_dict in case_dicts: case = case_dict.get('name') @@ -253,6 +248,6 @@ def main(): DocumentsPublisher(project, case, fmt, - days, - base_elastic_url, - es_creds).export().get_existed_docs().publish() + args.latest_days, + CONF.index_url, + CONF.es_creds).export().get_exists().publish() -- cgit 1.2.3-korg