+ (data.cluster.highest_used_port, keys[-1]))
+
+ if not data.nodes[data.cluster.master_node].master_candidate:
+ result.append("Master node is not a master candidate")
+
+ # master candidate checks
+ mc_now, mc_max, _ = self._UnlockedGetMasterCandidateStats()
+ if mc_now < mc_max:
+ result.append("Not enough master candidates: actual %d, target %d" %
+ (mc_now, mc_max))
+
+ # node checks
+ for node_name, node in data.nodes.items():
+ if node.name != node_name:
+ result.append("Node '%s' is indexed by wrong name '%s'" %
+ (node.name, node_name))
+ if [node.master_candidate, node.drained, node.offline].count(True) > 1:
+ result.append("Node %s state is invalid: master_candidate=%s,"
+ " drain=%s, offline=%s" %
+ (node.name, node.master_candidate, node.drain,
+ node.offline))
+
+ # drbd minors check
+ _, duplicates = self._UnlockedComputeDRBDMap()
+ for node, minor, instance_a, instance_b in duplicates:
+ result.append("DRBD minor %d on node %s is assigned twice to instances"
+ " %s and %s" % (minor, node, instance_a, instance_b))
+
+ # IP checks
+ default_nicparams = data.cluster.nicparams[constants.PP_DEFAULT]
+ ips = {}
+
+ def _AddIpAddress(ip, name):
+ ips.setdefault(ip, []).append(name)
+
+ _AddIpAddress(data.cluster.master_ip, "cluster_ip")
+
+ for node in data.nodes.values():
+ _AddIpAddress(node.primary_ip, "node:%s/primary" % node.name)
+ if node.secondary_ip != node.primary_ip:
+ _AddIpAddress(node.secondary_ip, "node:%s/secondary" % node.name)
+
+ for instance in data.instances.values():
+ for idx, nic in enumerate(instance.nics):
+ if nic.ip is None:
+ continue
+
+ nicparams = objects.FillDict(default_nicparams, nic.nicparams)
+ nic_mode = nicparams[constants.NIC_MODE]
+ nic_link = nicparams[constants.NIC_LINK]
+
+ if nic_mode == constants.NIC_MODE_BRIDGED:
+ link = "bridge:%s" % nic_link
+ elif nic_mode == constants.NIC_MODE_ROUTED:
+ link = "route:%s" % nic_link
+ else:
+ raise errors.ProgrammerError("NIC mode '%s' not handled" % nic_mode)
+
+ _AddIpAddress("%s/%s" % (link, nic.ip),
+ "instance:%s/nic:%d" % (instance.name, idx))
+
+ for ip, owners in ips.items():
+ if len(owners) > 1:
+ result.append("IP address %s is used by multiple owners: %s" %
+ (ip, utils.CommaJoin(owners)))