Fix getting host_name and host_fqdn.

remotes/origin/4.3
Darko Poljak 8 years ago
parent 2fb551131e
commit 680806ce76
  1. 12
      cdist/config.py

12
cdist/config.py vendored

@ -243,15 +243,23 @@ class Config(object):
# gethostbyaddr returns triple
# (hostname, aliaslist, ipaddrlist)
host_name = socket.gethostbyaddr(ip_addr)[0]
log.debug("derived host_name for host \"{}\": {}".format(
host, host_name))
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
host_name = ''
try:
host_fqdn = socket.getfqdn(host)
log.debug("derived host_fqdn for host \"{}\": {}".format(
host, host_fqdn))
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
host_fqdn = ''
target_host = (host, host_name, host_fqdn)

Loading…
Cancel
Save