Fix getting host_name and host_fqdn.
This commit is contained in:
parent
2fb551131e
commit
680806ce76
1 changed files with 10 additions and 2 deletions
|
@ -243,15 +243,23 @@ class Config(object):
|
||||||
# gethostbyaddr returns triple
|
# gethostbyaddr returns triple
|
||||||
# (hostname, aliaslist, ipaddrlist)
|
# (hostname, aliaslist, ipaddrlist)
|
||||||
host_name = socket.gethostbyaddr(ip_addr)[0]
|
host_name = socket.gethostbyaddr(ip_addr)[0]
|
||||||
|
log.debug("derived host_name for host \"{}\": {}".format(
|
||||||
|
host, host_name))
|
||||||
except socket.gaierror as e:
|
except socket.gaierror as e:
|
||||||
log.warn("{}".format(e))
|
log.warn("host_name: {}".format(e))
|
||||||
|
# in case of error provide empty value
|
||||||
|
host_name = ''
|
||||||
|
except socket.herror as e:
|
||||||
|
log.warn("host_name: {}".format(e))
|
||||||
# in case of error provide empty value
|
# in case of error provide empty value
|
||||||
host_name = ''
|
host_name = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
host_fqdn = socket.getfqdn(host)
|
host_fqdn = socket.getfqdn(host)
|
||||||
|
log.debug("derived host_fqdn for host \"{}\": {}".format(
|
||||||
|
host, host_fqdn))
|
||||||
except socket.herror as e:
|
except socket.herror as e:
|
||||||
log.warn("{}: {}".format(e[0], e[1]))
|
log.warn("host_fqdn: {}".format(e))
|
||||||
# in case of error provide empty value
|
# in case of error provide empty value
|
||||||
host_fqdn = ''
|
host_fqdn = ''
|
||||||
target_host = (host, host_name, host_fqdn)
|
target_host = (host, host_name, host_fqdn)
|
||||||
|
|
Loading…
Reference in a new issue