From 765c2c8ba8c3d88f4d00bd769516809c88e57674 Mon Sep 17 00:00:00 2001 From: Nagaraju Goruganti Date: Mon, 13 Nov 2017 06:17:13 -0600 Subject: Fix missing return value from do_post - For example user-initiated dump REST request has to respond with dump ID. This is not happening, the dump-manager is returning the ID, but rest-bus is not passing the ID to caller. - These changes will fix the issue. Fixes openbmc/openbmc#2592 Change-Id: I7ff3f24236249a4ca58ac6ce90cc9dec6fbe0341 Signed-off-by: Nagaraju Goruganti --- module/obmc/wsgi/apps/rest_dbus.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'module/obmc') diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py index 540322b..e0c2edf 100644 --- a/module/obmc/wsgi/apps/rest_dbus.py +++ b/module/obmc/wsgi/apps/rest_dbus.py @@ -335,7 +335,8 @@ class MethodHandler(RouteHandler): m = self.find_method_on_bus(path, method, *items) if m: method_list.append(m) - return method_list + if method_list: + return method_list abort(404, _4034_msg % ('method', 'found', method)) @@ -344,12 +345,29 @@ class MethodHandler(RouteHandler): def do_post(self, path, method): try: - for item in request.route_data['map']: - if request.parameter_list: - item(*request.parameter_list) - else: - item() - return + args = [] + if request.parameter_list: + args = request.parameter_list + # To see if the return type is capable of being merged + if len(request.route_data['map']) > 1: + results = None + for item in request.route_data['map']: + tmp = item(*args) + if not results: + if tmp is not None: + results = type(tmp)() + if isinstance(results, dict): + results = results.update(tmp) + elif isinstance(results, list): + results = results + tmp + elif isinstance(results, type(None)): + results = None + else: + abort(501, 'Don\'t know how to merge method call ' + 'results of {}'.format(type(tmp))) + return results + # There is only one method + return request.route_data['map'][0](*args) except dbus.exceptions.DBusException, e: paramlist = [] -- cgit v1.2.1