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


Python ip.ns_query方法代码示例

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


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

示例1: test_get_host_ip_with_hostname_no_dns

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import ns_query [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

示例2: test_get_host_ip_with_hostname_fallback

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import ns_query [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

示例3: test_ns_query_trigger_apt_install

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import ns_query [as 别名]
def test_ns_query_trigger_apt_install(self, apt_install):
        fake_dns = FakeDNS('5.5.5.5')
        with patch(builtin_import, side_effect=[ImportError, fake_dns]):
            nsq = net_ip.ns_query('5.5.5.5')
            if six.PY2:
                apt_install.assert_called_with('python-dnspython', fatal=True)
            else:
                apt_install.assert_called_with('python3-dnspython', fatal=True)
        self.assertEquals(nsq, '5.5.5.5') 
开发者ID:juju,项目名称:charm-helpers,代码行数:11,代码来源:test_ip.py

示例4: test_ns_query_ptr_record

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

示例5: test_ns_query_a_record

# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import ns_query [as 别名]
def test_ns_query_a_record(self, apt_install):
        fake_dns = FakeDNS('127.0.0.1')
        fake_dns_name = FakeDNSName('www.somedomain.tld')
        with patch(builtin_import, side_effect=[fake_dns]):
            nsq = net_ip.ns_query(fake_dns_name)
        self.assertEquals(nsq, '127.0.0.1') 
开发者ID:juju,项目名称:charm-helpers,代码行数:8,代码来源:test_ip.py

示例6: test_ns_query_lookup_fail

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

示例7: test_get_hostname_lookup_fail

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

示例8: test_get_hostname_lookup_fail_gethostbyaddr_fallback

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


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