ForemanAPIClient.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:check_katello_sync 作者: stdevel 项目源码 文件源码
def validate_hostname(hostname):
        """
        Validates that the Foreman API uses a FQDN as hostname.
        Also looks up the "real" hostname if "localhost" is specified.
        Otherwise, the picky Foreman API won't connect.

        :param hostname: the hostname to validate
        :type hostname: str
        """
        if hostname == "localhost":
            #get real hostname
            hostname = socket.gethostname()
        else:
            #convert to FQDN if possible:
            fqdn = socket.gethostbyaddr(hostname)
            if "." in fqdn[0]:
                hostname = fqdn[0]
        return hostname
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号