diff options
author | saksham115 <saksham.agrawal@research.iiit.ac.in> | 2017-08-17 03:55:41 +0530 |
---|---|---|
committer | Saksham Agrawal <saksham.agrawal@research.iiit.ac.in> | 2017-08-16 22:46:13 +0000 |
commit | 432583fb52e5efb3d1417a498d2e72d7b3e3f70e (patch) | |
tree | 451c103bed83228d4aba84a985b69afdec8832ff /docker/storperf-reporting | |
parent | 1d3a2a843e03b8e36d6ac2069fdb1e143b08c91c (diff) |
Making the container compliant with the static data and selecting
the metrics, report data using flask server instead of Javascript
To test the static data, just enter the filename in the URL field
Now the metrics and the report data are taken from the json dump using
the server side(flask server) instead the client side
JIRA: STORPERF-194
Change-Id: I6747aa3db30ad30920c2459b9c5eb5a0c1e3539d
Signed-off-by: saksham115 <saksham.agrawal@research.iiit.ac.in>
Diffstat (limited to 'docker/storperf-reporting')
-rw-r--r-- | docker/storperf-reporting/requirements.txt | 3 | ||||
-rw-r--r-- | docker/storperf-reporting/src/app.py | 25 | ||||
-rw-r--r-- | docker/storperf-reporting/src/templates/plot_tables.html | 37 |
3 files changed, 52 insertions, 13 deletions
diff --git a/docker/storperf-reporting/requirements.txt b/docker/storperf-reporting/requirements.txt index 81903de..7016e72 100644 --- a/docker/storperf-reporting/requirements.txt +++ b/docker/storperf-reporting/requirements.txt @@ -1,2 +1,3 @@ Flask==0.12.2 -requests
\ No newline at end of file +requests +validators
\ No newline at end of file diff --git a/docker/storperf-reporting/src/app.py b/docker/storperf-reporting/src/app.py index 62d4d33..74d1339 100644 --- a/docker/storperf-reporting/src/app.py +++ b/docker/storperf-reporting/src/app.py @@ -10,17 +10,38 @@ from flask import Flask, redirect, url_for, request, render_template, session from flask import send_from_directory, flash import urllib +import validators import json app = Flask(__name__) app.secret_key = 'storperf_graphing_module' +def get_data(data): + metrics = {} + report_data = {} + temp = data.keys()[0] + if type(data[temp]) is list: + details = data[temp][0].get('details') + metrics = details.get('metrics') + report_data = details.get('report_data') + else: + metrics = data[temp].get('metrics') + report_data = data[temp].get('report_data') + return metrics, report_data + + @app.route('/reporting/success/') def success(): try: - data = urllib.urlopen(session["url"]).read() + URL = session["url"] + if validators.url(URL): + data = urllib.urlopen(URL).read() + else: + data = open("./static/testdata/" + URL).read() data = json.loads(data) - return render_template('plot_tables.html', data=data) + metrics, report_data = get_data(data) + return render_template('plot_tables.html', + metrics=metrics, report_data=report_data) except Exception as e: session['server_error'] = e.message + ' ' + repr(e.args) return redirect(url_for('file_not_found')) diff --git a/docker/storperf-reporting/src/templates/plot_tables.html b/docker/storperf-reporting/src/templates/plot_tables.html index 04eaadc..d6eed8e 100644 --- a/docker/storperf-reporting/src/templates/plot_tables.html +++ b/docker/storperf-reporting/src/templates/plot_tables.html @@ -27,17 +27,13 @@ </center> </div> <script> - data = {{ data | tojson | safe }}; page = []; - results = data.results; - if (results == undefined) { - details = data.details; - } else { - details = results[0].details; - } - metrics = details.metrics; - report_data = details.report_data; + metrics = {{ metrics | tojson | safe }}; + report_data = {{ report_data | tojson | safe }}; + console.log(metrics); + console.log(report_data); for (var key in report_data) { + console.log(key); for (var test in report_data[key]) { var text = ""; var series = []; @@ -73,6 +69,7 @@ } } } + console.log(page); function content_display(num) { var text = page[num - 1][0]; @@ -117,7 +114,27 @@ width: 2 } }; - Plotly.newPlot(graphID, [plot, avg_plus, avg_minus]); + var layout = { + xaxis: { + title: 'ROUND', + titlefont: { + family: 'Arial, sans-serif', + size: 18, + color: 'lightgrey' + }, + showticklabels: true, + }, + yaxis: { + title: 'IOPS', + titlefont: { + family: 'Arial, sans-serif', + size: 18, + color: 'lightgrey' + }, + showticklabels: true, + } +}; + Plotly.newPlot(graphID, [plot, avg_plus, avg_minus],layout); } content_display(1); $('#page-selection').bootpag({ |