summaryrefslogtreecommitdiffstats
path: root/rest_server.py
diff options
context:
space:
mode:
authorMark Beierl <mark.beierl@emc.com>2016-05-04 22:53:07 -0400
committerMark Beierl <mark.beierl@emc.com>2016-05-06 14:13:52 -0400
commitda56b4dac702713045aaeeedbab9234e1825ffe0 (patch)
treeae5594911e25458bada74916f01e82520b2f423c /rest_server.py
parent05e863781ce6746fabec176d1fc5f7454f2cdd73 (diff)
Add Stats report and Swagger UI
Add Swagger web ui at /swagger Add ability to fetch read/write latency status via ReST ui Can now delete where stack was removed from OpenStack but not from the storperf DB Change to use Floating IPs instead of private IP Fix delete bug where there was no dependency on resources in the resource group. JIRA: STORPERF-19 JIRA: STORPERF-20 Change-Id: I1d9627d81f3c309b178a9b68cc306a4101c1a231 Signed-off-by: Mark Beierl <mark.beierl@emc.com>
Diffstat (limited to 'rest_server.py')
-rw-r--r--rest_server.py80
1 files changed, 75 insertions, 5 deletions
diff --git a/rest_server.py b/rest_server.py
index c5fe99b..f0a817b 100644
--- a/rest_server.py
+++ b/rest_server.py
@@ -25,15 +25,40 @@ storperf = StorPerfMaster()
@app.route('/swagger/<path:path>')
def send_swagger(path):
- print "called! storperf/resources/html/swagger/" + path
return send_from_directory('storperf/resources/html/swagger', path)
+@swagger.model
+class ConfigurationRequestModel:
+ resource_fields = {
+ 'agent_count': fields.Integer,
+ 'public_network': fields.String,
+ 'volume_size': fields.Integer
+ }
+
+
+@swagger.model
+class ConfigurationResponseModel:
+ resource_fields = {
+ 'agent_count': fields.Integer,
+ 'public_network': fields.String,
+ 'stack_created': fields.Boolean,
+ 'stack_id': fields.String,
+ 'volume_size': fields.Integer
+ }
+
+
class Configure(Resource):
+ """Configuration API"""
+
def __init__(self):
self.logger = logging.getLogger(__name__)
+ @swagger.operation(
+ notes='Fetch the current agent configuration',
+ type=ConfigurationResponseModel.__name__
+ )
def get(self):
return jsonify({'agent_count': storperf.agent_count,
'public_network': storperf.public_network,
@@ -41,6 +66,23 @@ class Configure(Resource):
'stack_created': storperf.is_stack_created,
'stack_id': storperf.stack_id})
+ @swagger.operation(
+ notes='''Set the current agent configuration and create a stack in
+ the controller. Returns once the stack request is submitted.''',
+ parameters=[
+ {
+ "name": "configuration",
+ "description": '''Configuration to be set. All parameters are
+ optional, and will retain their previous value if not
+ specified. Volume size is in GB.
+ ''',
+ "required": True,
+ "type": "ConfigurationRequestModel",
+ "paramType": "body"
+ }
+ ],
+ type=ConfigurationResponseModel.__name__
+ )
def post(self):
if not request.json:
abort(400, "ERROR: No data specified")
@@ -64,6 +106,9 @@ class Configure(Resource):
except Exception as e:
abort(400, str(e))
+ @swagger.operation(
+ notes='Deletes the agent configuration and the stack'
+ )
def delete(self):
try:
storperf.delete_stack()
@@ -81,8 +126,17 @@ class WorkloadModel:
}
+@swagger.model
+class WorkloadResponseModel:
+ resource_fields = {
+ 'job_id': fields.String
+ }
+
+
class Job(Resource):
+ """Job API"""
+
def __init__(self):
self.logger = logging.getLogger(__name__)
@@ -131,10 +185,11 @@ class Job(Resource):
"paramType": "body"
}
],
+ type=WorkloadResponseModel.__name__,
responseMessages=[
{
"code": 200,
- "message": "Wordload ID found, response in JSON format"
+ "message": "Job submitted"
},
{
"code": 400,
@@ -181,16 +236,31 @@ class Job(Resource):
)
def delete(self):
try:
- storperf.terminate_workloads()
- return True
+ return jsonify({'Slaves': storperf.terminate_workloads()})
except Exception as e:
abort(400, str(e))
+@swagger.model
+class QuotaModel:
+
+ resource_fields = {
+ 'quota': fields.Integer
+ }
+
+
class Quota(Resource):
+ """Quota API"""
+ @swagger.operation(
+ notes='''Fetch the current Cinder volume quota. This value limits
+ the number of volumes that can be created, and by extension, defines
+ the maximum number of agents that can be created for any given test
+ scenario''',
+ type=QuotaModel.__name__
+ )
def get(self):
- quota = storperf.get_volume_quota()
+ quota = storperf.volume_quota
return jsonify({'quota': quota})