summaryrefslogtreecommitdiffstats
path: root/rest_server.py
diff options
context:
space:
mode:
authorMark Beierl <mark.beierl@emc.com>2016-05-11 10:54:48 -0600
committerMark Beierl <mark.beierl@emc.com>2016-05-11 11:23:48 -0600
commit12d0fb066321f5503128b4babd79a3efd369fb07 (patch)
tree2844b2f7ef2e7441d0d7ce731abd987f89c38646 /rest_server.py
parentf250f3e2eb01e88adcf2f9f3c01d898ce2e5f5a9 (diff)
Job Run Metadata
Add the ability to store arbitrary metadata about the job for later reporting Change-Id: If7f1d0a69111567d69db865baec6c20f9a1f494f Signed-off-by: Mark Beierl <mark.beierl@emc.com>
Diffstat (limited to 'rest_server.py')
-rw-r--r--rest_server.py40
1 files changed, 35 insertions, 5 deletions
diff --git a/rest_server.py b/rest_server.py
index 45d77ff..b628a7e 100644
--- a/rest_server.py
+++ b/rest_server.py
@@ -95,9 +95,16 @@ def results_page(job_id):
'Write Latency (ms)')
writechart = chart.to_base64_image()
+ metadata = "<table>"
+ for key, value in params.iteritems():
+ metadata += "<TR><TD>" + key + "<TD>" + value + "</TR>"
+ metadata += "</table>"
+
html = """<html><body>%s <BR>
Number of VMs: %s <BR>
Cinder volume size per VM: %s (GB) <BR>
+ Metadata: <BR>
+ %s<BR>
<center>Read Latency Report <BR>
<img src="data:image/png;base64,%s"/>
<center>Write Latency Report <BR>
@@ -105,6 +112,7 @@ def results_page(job_id):
</body></html>""" % (job_id,
params['agent_count'],
params['volume_size'],
+ metadata,
readchart,
writechart,
)
@@ -233,7 +241,7 @@ class Job(Resource):
self.logger = logging.getLogger(__name__)
@swagger.operation(
- notes='Fetch the average latency of the specified workload',
+ notes='Fetch the metrics of the specified workload',
parameters=[
{
"name": "id",
@@ -243,12 +251,21 @@ class Job(Resource):
"type": "string",
"allowMultiple": False,
"paramType": "query"
+ },
+ {
+ "name": "type",
+ "description": "The type of metrics to report. May be "
+ "metrics (default), or metadata",
+ "required": False,
+ "type": "string",
+ "allowMultiple": False,
+ "paramType": "query"
}
],
responseMessages=[
{
"code": 200,
- "message": "Wordload ID found, response in JSON format"
+ "message": "Workload ID found, response in JSON format"
},
{
"code": 404,
@@ -257,9 +274,18 @@ class Job(Resource):
]
)
def get(self):
+
+ type = "metrics"
+ if request.args.get('type'):
+ type = request.args.get('type')
+
workload_id = request.args.get('id')
- print workload_id
- return jsonify(storperf.fetch_results(workload_id))
+
+ if type == "metrics":
+ return jsonify(storperf.fetch_results(workload_id))
+
+ if type == "metadata":
+ return jsonify(storperf.fetch_metadata(workload_id))
@swagger.operation(
parameters=[
@@ -310,8 +336,12 @@ class Job(Resource):
storperf.workloads = request.json['workload']
else:
storperf.workloads = None
+ if ('metadata' in request.json):
+ metadata = request.json['metadata']
+ else:
+ metadata = {}
- job_id = storperf.execute_workloads()
+ job_id = storperf.execute_workloads(metadata)
return jsonify({'job_id': job_id})