Add check for node memory in instance creation
authorIustin Pop <iustin@google.com>
Sat, 31 May 2008 21:59:47 +0000 (21:59 +0000)
committerIustin Pop <iustin@google.com>
Sat, 31 May 2008 21:59:47 +0000 (21:59 +0000)
Currently the check for enough memory is done only on instance start
command and failover command. But we also start an instance in instance
create, therefore we need to check this instead of failing to start in
the hypervisor phase.

The patch adds a check for node memory in the case the creation command
specifies that the instance should be started. It is allowed for the
memory to be less than needed if the instance will not be started, in
order to allow migration and other such cases.

Reviewed-by: imsnah

lib/cmdlib.py

index e2ba9c6..42b0591 100644 (file)
@@ -3426,6 +3426,12 @@ class LUCreateInstance(LogicalUnit):
                                  " destination node '%s'" %
                                  (self.op.bridge, pnode.name))
 
+    # memory check on primary node
+    if self.op.start:
+      _CheckNodeFreeMemory(self.cfg, self.pnode.name,
+                           "creating instance %s" % self.op.instance_name,
+                           self.op.mem_size)
+
     # hvm_cdrom_image_path verification
     if self.op.hvm_cdrom_image_path is not None:
       if not os.path.isabs(self.op.hvm_cdrom_image_path):