Commit 49ce1563 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add check for node memory in instance creation

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
parent 8a12ce45
...@@ -3486,6 +3486,12 @@ class LUCreateInstance(LogicalUnit): ...@@ -3486,6 +3486,12 @@ class LUCreateInstance(LogicalUnit):
" destination node '%s'" % " destination node '%s'" %
(self.op.bridge, pnode.name)) (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 # hvm_cdrom_image_path verification
if self.op.hvm_cdrom_image_path is not None: if self.op.hvm_cdrom_image_path is not None:
if not os.path.isabs(self.op.hvm_cdrom_image_path): if not os.path.isabs(self.op.hvm_cdrom_image_path):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment