Nir Soffer has uploaded a new change for review.
Change subject: bridge: Show more info when method call fail
......................................................................
bridge: Show more info when method call fail
When the bridge try to run a method dynamically and the number of
arguments does not match the function definition, we get an unhelpful
TypeError. Now a more specific and verbose error is raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/yajsonrpc/__init__.py", line 480,
in _serveRequest
res = method(**params)
File "/usr/share/vdsm/rpc/Bridge.py", line 252, in _dynamicMethod
raise InvalidCall(fn, methodArgs, e)
InvalidCall: Attempt to call function <bound method StoragePool.disconnect
of <API.StoragePool object at 0x7ff6405a9c50>> with arguments (1,
u'2440ff3d-275f-42e6-b204-7d055b26b174'): disconnect() takes exactly 4
arguments (3 given)
(Traceback lines wrapped for the commit message)
Change-Id: I9ec0a745ec65d3994e06a0b72ded9b7bbe55b1ae
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/rpc/Bridge.py
1 file changed, 16 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/29457/1
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index 7e898de..9d37e3b 100644
--- a/vdsm/rpc/Bridge.py
+++ b/vdsm/rpc/Bridge.py
@@ -36,6 +36,18 @@
self.message = message
+class InvalidCall(Exception):
+
+ def __init__(self, function, kwargs, error):
+ self.function = function
+ self.kwargs = kwargs
+ self.error = error
+
+ def __str__(self):
+ return ("Attempt to call function %s with arguments %s: %s" %
+ (self.function, self.kwargs, self.error))
+
+
class DynamicBridge(object):
def __init__(self):
self.api = vdsmapi.get_api()
@@ -236,7 +248,10 @@
result = fn(api, argobj)
else:
fn = getattr(api, methodName)
- result = fn(*methodArgs)
+ try:
+ result = fn(*methodArgs)
+ except TypeError as e:
+ raise InvalidCall(fn, methodArgs, e)
if result['status']['code']:
code = result['status']['code']
--
To view, visit
http://gerrit.ovirt.org/29457
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ec0a745ec65d3994e06a0b72ded9b7bbe55b1ae
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>