On 12/03/2014 05:12 PM, Klaus Aehlig wrote:
Here we probably need `if not ...instance....forthcoming: FAIL`
commit 58dabf47e898d269414b11f76172eaa12f03b554
Author: Klaus Aehlig <[email protected]>
Date: Wed Dec 3 17:03:35 2014 +0100
Interdiff [PATCH master 06/10] Support committing instances
diff --git a/lib/cmdlib/instance_create.py b/lib/cmdlib/instance_create.py
index b5e37ce..5b7d32e 100644
--- a/lib/cmdlib/instance_create.py
+++ b/lib/cmdlib/instance_create.py
@@ -349,8 +349,9 @@ class LUInstanceCreate(LogicalUnit):
self.op.instance_name = name
if not self.cfg.GetInstanceInfo(uuid).forthcoming:
raise errors.OpPrereqError("Instance %s (with uuid %s) not
forthcoming"
- % (name, uuid), errors.ECODE_STATE)
- logging.debug("Verified that instance %s with uuid %s if forthcoming",
+ " but --commit was passed." % (name, uuid),
+ errors.ECODE_STATE)
+ logging.debug("Verified that instance %s with uuid %s is forthcoming",
name, uuid)
else:
# this is just a preventive check, but someone might still add this
@@ -718,9 +719,18 @@ class LUInstanceCreate(LogicalUnit):
owned_nodes = frozenset(self.owned_locks(locking.LEVEL_NODE))
if self.op.commit:
- # Check that the instance is still on the cluster and
+ # Check that the instance is still on the cluster, forthcoming, and
# still resides on the nodes we acquired.
- (uuid, _) = self.cfg.ExpandInstanceName(self.op.instance_name)
+ (uuid, name) = self.cfg.ExpandInstanceName(self.op.instance_name)
+ if uuid is None:
+ raise errors.OpPrereqError("Instance %s disappeared from the cluster"
+ " while waiting for locks"
+ % (self.op.instance_name,),
+ errors.ECODE_STATE)
+ if not self.cfg.GetInstanceInfo(uuid).forthcoming:
+ raise errors.OpPrereqError("Instance %s (with uuid %s) is no longer"
+ " forthcoming" % (name, uuid),
+ errors.ECODE_STATE)
required_nodes = self.cfg.GetInstanceNodes(uuid)
if not owned_nodes.issuperset(required_nodes):
raise errors.OpPrereqError("Forthcoming instance %s nodes changed"
LGTM
--
Niklas Hambüchen
Google Germany GmbH, Dienerstr. 12, 80331 Muenchen
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschaeftsfuehrer: Graham Law, Christine Elizabeth Flores