diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 08eddd14dc4a491e6e78dc3620450b7fbd6c3fea..15c1e1478bc436fa055813e6e8c67c897a9377f6 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -514,8 +514,6 @@ class LUInitCluster(LogicalUnit): " range (%s). Please fix DNS or %s." % (hostname.ip, constants.ETC_HOSTS)) - self.clustername = clustername = utils.HostInfo(self.op.cluster_name) - if not utils.TcpPing(hostname.ip, constants.DEFAULT_NODED_PORT, source=constants.LOCALHOST_IP_ADDRESS): raise errors.OpPrereqError("Inconsistency: this host's name resolves" @@ -523,6 +521,12 @@ class LUInitCluster(LogicalUnit): " belong to this host." " Aborting." % hostname.ip) + self.clustername = clustername = utils.HostInfo(self.op.cluster_name) + + if utils.TcpPing(clustername.ip, constants.DEFAULT_NODED_PORT, + timeout=5): + raise errors.OpPrereqError("Cluster IP already active. Aborting.") + secondary_ip = getattr(self.op, "secondary_ip", None) if secondary_ip and not utils.IsValidIP(secondary_ip): raise errors.OpPrereqError("Invalid secondary ip given")