summaryrefslogtreecommitdiffstats
path: root/docker/storperf-master/rest_server.py
diff options
context:
space:
mode:
authorMark Beierl <mark.beierl@dell.com>2017-08-21 17:11:39 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-21 17:11:39 +0000
commit596470aa54a78537434343e6cd310b77128d2ad6 (patch)
treecec717f4d6f5a2ca5fa43aaa1e8c3290dce6c090 /docker/storperf-master/rest_server.py
parenta5085dc6cd9995d7dc78933ff2d12eaa342a6358 (diff)
parent0cfd0baf13b2cf1d78cbe98b2c7ded9e51ffe952 (diff)
Merge "REST API for logs"
Diffstat (limited to 'docker/storperf-master/rest_server.py')
-rw-r--r--docker/storperf-master/rest_server.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/docker/storperf-master/rest_server.py b/docker/storperf-master/rest_server.py
index 19f87ca..8d1ad78 100644
--- a/docker/storperf-master/rest_server.py
+++ b/docker/storperf-master/rest_server.py
@@ -26,6 +26,35 @@ api = swagger.docs(Api(app), apiVersion='1.0')
storperf = StorPerfMaster()
+class Logs(Resource):
+ def __init__(self):
+ self.logger = logging.getLogger(__name__)
+
+ @swagger.operation(
+ notes="Fetch logs",
+ parameters=[
+ {
+ "name": "lines",
+ "description": "The number of lines to fetch",
+ "required": "False",
+ "type": "string",
+ "allowedMultiple": "False",
+ "paramType": "query"
+ }
+ ]
+ )
+ def get(self):
+ lines = request.args.get('lines')
+ if lines:
+ try:
+ lines = int(lines)
+ except Exception:
+ pass
+ else:
+ lines = 35
+ return jsonify({'logs': storperf.get_logs(lines)})
+
+
@swagger.model
class ConfigurationRequestModel:
resource_fields = {
@@ -343,6 +372,7 @@ def setup_logging(default_path='logging.json',
api.add_resource(Configure, "/api/v1.0/configurations")
api.add_resource(Quota, "/api/v1.0/quotas")
api.add_resource(Job, "/api/v1.0/jobs")
+api.add_resource(Logs, "/api/v1.0/logs")
if __name__ == "__main__":
setup_logging()