diff options
author | Mark Beierl <mark.beierl@dell.com> | 2017-08-17 21:57:18 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-08-17 21:57:18 +0000 |
commit | 8a17042d28bb9d4ddda71714c0045e4ed8bfd589 (patch) | |
tree | 17296c6b02e0671c0b5a3c6a0fed0c73875fb3f2 /docker/storperf-reporting/src | |
parent | de09799887339c5af02d96e20bb417fa65dbc8d1 (diff) | |
parent | 432583fb52e5efb3d1417a498d2e72d7b3e3f70e (diff) |
Merge "Making the container compliant with the static data and selecting the metrics, report data using flask server instead of Javascript"
Diffstat (limited to 'docker/storperf-reporting/src')
-rw-r--r-- | docker/storperf-reporting/src/app.py | 25 | ||||
-rw-r--r-- | docker/storperf-reporting/src/templates/plot_tables.html | 37 |
2 files changed, 50 insertions, 12 deletions
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({ |