当前位置: 首页>>代码示例>>Python>>正文


Python ip.get_host_ip方法代码示例

本文整理汇总了Python中charmhelpers.contrib.network.ip.get_host_ip方法的典型用法代码示例。如果您正苦于以下问题:Python ip.get_host_ip方法的具体用法?Python ip.get_host_ip怎么用?Python ip.get_host_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在charmhelpers.contrib.network.ip的用法示例。


在下文中一共展示了ip.get_host_ip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: normalize_address

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_host_ip [as 别名]
def normalize_address(self, hostname):
        """Ensure that address returned is an IP address (i.e. not fqdn)"""
        if config_get('prefer-ipv6'):
            # TODO: add support for ipv6 dns
            return hostname

        if hostname != unit_get('private-address'):
            return get_host_ip(hostname, fallback=hostname)

        # Otherwise assume localhost
        return '127.0.0.1' 
开发者ID:openstack,项目名称:charm-percona-cluster,代码行数:13,代码来源:mysql.py

示例2: test_get_host_ip_with_hostname

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_host_ip [as 别名]
def test_get_host_ip_with_hostname(self, apt_install):
        fake_dns = FakeDNS('10.0.0.1')
        with patch(builtin_import, side_effect=[fake_dns]):
            ip = net_ip.get_host_ip('www.ubuntu.com')
        self.assertEquals(ip, '10.0.0.1') 
开发者ID:juju,项目名称:charm-helpers,代码行数:7,代码来源:test_ip.py

示例3: test_get_host_ip_with_hostname_no_dns

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_host_ip [as 别名]
def test_get_host_ip_with_hostname_no_dns(self, apt_install, socket,
                                              ns_query):
        ns_query.return_value = []
        fake_dns = FakeDNS(None)
        socket.return_value = '10.0.0.1'
        with patch(builtin_import, side_effect=[fake_dns]):
            ip = net_ip.get_host_ip('www.ubuntu.com')
        self.assertEquals(ip, '10.0.0.1') 
开发者ID:juju,项目名称:charm-helpers,代码行数:10,代码来源:test_ip.py

示例4: test_get_host_ip_with_hostname_fallback

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_host_ip [as 别名]
def test_get_host_ip_with_hostname_fallback(self, apt_install, socket,
                                                ns_query, *args):
        ns_query.return_value = []
        fake_dns = FakeDNS(None)

        def r():
            raise Exception()

        socket.side_effect = r
        with patch(builtin_import, side_effect=[fake_dns]):
            ip = net_ip.get_host_ip('www.ubuntu.com', fallback='127.0.0.1')
        self.assertEquals(ip, '127.0.0.1') 
开发者ID:juju,项目名称:charm-helpers,代码行数:14,代码来源:test_ip.py

示例5: test_get_host_ip_with_ip

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_host_ip [as 别名]
def test_get_host_ip_with_ip(self, apt_install):
        fake_dns = FakeDNS('5.5.5.5')
        with patch(builtin_import, side_effect=[fake_dns]):
            ip = net_ip.get_host_ip('4.2.2.1')
        self.assertEquals(ip, '4.2.2.1') 
开发者ID:juju,项目名称:charm-helpers,代码行数:7,代码来源:test_ip.py


注:本文中的charmhelpers.contrib.network.ip.get_host_ip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。