summaryrefslogtreecommitdiffstats
path: root/dashboard
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-09-28 07:42:30 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-09-28 07:42:31 +0000
commit41889729b034451eaa5d42ed4a80daf69b96a0ad (patch)
tree6156cd7cfe3fcbbb522d50dae271a3256b535307 /dashboard
parenteda16085a4a2e65db90d4e01e9925f86a7c479b6 (diff)
parent0782c4263d39bd7b44cc19e19107c7dda3a4b45e (diff)
Merge "no more output elastic docs to stdout/console"
Diffstat (limited to 'dashboard')
-rw-r--r--dashboard/dashboard/common/elastic_access.py11
-rw-r--r--dashboard/dashboard/conf/config.py12
-rw-r--r--dashboard/dashboard/elastic2kibana/main.py5
-rw-r--r--dashboard/dashboard/mongo2elastic/main.py18
-rw-r--r--dashboard/etc/config.ini4
5 files changed, 15 insertions, 35 deletions
diff --git a/dashboard/dashboard/common/elastic_access.py b/dashboard/dashboard/common/elastic_access.py
index 6d82e8e..8c6494d 100644
--- a/dashboard/dashboard/common/elastic_access.py
+++ b/dashboard/dashboard/common/elastic_access.py
@@ -22,14 +22,9 @@ def delete_docs(url, creds=None, body=None):
return _request('DELETE', url, creds=creds, body=body)
-def publish_docs(docs, creds, to):
- json_docs = json.dumps(docs)
- if to == 'stdout':
- print json_docs
- return 200, None
- else:
- result = _post(to, creds=creds, body=json_docs)
- return result.status, result.data
+def publish_docs(url, creds=None, body=None):
+ result = _post(url, creds=creds, body=(json.dumps(body)))
+ return result.status, result.data
def _get_docs_nr(url, creds=None, body=None):
diff --git a/dashboard/dashboard/conf/config.py b/dashboard/dashboard/conf/config.py
index 2e0f1ca..b868999 100644
--- a/dashboard/dashboard/conf/config.py
+++ b/dashboard/dashboard/conf/config.py
@@ -25,7 +25,6 @@ class APIConfig:
self._default_config_location = "../etc/config.ini"
self.elastic_url = 'http://localhost:9200'
self.elastic_creds = None
- self.destination = 'elasticsearch'
self.kibana_url = None
self.is_js = True
self.js_path = None
@@ -67,7 +66,6 @@ class APIConfig:
# Linking attributes to keys from file with their sections
obj.elastic_url = obj._get_str_parameter("elastic", "url")
obj.elastic_creds = obj._get_str_parameter("elastic", "creds")
- obj.destination = obj._get_str_parameter("output", "destination")
obj.kibana_url = obj._get_str_parameter("kibana", "url")
obj.is_js = obj._get_bool_parameter("kibana", "js")
obj.js_path = obj._get_str_parameter("kibana", "js_path")
@@ -77,12 +75,10 @@ class APIConfig:
def __str__(self):
return "elastic_url = %s \n" \
"elastic_creds = %s \n" \
- "destination = %s \n" \
"kibana_url = %s \n" \
"is_js = %s \n" \
"js_path = %s \n" % (self.elastic_url,
- self.elastic_creds,
- self.destination,
- self.kibana_url,
- self.is_js,
- self.js_path)
+ self.elastic_creds,
+ self.kibana_url,
+ self.is_js,
+ self.js_path)
diff --git a/dashboard/dashboard/elastic2kibana/main.py b/dashboard/dashboard/elastic2kibana/main.py
index 38a49b6..95f758e 100644
--- a/dashboard/dashboard/elastic2kibana/main.py
+++ b/dashboard/dashboard/elastic2kibana/main.py
@@ -60,7 +60,7 @@ class KibanaDashboard(dict):
url = urlparse.urljoin(base_elastic_url, '/.kibana/visualization/{}'.format(visualization.id))
logger.debug("publishing visualization '{}'".format(url))
# logger.error("_publish_visualization: %s" % visualization)
- elastic_access.publish_docs(visualization, es_creds, url)
+ elastic_access.publish_docs(url, es_creds, visualization)
def _construct_panels(self):
size_x = 6
@@ -138,7 +138,7 @@ class KibanaDashboard(dict):
def _publish(self):
url = urlparse.urljoin(base_elastic_url, '/.kibana/dashboard/{}'.format(self.id))
logger.debug("publishing dashboard '{}'".format(url))
- elastic_access.publish_docs(self, es_creds, url)
+ elastic_access.publish_docs(url, es_creds, self)
def publish(self):
self._publish_visualizations()
@@ -191,7 +191,6 @@ class VisualizationBuilder(object):
return json.loads(vis)
-
class KibanaVisualization(dict):
def __init__(self, project_name, case_name, installer, pod, scenario, visualization):
"""
diff --git a/dashboard/dashboard/mongo2elastic/main.py b/dashboard/dashboard/mongo2elastic/main.py
index ad04372..76efb14 100644
--- a/dashboard/dashboard/mongo2elastic/main.py
+++ b/dashboard/dashboard/mongo2elastic/main.py
@@ -38,12 +38,12 @@ tmp_docs_file = './mongo-{}.json'.format(uuid.uuid4())
class DocumentPublisher:
- def __init__(self, doc, fmt, exist_docs, creds, to):
+ def __init__(self, doc, fmt, exist_docs, creds, elastic_url):
self.doc = doc
self.fmt = fmt
self.creds = creds
self.exist_docs = exist_docs
- self.to = to
+ self.elastic_url = elastic_url
self.is_formatted = True
def format(self):
@@ -64,7 +64,7 @@ class DocumentPublisher:
self._publish()
def _publish(self):
- status, data = elastic_access.publish_docs(self.doc, self.creds, self.to)
+ status, data = elastic_access.publish_docs(self.elastic_url, self.creds, self.doc)
if status > 300:
logger.error('Publish record[{}] failed, due to [{}]'
.format(self.doc, json.loads(data)['error']['reason']))
@@ -163,14 +163,13 @@ class DocumentPublisher:
class DocumentsPublisher:
- def __init__(self, project, case, fmt, days, elastic_url, creds, to):
+ def __init__(self, project, case, fmt, days, elastic_url, creds):
self.project = project
self.case = case
self.fmt = fmt
self.days = days
self.elastic_url = elastic_url
self.creds = creds
- self.to = to
self.existed_docs = []
def export(self):
@@ -240,7 +239,7 @@ class DocumentsPublisher:
self.fmt,
self.existed_docs,
self.creds,
- self.to).format().publish()
+ self.elastic_url).format().publish()
finally:
fdocs.close()
self._remove()
@@ -252,13 +251,9 @@ class DocumentsPublisher:
def main():
base_elastic_url = urlparse.urljoin(CONF.elastic_url, '/test_results/mongo2elastic')
- to = CONF.destination
days = args.latest_days
es_creds = CONF.elastic_creds
- if to == 'elasticsearch':
- to = base_elastic_url
-
for project, case_dicts in testcases.testcases_yaml.items():
for case_dict in case_dicts:
case = case_dict.get('name')
@@ -268,5 +263,4 @@ def main():
fmt,
days,
base_elastic_url,
- es_creds,
- to).export().get_existed_docs().publish()
+ es_creds).export().get_existed_docs().publish()
diff --git a/dashboard/etc/config.ini b/dashboard/etc/config.ini
index b94ac7b..1e67bd8 100644
--- a/dashboard/etc/config.ini
+++ b/dashboard/etc/config.ini
@@ -4,10 +4,6 @@
url = http://localhost:9200
creds =
-[output]
-# elasticsearch or console
-destination = elasticsearch
-
[kibana]
url = http://10.63.243.17:5601/app/kibana
js = true