[Kimchi-devel] [PATCH][WOK] Add validation and fix parameters in _generate_action_handler_base

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Wed Dec 9 21:23:26 UTC 2015


The function _generate_action_handler_base is used in
asynchronous tasks like clone and migration. It usually
handles POST requests, which may contain parameters.

Handler was not able to differentiate the parameters, so
user was forced to pass all and in the right position,
also, parameters where not checked against API.json.

This patch do the following changes to fix the issues:
- handle parameters, and if not passed, sends None
- check parameters against API.json (adds validate_params)

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/wok/control/base.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/wok/control/base.py b/src/wok/control/base.py
index f739eae..e1591b5 100644
--- a/src/wok/control/base.py
+++ b/src/wok/control/base.py
@@ -107,11 +107,12 @@ class Resource(object):
                     raise UnauthorizedError('WOKAPI0009E')
 
                 model_args = list(self.model_args)
+                request = parse_request()
+                validate_params(request, self, action_name)
                 if action_args is not None:
-                    request = parse_request()
                     model_args.extend(
-                        request[key] for key in action_args
-                        if key in request.keys()
+                        request[key] if key in request.keys() else None
+                        for key in action_args
                     )
 
                 action_fn = getattr(self.model, model_fn(self, action_name))
-- 
2.1.0




More information about the Kimchi-devel mailing list