Fix infinite do_put recursive call with retry only once

For failure in do-put method call REST server computes
the argument types based on the signature and makes a
recursive call with the modified argument types.

Without proper exit clause recursive call is falling into an
infinite loop, modified to retry only once.

Also fixed do_post which has similar retry logic.

Fixes openbmc/openbmc#2653

Change-Id: I150464de5585ebdfab4ae2da2083a62bd63caca1
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py
index e0c2edf..b47ea4e 100644
--- a/module/obmc/wsgi/apps/rest_dbus.py
+++ b/module/obmc/wsgi/apps/rest_dbus.py
@@ -343,7 +343,7 @@
     def setup(self, path, method):
         request.route_data['map'] = self.find(path, method)
 
-    def do_post(self, path, method):
+    def do_post(self, path, method, retry=True):
         try:
             args = []
             if request.parameter_list:
@@ -371,7 +371,7 @@
 
         except dbus.exceptions.DBusException, e:
             paramlist = []
-            if e.get_dbus_name() == DBUS_INVALID_ARGS:
+            if e.get_dbus_name() == DBUS_INVALID_ARGS and retry == True:
 
                 signature_list = get_method_signature(self.bus, self.service,
                                                       path, self.interface,
@@ -387,7 +387,7 @@
                         converted_value = convert_type(expected_type, value)
                         paramlist.append(converted_value)
                     request.parameter_list = paramlist
-                    self.do_post(path, method)
+                    self.do_post(path, method, False)
                     return
                 except Exception as ex:
                     abort(400, "Failed to convert the types")
@@ -454,7 +454,7 @@
         name = request.route_data['name']
         return request.route_data['obj'][path][name]
 
-    def do_put(self, path, prop, value=None):
+    def do_put(self, path, prop, value=None, retry=True):
         if value is None:
             value = request.parameter_list
 
@@ -465,7 +465,7 @@
         except ValueError, e:
             abort(400, str(e))
         except dbus.exceptions.DBusException, e:
-            if e.get_dbus_name() == DBUS_INVALID_ARGS:
+            if e.get_dbus_name() == DBUS_INVALID_ARGS and retry == True:
                 bus_name = properties_iface.bus_name
                 expected_type = get_type_signature_by_introspection(self.bus,
                                                                     bus_name,
@@ -476,7 +476,7 @@
                 converted_value = None
                 try:
                     converted_value = convert_type(expected_type, value)
-                    self.do_put(path, prop, converted_value)
+                    self.do_put(path, prop, converted_value, False)
                     return
                 except Exception as ex:
                     abort(403, "Failed to convert %s to type %s" %