From 4e0b4d2dc121c08d033c46bb2a72a041b9357d59 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Wed, 30 Jul 2008 11:30:49 +0000 Subject: [PATCH] Parallelize LUReinstallInstance self.recalculate_locks[locking.LEVEL_NODE] could have any value and everything would work anyway. We'll use the string 'replace' by convention because in the future we might want an 'append' mode. Reviewed-by: iustinp --- lib/cmdlib.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 6789a35..7674950 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2191,6 +2191,16 @@ class LUReinstallInstance(LogicalUnit): HPATH = "instance-reinstall" HTYPE = constants.HTYPE_INSTANCE _OP_REQP = ["instance_name"] + 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. @@ -2209,11 +2219,10 @@ class LUReinstallInstance(LogicalUnit): This checks that the instance is in the cluster and is not running. """ - 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) + instance = self.cfg.GetInstanceInfo(self.op.instance_name) + assert instance is not None, \ + "Cannot retrieve locked instance %s" % self.op.instance_name + if instance.disk_template == constants.DT_DISKLESS: raise errors.OpPrereqError("Instance '%s' has no disks" % self.op.instance_name) -- 1.7.10.4