diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 2fecf32417788e90466b3635938e7d4c4b0fb359..ca7ff6816e66b205526b9ff407205d385b936d26 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -3354,6 +3354,10 @@ class LUConnectConsole(NoHooksLU): """ _OP_REQP = ["instance_name"] + REQ_BGL = False + + def ExpandNames(self): + self._ExpandAndLockInstance() def CheckPrereq(self): """Check prerequisites. @@ -3361,12 +3365,9 @@ class LUConnectConsole(NoHooksLU): 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.instance = self.cfg.GetInstanceInfo(self.op.instance_name) + assert self.instance is not None, \ + "Cannot retrieve locked instance %s" % self.op.instance_name def Exec(self, feedback_fn): """Connect to the console of an instance