Amador Pahim has uploaded a new change for review.

Change subject: Validating number of required args in spmStart()
......................................................................

Validating number of required args in spmStart()

Bug-Url: http://bugzilla.redhat.com/868619

Currently vdsClient spmStart retunrs
"(Unexpected exception )" error when providing
less arguments than required. spmStart()
expects 7 arguments, with 5 of them being
required.
This patch changes validateArgTypes() to allow
number of required args specification instead
of requireAllArgs true or false, which was not
enough when not all arguments, but some
are required.

Change-Id: Iab0ddbd4b3f77fc2011e7b554a4800298a9cf39f
Signed-off-by: Amador Pahim <[email protected]>
---
M vdsm_cli/vdsClient.py
1 file changed, 5 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/8731/1

diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index c83dd7a..5e98931 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -60,10 +60,11 @@
 LEAF_VOL = 8
 
 
-def validateArgTypes(args, conv, requireAllArgs=False):
-    if len(args) > len(conv) or requireAllArgs and len(args) < len(conv):
+def validateArgTypes(args, conv, requiredArgsNumber=0):
+    if len(args) > len(conv) or len(args) < requiredArgsNumber:
         raise ValueError("Wrong number of arguments provided, "
-                         "expecting %d got %d" % (len(conv), len(args)))
+                         "expecting %d (%d required) got %d"
+                         % (len(conv), requiredArgsNumber, len(args)))
 
     for i in range(len(args)):
         args[i] = conv[i](args[i])
@@ -713,7 +714,7 @@
         return 0, ''
 
     def spmStart(self, args):
-        validateArgTypes(args, [str, int, int, int, str, int, int])
+        validateArgTypes(args, [str, int, int, int, str, int, int], 5)
         status = self.s.spmStart(*args)
         if status['status']['code']:
             return status['status']['code'], status['status']['message']


--
To view, visit http://gerrit.ovirt.org/8731
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab0ddbd4b3f77fc2011e7b554a4800298a9cf39f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Amador Pahim <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to