resync charmhelper
This commit is contained in:
parent
ef0038c70f
commit
f41649ff0f
@ -420,19 +420,19 @@ def get_hostname(address, fqdn=True):
|
|||||||
Resolves hostname for given IP, or returns the input
|
Resolves hostname for given IP, or returns the input
|
||||||
if it is already a hostname.
|
if it is already a hostname.
|
||||||
"""
|
"""
|
||||||
if not is_ip(address):
|
if is_ip(address):
|
||||||
return address
|
try:
|
||||||
|
import dns.reversename
|
||||||
|
except ImportError:
|
||||||
|
apt_install('python-dnspython')
|
||||||
|
import dns.reversename
|
||||||
|
|
||||||
try:
|
rev = dns.reversename.from_address(address)
|
||||||
import dns.reversename
|
result = ns_query(rev)
|
||||||
except ImportError:
|
if not result:
|
||||||
apt_install('python-dnspython')
|
return None
|
||||||
import dns.reversename
|
else:
|
||||||
|
result = address
|
||||||
rev = dns.reversename.from_address(address)
|
|
||||||
result = ns_query(rev)
|
|
||||||
if not result:
|
|
||||||
return None
|
|
||||||
|
|
||||||
if fqdn:
|
if fqdn:
|
||||||
# strip trailing .
|
# strip trailing .
|
||||||
|
Loading…
Reference in New Issue
Block a user