You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by st...@apache.org on 2017/04/21 06:11:42 UTC
ambari git commit: AMBARI-20787. Ambari agent should log how it
determines it's FQDN. (stoader)
Repository: ambari
Updated Branches:
refs/heads/trunk 2075f52e3 -> ad4e11cc0
AMBARI-20787. Ambari agent should log how it determines it's FQDN. (stoader)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ad4e11cc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ad4e11cc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ad4e11cc
Branch: refs/heads/trunk
Commit: ad4e11cc0cdfe33bdb33008b4b7586e55b9cd715
Parents: 2075f52
Author: Toader, Sebastian <st...@hortonworks.com>
Authored: Fri Apr 21 08:11:31 2017 +0200
Committer: Toader, Sebastian <st...@hortonworks.com>
Committed: Fri Apr 21 08:11:31 2017 +0200
----------------------------------------------------------------------
ambari-agent/src/main/python/ambari_agent/Hardware.py | 2 ++
ambari-agent/src/main/python/ambari_agent/hostname.py | 8 ++++++++
2 files changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/ad4e11cc/ambari-agent/src/main/python/ambari_agent/Hardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Hardware.py b/ambari-agent/src/main/python/ambari_agent/Hardware.py
index 8cb8a28..696438e 100644
--- a/ambari-agent/src/main/python/ambari_agent/Hardware.py
+++ b/ambari-agent/src/main/python/ambari_agent/Hardware.py
@@ -45,11 +45,13 @@ class Hardware:
LINUX_PATH_SEP = "/"
def __init__(self, config):
+ logger.info("Initializing host system information.")
self.hardware = {
'mounts': Hardware.osdisks()
}
self.config = config
self.hardware.update(Facter(self.config).facterInfo())
+ logger.info("Host system information: %s", self.hardware)
@classmethod
def _parse_df_line(cls, line):
http://git-wip-us.apache.org/repos/asf/ambari/blob/ad4e11cc/ambari-agent/src/main/python/ambari_agent/hostname.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/hostname.py b/ambari-agent/src/main/python/ambari_agent/hostname.py
index 0f5f069..357c6b0 100644
--- a/ambari-agent/src/main/python/ambari_agent/hostname.py
+++ b/ambari-agent/src/main/python/ambari_agent/hostname.py
@@ -23,6 +23,7 @@ import subprocess
import urllib2
import logging
import traceback
+import sys
logger = logging.getLogger(__name__)
@@ -52,12 +53,19 @@ def hostname(config):
out, err = osStat.communicate()
if (0 == osStat.returncode and 0 != len(out.strip())):
cached_hostname = out.strip()
+ logger.info("Read hostname '{0}' using agent:hostname_script '{1}'".format(cached_hostname, scriptname))
else:
+ logger.warn("Execution of '{0}' failed with exit code {1}. err='{2}'\nout='{3}'".format(scriptname, osStat.returncode, err.strip(), out.strip()))
cached_hostname = socket.getfqdn()
+ logger.info("Read hostname '{0}' using socket.getfqdn() as '{1}' failed".format(cached_hostname, scriptname))
except:
cached_hostname = socket.getfqdn()
+ logger.warn("Unexpected error while retrieving hostname: '{0}', defaulting to socket.getfqdn()".format(sys.exc_info()))
+ logger.info("Read hostname '{0}' using socket.getfqdn().".format(cached_hostname))
except:
cached_hostname = socket.getfqdn()
+ logger.info("agent:hostname_script configuration not defined thus read hostname '{0}' using socket.getfqdn().".format(cached_hostname))
+
cached_hostname = cached_hostname.lower()
return cached_hostname