+ def _CheckIpolicy(self, cluster, owned_instance_names):
+ """Sanity checks for the ipolicy.
+
+ @type cluster: C{objects.Cluster}
+ @param cluster: the cluster's configuration
+ @type owned_instance_names: list of string
+ @param owned_instance_names: list of instances
+
+ """
+ if self.op.ipolicy:
+ self.new_ipolicy = GetUpdatedIPolicy(self.group.ipolicy,
+ self.op.ipolicy,
+ group_policy=True)
+
+ new_ipolicy = cluster.SimpleFillIPolicy(self.new_ipolicy)
+ CheckIpolicyVsDiskTemplates(new_ipolicy,
+ cluster.enabled_disk_templates)
+ instances = self.cfg.GetMultiInstanceInfoByName(owned_instance_names)
+ gmi = ganeti.masterd.instance
+ violations = \
+ ComputeNewInstanceViolations(gmi.CalculateGroupIPolicy(cluster,
+ self.group),
+ new_ipolicy, instances, self.cfg)
+
+ if violations:
+ self.LogWarning("After the ipolicy change the following instances"
+ " violate them: %s",
+ utils.CommaJoin(violations))
+