
+ Added function for Rally Results + Modified the Service filed + Rally.py now produces a json file and returns json + Grafana to return the URL list + Quick single workload test worked.. +1 + Switched to a List for the config + Rebase + Remove parent/child work + Error check + Default 3 jsons in the config file + Rebase + Pep + Remove Grafana-API Key per Akrzos + Small bug + Removed getter/setter in Grafana.py Change-Id: I9f1d5f27597c4c4897fc4ee821aad309fa11a04b
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
from elasticsearch import Elasticsearch
|
|
import logging
|
|
import json
|
|
import pprint
|
|
import numpy
|
|
|
|
class Elastic:
|
|
"""
|
|
"""
|
|
def __init__(self,config,tool="browbeat") :
|
|
self.config = config
|
|
self.logger = logging.getLogger('browbeat.Elastic')
|
|
self.es = Elasticsearch([
|
|
{'host': self.config['elasticsearch']['host'],
|
|
'port': self.config['elasticsearch']['port']}],
|
|
send_get_body_as='POST'
|
|
)
|
|
self.index = tool
|
|
|
|
"""
|
|
"""
|
|
def load_json(self,result):
|
|
json_data = None
|
|
self.logger.info("Loading JSON")
|
|
json_data = json.loads(result)
|
|
return json_data
|
|
|
|
"""
|
|
"""
|
|
def load_json_file(self,result):
|
|
json_data = None
|
|
self.logger.info("Loading JSON file : {}".format(result))
|
|
try :
|
|
with open(result) as jdata :
|
|
json_data = json.load(jdata)
|
|
except (IOError, OSError) as e:
|
|
self.logger.error("Error loading JSON file : {}".format(result))
|
|
return False
|
|
return json_data
|
|
|
|
"""
|
|
"""
|
|
def combine_metadata(self,result):
|
|
if len(self.config['elasticsearch']['metadata_files']) > 0 :
|
|
meta = self.config['elasticsearch']['metadata_files']
|
|
for _meta in meta:
|
|
try :
|
|
with open(_meta['file']) as jdata :
|
|
result[_meta['name']] = json.load(jdata)
|
|
except (IOError, OSError) as e:
|
|
self.logger.error("Error loading Metadata file : {}".format(_meta['file']))
|
|
return False
|
|
return result
|
|
|
|
"""
|
|
"""
|
|
def index_result(self,result,_id=None) :
|
|
return self.es.index(index=self.index,
|
|
id=_id,
|
|
body=result,
|
|
doc_type='result',
|
|
refresh=True
|
|
)
|