Standardize the ReST API 37/14437/1
authorMark Beierl <mark.beierl@emc.com>
Fri, 20 May 2016 13:30:46 +0000 (09:30 -0400)
committerMark Beierl <mark.beierl@emc.com>
Fri, 20 May 2016 13:30:46 +0000 (09:30 -0400)
Change-Id: I004824711abf17f06781302cf48a0b0e3d095ecb
Signed-off-by: Mark Beierl <mark.beierl@emc.com>
cli.py
rest_server.py
storperf/test_executor.py

diff --git a/cli.py b/cli.py
index 85ebcfd..fda05c2 100644 (file)
--- a/cli.py
+++ b/cli.py
@@ -17,12 +17,11 @@ import json
 import logging
 import logging.config
 import logging.handlers
+import requests
 import socket
 import struct
 import sys
 
-import requests
-
 
 class Usage(Exception):
     pass
@@ -132,7 +131,7 @@ def main(argv=None):
 
         if (erase):
             response = requests.delete(
-                'http://127.0.0.1:5000/api/v1.0/configure')
+                'http://127.0.0.1:5000/api/v1.0/configurations')
             if (response.status_code == 400):
                 content = json.loads(response.content)
                 raise Usage(content['message'])
@@ -140,7 +139,7 @@ def main(argv=None):
 
         if (terminate):
             response = requests.delete(
-                'http://127.0.0.1:5000/api/v1.0/job')
+                'http://127.0.0.1:5000/api/v1.0/jobs')
             if (response.status_code == 400):
                 content = json.loads(response.content)
                 raise Usage(content['message'])
@@ -148,7 +147,7 @@ def main(argv=None):
 
         if (configuration is not None):
             response = requests.post(
-                'http://127.0.0.1:5000/api/v1.0/configure', json=configuration)
+                'http://127.0.0.1:5000/api/v1.0/configurations', json=configuration)
             if (response.status_code == 400):
                 content = json.loads(response.content)
                 raise Usage(content['message'])
@@ -156,7 +155,7 @@ def main(argv=None):
         if (report is not None):
             print "Fetching report for %s..." % (report,)
             response = requests.get(
-                'http://127.0.0.1:5000/api/v1.0/job?id=%s' % (report,))
+                'http://127.0.0.1:5000/api/v1.0/jobs?id=%s' % (report,))
             if (response.status_code == 400):
                 content = json.loads(response.content)
                 raise Usage(content['message'])
@@ -165,7 +164,7 @@ def main(argv=None):
         else:
             print "Calling start..."
             response = requests.post(
-                'http://127.0.0.1:5000/api/v1.0/job', json=options)
+                'http://127.0.0.1:5000/api/v1.0/jobs', json=options)
             if (response.status_code == 400):
                 content = json.loads(response.content)
                 raise Usage(content['message'])
index 7578f41..390cb8c 100644 (file)
@@ -7,6 +7,9 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
+from storperf.db.job_db import JobDB
+from storperf.plot.barchart import Barchart
+from storperf.storperf_master import StorPerfMaster
 import io
 import json
 import logging
@@ -15,11 +18,7 @@ import os
 
 from flask import abort, Flask, request, jsonify, send_from_directory
 from flask_restful import Resource, Api, fields
-
 from flask_restful_swagger import swagger
-from storperf.db.job_db import JobDB
-from storperf.plot.barchart import Barchart
-from storperf.storperf_master import StorPerfMaster
 
 
 app = Flask(__name__, static_url_path="")
@@ -421,9 +420,9 @@ def setup_logging(default_path='storperf/logging.json',
     rootLogger.addHandler(socketHandler)
 
 
-api.add_resource(Configure, "/api/v1.0/configure")
-api.add_resource(Quota, "/api/v1.0/quota")
-api.add_resource(Job, "/api/v1.0/job")
+api.add_resource(Configure, "/api/v1.0/configurations")
+api.add_resource(Quota, "/api/v1.0/quotas")
+api.add_resource(Job, "/api/v1.0/jobs")
 
 if __name__ == "__main__":
     setup_logging()
index 592c33d..fc51adc 100644 (file)
@@ -92,6 +92,8 @@ class TestExecutor(object):
         self.metrics_emitter.transmit_metrics(carbon_metrics)
 
     def register_workloads(self, workloads):
+        self.workload_modules = []
+
         if (workloads is None or len(workloads) == 0):
             workload_dir = os.path.normpath(
                 os.path.join(os.path.dirname(__file__), "workloads"))