From 680806ce76ba39547f0f593f355b16b3aa704ae6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 17 Aug 2016 20:46:56 +0200 Subject: [PATCH] Fix getting host_name and host_fqdn. --- cdist/config.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index a873089d..31b41781 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -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)