Hello Yaniv Bronhaim, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/29476
to review the following change.
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 254, in _dynamicMethod
raise InvalidCall(fn, methodArgs, e)
InvalidCall: Attempt to call function: <bound method
StoragePool.disconnect of <API.StoragePool object at 0x7f77046397d0>>
with arguments: (1, u'2440ff3d-275f-42e6-b204-7d055b26b174') error:
disconnect() takes exactly 4 arguments (3 given)
(Traceback lines wrapped for the commit message)
Change-Id: I9ec0a745ec65d3994e06a0b72ded9b7bbe55b1ae
Relates-to:
https://bugzilla.redhat.com/1115033
Relates-to:
https://bugzilla.redhat.com/1115044
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
Reviewed-on:
http://gerrit.ovirt.org/29457
Reviewed-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
Reviewed-by: Dan Kenigsberg <danken(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/76/29476/1
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index 7e898de..e6fcd9a 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, arguments, error):
+ self.function = function
+ self.arguments = arguments
+ self.error = error
+
+ def __str__(self):
+ return ("Attempt to call function: %s with arguments: %s error: %s" %
+ (self.function, self.arguments, 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/29476
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ec0a745ec65d3994e06a0b72ded9b7bbe55b1ae
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei(a)redhat.com>