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 <ngorugan@in.ibm.com>
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 @@
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 @@
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 = []