X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Ftest%2Fdashboard%2Fdashboard%2Fcommon%2Felastic_access.py;h=eb29ce87907cffe9193c862857486085c8ed0595;hb=122cf34bf3e656e1b7fa35e07dd8a71e42ed4d59;hp=6d82e8e437d792c65dea5725064bca44eac9f242;hpb=4ba53f4e81549104f0ba785a6d072f56305d42f8;p=releng.git diff --git a/utils/test/dashboard/dashboard/common/elastic_access.py b/utils/test/dashboard/dashboard/common/elastic_access.py index 6d82e8e43..eb29ce879 100644 --- a/utils/test/dashboard/dashboard/common/elastic_access.py +++ b/utils/test/dashboard/dashboard/common/elastic_access.py @@ -1,4 +1,5 @@ import json +import urlparse import urllib3 @@ -22,19 +23,14 @@ 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): res_data = _get('{}/_search?size=0'.format(url), creds=creds, body=body) - print type(res_data), res_data + print(type(res_data), res_data) return res_data['hits']['total'] @@ -48,3 +44,8 @@ def get_docs(url, creds=None, body=None, field='_source'): for hit in res_data['hits']['hits']: docs.append(hit[field]) return docs + + +def publish_kibana(url, creds, type, id, body): + url = urlparse.urljoin(url, '/.kibana/{}/{}'.format(type, id)) + publish_docs(url, creds, body)