diff options
author | mbeierl <mark.beierl@dell.com> | 2018-07-13 14:50:17 -0400 |
---|---|---|
committer | mbeierl <mark.beierl@dell.com> | 2018-07-13 14:53:22 -0400 |
commit | 35643d32b7597c08af835c67ea76c1437d41330e (patch) | |
tree | be7c77245203c65bb5d9419f7709a545b3a763e4 /docker/storperf-master/rest_server.py | |
parent | f96c968bb5e8149354a3f31c6e704ce821e5d813 (diff) |
Initialization API
Adds a new API that performs initialization of the target
filename or device instead of having to rely on the
magic _warm_up workload name.
Change-Id: Icb7ece05fb6190802df08f5a4aeeba62652757db
JIRA: STORPERF-254
Signed-off-by: mbeierl <mark.beierl@dell.com>
Diffstat (limited to 'docker/storperf-master/rest_server.py')
-rw-r--r-- | docker/storperf-master/rest_server.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/docker/storperf-master/rest_server.py b/docker/storperf-master/rest_server.py index 9d9b7fa..8544f19 100644 --- a/docker/storperf-master/rest_server.py +++ b/docker/storperf-master/rest_server.py @@ -471,6 +471,68 @@ for any single test iteration. @swagger.model +class WarmUpModel: + resource_fields = { + 'target': fields.String + } + + +class Initialize(Resource): + + """Disk initialization API""" + + def __init__(self): + self.logger = logging.getLogger(__name__) + + @swagger.operation( + parameters=[ + { + "name": "body", + "description": """Fill the target with random data. If no +target is specified, it will default to /dev/vdb + +"target": The target device or file to fill with random data", + """, + "required": False, + "type": "WarmUpModel", + "paramType": "body" + } + ], + type=WorkloadResponseModel.__name__, + notes='''Initialize the target device or file by filling it to + capacity with random data. This is similar to the jobs API, + but does not have a deadline or steady state. It also + uses a predefined block size and queue depth.''', + responseMessages=[ + { + "code": 200, + "message": "Job submitted" + }, + { + "code": 400, + "message": "Missing configuration data" + } + ] + ) + def post(self): + self.logger.info(request.json) + + try: + if (request.json and 'target' in request.json): + storperf.filename = request.json['target'] + storperf.queue_depths = "8" + storperf.block_sizes = "8192" + storperf.workloads = "_warm_up" + job_id = storperf.execute_workloads() + + return jsonify({'job_id': job_id}) + + except Exception as e: + self.logger.exception(e) + abort(400, str(e)) + + +@swagger.model class QuotaModel: resource_fields = { @@ -516,6 +578,7 @@ def setup_logging(default_path='logging.json', api.add_resource(Configure, "/api/v1.0/configurations") +api.add_resource(Initialize, "/api/v1.0/initializations") api.add_resource(Quota, "/api/v1.0/quotas") api.add_resource(Job, "/api/v1.0/jobs") api.add_resource(Job_v2, "/api/v2.0/jobs") |