X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Fscripts%2Fpush_to_elk.py;h=e0d37ffd111fb09cd0e665b7158b042ab85835ed;hb=7b490aee8c74c4bba23494fdab6ddf8ada56093a;hp=41f4a0b7c6296a081f6aa5ae8aaf9639090f150c;hpb=011dff0315d0cd1bc39ea9ec2735af2aca3bb2af;p=integration%2Ftest.git diff --git a/csit/scripts/push_to_elk.py b/csit/scripts/push_to_elk.py index 41f4a0b7c6..e0d37ffd11 100755 --- a/csit/scripts/push_to_elk.py +++ b/csit/scripts/push_to_elk.py @@ -95,7 +95,8 @@ else: for f in csv_files: key = (f.split('/')[-1])[:-4] BODY['plots'][key] = {} - lines = open(f).readlines() + with open(f) as file: + lines = file.readlines() props = lines[0].strip().split(',') vals = lines[1].strip().split(',') BODY['plots'][key][props[0]] = float(vals[0]) @@ -138,7 +139,7 @@ print(json.dumps(BODY, indent=4)) try: r = requests.put(PUT_URL, json=BODY) print(r.status_code) - print(json.dumps(json.loads(r.content), indent=4)) + print(json.dumps(r.json(), indent=4)) except: print('Unable to push data to ElasticSearch') @@ -320,7 +321,7 @@ if BODY['test-type'] == 'performance': try: r = requests.put(PUT_URL, json=vis) print(r.status_code) - print(json.dumps(json.loads(r.content), indent=4)) + print(json.dumps(r.json(), indent=4)) except: print('Unable to push visualization to Kibana') @@ -333,7 +334,7 @@ print(json.dumps(vis, indent=4)) try: r = requests.put(PUT_URL, json=vis) print(r.status_code) - print(json.dumps(json.loads(r.content), indent=4)) + print(json.dumps(r.json(), indent=4)) except: print('Unable to push dashboard to Kibana') @@ -357,12 +358,12 @@ dashboard['kibanaSavedObjectMeta'] = { GET_URL = 'https://{}:{}/.kibana/dashboard/{}'.format(ELK_DB_HOST, ELK_DB_PORT, DASHBOARD_NAME) r = requests.get(GET_URL) -response = json.loads(r.content) +response = r.json() dashboard_found = response['found'] vis_ids_present = set() panelsJSON = [] -print json.dumps(response, indent=4) +print(json.dumps(response, indent=4)) if dashboard_found: panelsJSON = yaml.safe_load(response['_source']['panelsJSON']) for vis in panelsJSON: @@ -397,4 +398,4 @@ print(PUT_URL) print(json.dumps(dashboard, indent=4)) r = requests.put(PUT_URL, json=dashboard) print(r.status_code) -print(json.dumps(json.loads(r.content), indent=4)) +print(json.dumps(r.json(), indent=4))