Add API to upload pod.yaml file
[yardstick.git] / api / base.py
index 7671527..6fa2777 100644 (file)
@@ -6,6 +6,7 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
+from __future__ import absolute_import
 import re
 import importlib
 import logging
@@ -22,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