Merge "Add qtip job to pod zte-virtual6"
[releng.git] / utils / test / dashboard / dashboard / common / elastic_access.py
index 8c6494d..eb29ce8 100644 (file)
@@ -1,4 +1,5 @@
 import json
+import urlparse
 
 import urllib3
 
@@ -29,7 +30,7 @@ def publish_docs(url, creds=None, body=None):
 
 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']
 
 
@@ -43,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)