From 52ecc06385e7db08d49b27d6ece485e34cafb2f7 Mon Sep 17 00:00:00 2001 From: Bernardo Dal Seno <bdalseno@google.com> Date: Wed, 19 Sep 2012 18:51:38 +0200 Subject: [PATCH] Support for the default iallocator in replace-disks "gnt-instance replace-disks" now behaves like the other commands, and uses the default iallocator when "." is passed as the iallocator parameter. Signed-off-by: Bernardo Dal Seno <bdalseno@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/cmdlib.py | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index c1eff0223..aca93a700 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -10649,8 +10649,24 @@ class LUInstanceReplaceDisks(LogicalUnit): REQ_BGL = False def CheckArguments(self): - TLReplaceDisks.CheckArguments(self.op.mode, self.op.remote_node, - self.op.iallocator) + """Check arguments. + + """ + remote_node = self.op.remote_node + ialloc = self.op.iallocator + if self.op.mode == constants.REPLACE_DISK_CHG: + if remote_node is None and ialloc is None: + raise errors.OpPrereqError("When changing the secondary either an" + " iallocator script must be used or the" + " new node given", errors.ECODE_INVAL) + else: + _CheckIAllocatorOrNode(self, "iallocator", "remote_node") + + elif remote_node is not None or ialloc is not None: + # Not replacing the secondary + raise errors.OpPrereqError("The iallocator and new node options can" + " only be used when changing the" + " secondary node", errors.ECODE_INVAL) def ExpandNames(self): self._ExpandAndLockInstance() @@ -10791,28 +10807,6 @@ class TLReplaceDisks(Tasklet): self.remote_node_info = None self.node_secondary_ip = None - @staticmethod - def CheckArguments(mode, remote_node, ialloc): - """Helper function for users of this class. - - """ - # check for valid parameter combination - if mode == constants.REPLACE_DISK_CHG: - if remote_node is None and ialloc is None: - raise errors.OpPrereqError("When changing the secondary either an" - " iallocator script must be used or the" - " new node given", errors.ECODE_INVAL) - - if remote_node is not None and ialloc is not None: - raise errors.OpPrereqError("Give either the iallocator or the new" - " secondary, not both", errors.ECODE_INVAL) - - elif remote_node is not None or ialloc is not None: - # Not replacing the secondary - raise errors.OpPrereqError("The iallocator and new node options can" - " only be used when changing the" - " secondary node", errors.ECODE_INVAL) - @staticmethod def _RunAllocator(lu, iallocator_name, instance_name, relocate_from): """Compute a new secondary node using an IAllocator. -- GitLab