ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-11428 Ambari Agent is not reporting the public_host_name properly on ec2 (dsen)
Date Wed, 27 May 2015 16:54:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d6882d341 -> f119a671f


AMBARI-11428 Ambari Agent is not reporting the public_host_name properly on ec2 (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f119a671
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f119a671
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f119a671

Branch: refs/heads/trunk
Commit: f119a671f9a6e93e53a5e26ab8dc0a4328debcd7
Parents: d6882d3
Author: Dmytro Sen <dsen@apache.org>
Authored: Wed May 27 19:53:15 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Wed May 27 19:53:41 2015 +0300

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/hostname.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f119a671/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 3c2fe72..9cb75d6 100644
--- a/ambari-agent/src/main/python/ambari_agent/hostname.py
+++ b/ambari-agent/src/main/python/ambari_agent/hostname.py
@@ -21,7 +21,6 @@ limitations under the License.
 import socket
 import subprocess
 import urllib2
-import AmbariConfig
 import logging
 import traceback
 
@@ -77,7 +76,15 @@ def public_hostname(config):
                 + " :out " + out + " :err " + err)
     logger.info("Defaulting to fqdn.")
 
-  cached_public_hostname = socket.getfqdn().lower()
+  try:
+    handle = urllib2.urlopen('http://169.254.169.254/latest/meta-data/public-hostname', '',
2)
+    str = handle.read()
+    handle.close()
+    cached_public_hostname = str.lower()
+    logger.info("Read public hostname '" + cached_public_hostname + "' from http://169.254.169.254/latest/meta-data/public-hostname")
+  except:
+    cached_public_hostname = socket.getfqdn().lower()
+    logger.info("Read public hostname '" + cached_public_hostname + "' using socket.getfqdn()")
   return cached_public_hostname
 
 def server_hostname(config):


Mime
View raw message