@see: L{_ComputeIPolicySpecViolation}
"""
- res = _compute_fn(ipolicy, instance, instance.primary_node.group, node.group)
+ primary_node = lu.cfg.GetNodeInfo(instance.primary_node)
+ res = _compute_fn(ipolicy, instance, primary_node.group, node.group)
if res:
msg = ("Instance does not meet target node group's (%s) instance"
msg = "cannot reach the master IP"
_ErrorIf(True, constants.CV_ENODENET, node, msg)
- def _VerifyInstancePolicy(self, instance):
- """Verify instance specs against instance policy set on node group level.
-
-
- """
- cluster = self.cfg.GetClusterInfo()
- full_beparams = cluster.FillBE(instance)
- ipolicy = cluster.SimpleFillIPolicy(self.group_info.ipolicy)
-
- mem_size = full_beparams.get(constants.BE_MAXMEM, None)
- cpu_count = full_beparams.get(constants.BE_VCPUS, None)
- disk_count = len(instance.disks)
- disk_sizes = [disk.size for disk in instance.disks]
- nic_count = len(instance.nics)
-
- test_settings = [
- (constants.ISPEC_MEM_SIZE, mem_size),
- (constants.ISPEC_CPU_COUNT, cpu_count),
- (constants.ISPEC_DISK_COUNT, disk_count),
- (constants.ISPEC_NIC_COUNT, nic_count),
- ] + map((lambda d: (constants.ISPEC_DISK_SIZE, d)), disk_sizes)
-
- for (name, value) in test_settings:
- test_result = _CheckMinMaxSpecs(name, ipolicy, value)
- self._ErrorIf(test_result is not None,
- constants.CV_EINSTANCEPOLICY, instance.name,
- test_result)
-
def _VerifyInstance(self, instance, instanceconfig, node_image,
diskstatus):
"""Verify an instance.
node_vol_should = {}
instanceconfig.MapLVsByNode(node_vol_should)
- self._VerifyInstancePolicy(instanceconfig)
+ ipolicy = _CalculateGroupIPolicy(self.cfg.GetClusterInfo(), self.group_info)
+ err = _ComputeIPolicyInstanceViolation(ipolicy, instanceconfig)
+ _ErrorIf(err, constants.CV_EINSTANCEPOLICY, instance, err)
for node in node_vol_should:
n_img = node_image[node]
_CheckNodeOnline(self, instance.primary_node)
bep = self.cfg.GetClusterInfo().FillBE(instance)
+ bep.update(self.op.beparams)
# check bridges existence
_CheckInstanceBridgesExist(self, instance)
_CheckNodeOnline(self, target_node)
_CheckNodeNotDrained(self, target_node)
_CheckNodeVmCapable(self, target_node)
- ipolicy = _CalculateGroupIPolicy(self.cfg.GetClusterInfo(), node.group)
+ ipolicy = _CalculateGroupIPolicy(self.cfg.GetClusterInfo(),
+ self.cfg.GetNodeGroup(node.group))
_CheckTargetNodeIPolicy(self, ipolicy, instance, node,
ignore=self.op.ignore_ipolicy)
# Check that the target node is correct in terms of instance policy
nodeinfo = self.cfg.GetNodeInfo(self.target_node)
- ipolicy = _CalculateGroupIPolicy(cluster, nodeinfo.group)
+ group_info = self.cfg.GetNodeGroup(nodeinfo.group)
+ ipolicy = _CalculateGroupIPolicy(cluster, group_info)
_CheckTargetNodeIPolicy(self.lu, ipolicy, instance, nodeinfo,
ignore=self.ignore_ipolicy)
(instance.disk_template, text),
errors.ECODE_INVAL)
nodeinfo = self.cfg.GetNodeInfo(target_node)
- ipolicy = _CalculateGroupIPolicy(cluster, nodeinfo.group)
+ group_info = self.cfg.GetNodeGroup(nodeinfo.group)
+ ipolicy = _CalculateGroupIPolicy(cluster, group_info)
_CheckTargetNodeIPolicy(self.lu, ipolicy, instance, nodeinfo,
ignore=self.ignore_ipolicy)
_ReleaseLocks(self, locking.LEVEL_NODE,
keep=filter(None, [self.op.pnode, self.op.snode,
self.op.src_node]))
+ _ReleaseLocks(self, locking.LEVEL_NODE_RES,
+ keep=filter(None, [self.op.pnode, self.op.snode,
+ self.op.src_node]))
#### node related checks
constants.ISPEC_MEM_SIZE: self.be_full.get(constants.BE_MAXMEM, None),
constants.ISPEC_CPU_COUNT: self.be_full.get(constants.BE_VCPUS, None),
constants.ISPEC_DISK_COUNT: len(self.disks),
- constants.ISPEC_DISK_SIZE: [disk.size for disk in self.disks],
+ constants.ISPEC_DISK_SIZE: [disk["size"] for disk in self.disks],
constants.ISPEC_NIC_COUNT: len(self.nics),
}
- ipolicy = _CalculateGroupIPolicy(cluster, pnode.group)
+ group_info = self.cfg.GetNodeGroup(pnode.group)
+ ipolicy = _CalculateGroupIPolicy(cluster, group_info)
res = _ComputeIPolicyInstanceSpecViolation(ipolicy, ispec)
if not self.op.ignore_ipolicy and res:
raise errors.OpPrereqError(("Instance allocation to group %s violates"
# disk parameters (not customizable at instance or node level)
# just use the primary node parameters, ignoring the secondary.
- self.diskparams = self.cfg.GetNodeGroup(pnode.group).diskparams
+ self.diskparams = group_info.diskparams
if not self.adopt_disks:
# Check lv size requirements, if not adopting
_CheckNodesFreeDiskPerVG(self, [self.op.remote_node], required)
snode_info = self.cfg.GetNodeInfo(self.op.remote_node)
- ipolicy = _CalculateGroupIPolicy(cluster, snode_info.group)
+ snode_group = self.cfg.GetNodeGroup(snode_info.group)
+ ipolicy = _CalculateGroupIPolicy(cluster, snode_group)
_CheckTargetNodeIPolicy(self, ipolicy, instance, snode_info,
ignore=self.op.ignore_ipolicy)
if pnode_info.group != snode_info.group: