summaryrefslogtreecommitdiffstats
path: root/api/views.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2016-11-17 08:01:14 +0000
committerchenjiankun <chenjiankun1@huawei.com>2016-11-21 08:59:40 +0000
commit0e23c697e6329a57ba168cc57886b436ea87cdc4 (patch)
tree9344c63ed5296375dda7b0f0f2a3d85c06d7048e /api/views.py
parenteeeca4f0cdeff152ec061bb9b40ae305547c027e (diff)
Create API to run test cases
JIRA: YARDSTICK-413 Change-Id: Ibf58b50b568fae3f2eea985b25ee33be0a3666b7 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/views.py')
-rw-r--r--api/views.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/api/views.py b/api/views.py
new file mode 100644
index 000000000..883091222
--- /dev/null
+++ b/api/views.py
@@ -0,0 +1,29 @@
+import json
+import logging
+
+from flask import request
+from flask_restful import Resource
+
+from api.utils import common as common_utils
+from api.actions import test as test_action
+from api import conf
+
+logger = logging.getLogger(__name__)
+
+
+class Test(Resource):
+ def post(self):
+ action = common_utils.translate_to_str(request.json.get('action', ''))
+ args = common_utils.translate_to_str(request.json.get('args', {}))
+ logger.debug('Input args is: action: %s, args: %s', action, args)
+
+ if action not in conf.TEST_ACTION:
+ logger.error('Wrong action')
+ result = {
+ 'status': 'error',
+ 'message': 'wrong action'
+ }
+ return json.dumps(result)
+
+ method = getattr(test_action, action)
+ return method(args)