From 3994f455c09324957dc3358885425fe8f7580ec0 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 4 May 2009 16:49:15 +0200 Subject: [PATCH] Fix argument checking in LUSetClusterParams This patch fixes two issues with LUSetClusterParams and argument checking. First, this LU used the wrong function name (CheckParameters instead of CheckArguments), which means that no parameter checking was done at all; this impacted the candidate_pool_size checks (the only one done at this stage). Second, int() can raise both ValueError and TypeError, and we should correctly handle both. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/cmdlib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 516483ee9..ab4044929 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1418,7 +1418,7 @@ class LUSetClusterParams(LogicalUnit): _OP_REQP = [] REQ_BGL = False - def CheckParameters(self): + def CheckArguments(self): """Check parameters """ @@ -1427,7 +1427,7 @@ class LUSetClusterParams(LogicalUnit): if self.op.candidate_pool_size is not None: try: self.op.candidate_pool_size = int(self.op.candidate_pool_size) - except ValueError, err: + except (ValueError, TypeError), err: raise errors.OpPrereqError("Invalid candidate_pool_size value: %s" % str(err)) if self.op.candidate_pool_size < 1: -- GitLab