From c9e5c0645d4a5525aa93fcbf0878011c67282632 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Wed, 30 Jul 2008 15:04:48 +0000 Subject: [PATCH] Parallelize LUFailoverInstance Reviewed-by: iustinp --- lib/cmdlib.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 37c45d066..dee811d35 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2580,6 +2580,16 @@ class LUFailoverInstance(LogicalUnit): HPATH = "instance-failover" HTYPE = constants.HTYPE_INSTANCE _OP_REQP = ["instance_name", "ignore_consistency"] + REQ_BGL = False + + def ExpandNames(self): + self._ExpandAndLockInstance() + self.needed_locks[locking.LEVEL_NODE] = [] + self.recalculate_locks[locking.LEVEL_NODE] = 'replace' + + def DeclareLocks(self, level): + if level == locking.LEVEL_NODE: + self._LockInstancesNodes() def BuildHooksEnv(self): """Build hooks env. @@ -2600,11 +2610,9 @@ class LUFailoverInstance(LogicalUnit): This checks that the instance is in the cluster. """ - instance = self.cfg.GetInstanceInfo( - self.cfg.ExpandInstanceName(self.op.instance_name)) - if instance is None: - raise errors.OpPrereqError("Instance '%s' not known" % - self.op.instance_name) + self.instance = instance = self.cfg.GetInstanceInfo(self.op.instance_name) + assert self.instance is not None, \ + "Cannot retrieve locked instance %s" % self.op.instance_name if instance.disk_template not in constants.DTS_NET_MIRROR: raise errors.OpPrereqError("Instance's disk layout is not" @@ -2627,8 +2635,6 @@ class LUFailoverInstance(LogicalUnit): " exist on destination node '%s'" % (brlist, target_node)) - self.instance = instance - def Exec(self, feedback_fn): """Failover an instance. -- GitLab