You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2015/03/26 18:05:17 UTC
ambari git commit: Ambari-7765. HostInfo.fqdn could be wrong due to
Python Issue5004 (Chuan Liu)
Repository: ambari
Updated Branches:
refs/heads/trunk 465c20ec2 -> cc69a00c3
Ambari-7765. HostInfo.fqdn could be wrong due to Python Issue5004 (Chuan Liu)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cc69a00c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cc69a00c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cc69a00c
Branch: refs/heads/trunk
Commit: cc69a00c33586b47355d23b2491d2a5a8e5b1d92
Parents: 465c20e
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Thu Mar 26 10:05:03 2015 -0700
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Thu Mar 26 10:05:09 2015 -0700
----------------------------------------------------------------------
.../src/main/python/ambari_agent/Facter.py | 25 ++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/cc69a00c/ambari-agent/src/main/python/ambari_agent/Facter.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Facter.py b/ambari-agent/src/main/python/ambari_agent/Facter.py
index 7497772..94a0ab1 100644
--- a/ambari-agent/src/main/python/ambari_agent/Facter.py
+++ b/ambari-agent/src/main/python/ambari_agent/Facter.py
@@ -64,10 +64,6 @@ class Facter(object):
def getKernel(self):
return platform.system()
- # Returns the FQDN of the host
- def getFqdn(self):
- return socket.getfqdn().lower()
-
# Returns the host's primary DNS domain name
def getDomain(self):
fqdn = self.getFqdn()
@@ -193,6 +189,10 @@ class FacterWindows(Facter):
GET_UPTIME_CMD = 'echo $([int]((get-date)-[system.management.managementdatetimeconverter]::todatetime((get-wmiobject -class win32_operatingsystem).Lastbootuptime)).TotalSeconds)'
+ # Returns the FQDN of the host
+ def getFqdn(self):
+ return socket.getfqdn().lower()
+
# Return netmask
def getNetmask(self):
#TODO return correct netmask
@@ -289,6 +289,9 @@ class FacterLinux(Facter):
GET_UPTIME_CMD = "cat /proc/uptime"
GET_MEMINFO_CMD = "cat /proc/meminfo"
+ # hostname command
+ GET_HOSTNAME_CMD = "/bin/hostname -f"
+
def __init__(self):
self.DATA_IFCONFIG_OUTPUT = FacterLinux.setDataIfConfigOutput()
@@ -325,6 +328,20 @@ class FacterLinux(Facter):
log.warn("Can't execute {0}".format(FacterLinux.GET_MEMINFO_CMD))
return ""
+ # Returns the FQDN of the host
+ def getFqdn(self):
+ # Try to use OS command to get hostname first due to Python Issue5004
+ try:
+ retcode, out, err = run_os_command(self.GET_HOSTNAME_CMD)
+ if (0 == retcode and 0 != len(out.strip())):
+ return out.strip()
+ else:
+ log.warn("Could not get fqdn using {0}".format(self.GET_HOSTNAME_CMD))
+ except OSError:
+ log.warn("Could not run {0} for fqdn".format(self.GET_HOSTNAME_CMD))
+ return socket.getfqdn().lower()
+
+
def isSeLinux(self):
try: