def _validate_reverse_dns()

in gridengine/src/gridengine/driver.py [0:0]


    def _validate_reverse_dns(self, node: Node) -> bool:
        # let's make sure the hostname is valid and reverse
        # dns compatible before adding to GE
        try:
            addr_info = socket.gethostbyaddr(node.private_ip)
        except Exception as e:
            logging.error(
                "Could not convert private_ip(%s) to hostname using gethostbyaddr() for %s: %s",
                node.private_ip,
                node,
                str(e),
            )
            return False

        addr_info_ips = addr_info[-1]
        if isinstance(addr_info_ips, str):
            addr_info_ips = [addr_info_ips]

        if node.private_ip not in addr_info_ips:
            logging.warning(
                "%s has a hostname that does not match the"
                + " private_ip (%s) reported by cyclecloud (%s)! Skipping",
                node,
                addr_info_ips,
                node.private_ip,
            )
            return False

        # when cluster has a custom prefix enabled, that is appended to node.hostname
        # in the cluster api, whereas by default it is left off. So, let's just do a full
        # comparison here to cover that case, the suffixless case is handled below.
        if addr_info[0].lower() == node.hostname.lower():
            return True

        addr_info_hostname = addr_info[0].split(".")[0]
        node_hostname = node.hostname.split(".")[0]

        if addr_info_hostname.lower() != node_hostname.lower():
            logging.warning(
                "%s has a hostname that can not be queried via reverse"
                + " dns (private_ip=%s cyclecloud hostname=%s reverse dns hostname=%s)."
                + " This is common and usually repairs itself. Skipping",
                node,
                node.private_ip,
                node.hostname,
                addr_info[0],
            )
            return False
        return True