Commit 75248363 authored by Klaus Aehlig's avatar Klaus Aehlig Committed by Guido Trotter
Browse files

Make LUInstanceSetParams handle pnode parameter

If pnode is set LUInstanceSetParams now sets the primary node
accordingly. Unless force is set, it is verified that the instance
is no longer running on the old node.
Signed-off-by: default avatarKlaus Aehlig <>
Reviewed-by: default avatarGuido Trotter <>
parent d2204b1a
......@@ -13358,7 +13358,8 @@ class LUInstanceSetParams(LogicalUnit):
def CheckArguments(self):
if not (self.op.nics or self.op.disks or self.op.disk_template or
self.op.hvparams or self.op.beparams or self.op.os_name or
self.op.offline is not None or self.op.runtime_mem):
self.op.offline is not None or self.op.runtime_mem or
raise errors.OpPrereqError("No changes submitted", errors.ECODE_INVAL)
if self.op.hvparams:
......@@ -13386,6 +13387,9 @@ class LUInstanceSetParams(LogicalUnit):
self._CheckMods("NIC", self.op.nics, constants.INIC_PARAMS_TYPES,
if self.op.pnode:
self.op.pnode = _ExpandNodeName(self.cfg, self.op.pnode)
def ExpandNames(self):
self.needed_locks[locking.LEVEL_NODEGROUP] = []
......@@ -13668,6 +13672,21 @@ class LUInstanceSetParams(LogicalUnit):
"Cannot retrieve locked instance %s" % self.op.instance_name
pnode = instance.primary_node
self.warn = []
if (self.op.pnode is not None and self.op.pnode != pnode and
not self.op.force):
# verify that the instance is not up
instance_info = self.rpc.call_instance_info(pnode,,
if instance_info.fail_msg:
self.warn.append("Can't get instance runtime information: %s" %
elif instance_info.payload:
raise errors.OpPrereqError("Instance is still running on %s" % pnode,
assert pnode in self.owned_locks(locking.LEVEL_NODE)
nodelist = list(instance.all_nodes)
pnode_info = self.cfg.GetNodeInfo(pnode)
......@@ -13800,8 +13819,6 @@ class LUInstanceSetParams(LogicalUnit):
self.os_inst = {}
self.warn = []
#TODO(dynmem): do the appropriate check involving MINMEM
if (constants.BE_MAXMEM in self.op.beparams and not self.op.force and
be_new[constants.BE_MAXMEM] > be_old[constants.BE_MAXMEM]):
......@@ -14234,6 +14251,10 @@ class LUInstanceSetParams(LogicalUnit):
result = []
instance = self.instance
# New primary node
if self.op.pnode:
instance.primary_node = self.op.pnode
# runtime memory
if self.op.runtime_mem:
rpcres = self.rpc.call_instance_balloon_memory(instance.primary_node,
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