From c04372b8630169a3fcc4b52e8d2b935f110519a6 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Thu, 22 Jun 2017 13:00:40 +0000 Subject: Add API to upload pod.yaml file JIRA: YARDSTICK-687 We need a API to upload a pod.yaml file to /etc/yardstick/pod.yaml. API: /yardstick/env/action method: POST param: { 'action': 'upload_pod_file', 'file': file object } Change-Id: I3d25df364da10aaf34f995e948e1704235a40f6f Signed-off-by: chenjiankun --- api/base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'api/base.py') diff --git a/api/base.py b/api/base.py index 527008588..6fa2777ce 100644 --- a/api/base.py +++ b/api/base.py @@ -23,9 +23,16 @@ logger.setLevel(logging.DEBUG) class ApiResource(Resource): def _post_args(self): - params = common_utils.translate_to_str(request.json) - action = params.get('action', '') + data = request.json if request.json else {} + params = common_utils.translate_to_str(data) + action = params.get('action', request.form.get('action', '')) args = params.get('args', {}) + + try: + args['file'] = request.files['file'] + except KeyError: + pass + logger.debug('Input args is: action: %s, args: %s', action, args) return action, args -- cgit 1.2.3-korg