本文整理汇总了Python中charmhelpers.contrib.network.ip.get_hostname方法的典型用法代码示例。如果您正苦于以下问题:Python ip.get_hostname方法的具体用法?Python ip.get_hostname怎么用?Python ip.get_hostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.contrib.network.ip
的用法示例。
在下文中一共展示了ip.get_hostname方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_hostname_with_ip
# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_hostname [as 别名]
def test_get_hostname_with_ip(self, apt_install):
fake_dns = FakeDNS('www.ubuntu.com')
with patch(builtin_import, side_effect=[fake_dns, fake_dns]):
hn = net_ip.get_hostname('4.2.2.1')
self.assertEquals(hn, 'www.ubuntu.com')
示例2: test_get_hostname_with_ip_not_fqdn
# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_hostname [as 别名]
def test_get_hostname_with_ip_not_fqdn(self, apt_install):
fake_dns = FakeDNS('packages.ubuntu.com')
with patch(builtin_import, side_effect=[fake_dns, fake_dns]):
hn = net_ip.get_hostname('4.2.2.1', fqdn=False)
self.assertEquals(hn, 'packages')
示例3: test_get_hostname_with_hostname
# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_hostname [as 别名]
def test_get_hostname_with_hostname(self, apt_install):
hn = net_ip.get_hostname('www.ubuntu.com')
self.assertEquals(hn, 'www.ubuntu.com')
示例4: test_get_hostname_with_hostname_trailingdot
# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_hostname [as 别名]
def test_get_hostname_with_hostname_trailingdot(self, apt_install):
hn = net_ip.get_hostname('www.ubuntu.com.')
self.assertEquals(hn, 'www.ubuntu.com')
示例5: test_get_hostname_with_hostname_not_fqdn
# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_hostname [as 别名]
def test_get_hostname_with_hostname_not_fqdn(self, apt_install):
hn = net_ip.get_hostname('packages.ubuntu.com', fqdn=False)
self.assertEquals(hn, 'packages')
示例6: test_get_hostname_lookup_fail
# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_hostname [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)
示例7: test_get_hostname_lookup_fail_gethostbyaddr_fallback
# 需要导入模块: from charmhelpers.contrib.network import ip [as 别名]
# 或者: from charmhelpers.contrib.network.ip import get_hostname [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")