You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by fb...@apache.org on 2015/01/28 00:17:32 UTC

ambari git commit: AMBARI-9341 Failing to register hosts on Centos5

Repository: ambari
Updated Branches:
  refs/heads/trunk 4cbf3a876 -> f27c22b0c


AMBARI-9341 Failing to register hosts on Centos5

+Fixed the ambari_commons imports to only include the bare minimum required to function
+Fixed the incompartibilities with Python 2.4


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

Branch: refs/heads/trunk
Commit: f27c22b0c57c1b48ba372abb0c0fa6b74f6eda0e
Parents: 4cbf3a8
Author: Florian Barca <fb...@hortonworks.com>
Authored: Tue Jan 27 15:17:23 2015 -0800
Committer: Florian Barca <fb...@hortonworks.com>
Committed: Tue Jan 27 15:17:23 2015 -0800

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/HostInfo.py    | 22 +++++++++++---------
 .../test/python/ambari_agent/TestHostInfo.py    |  4 ++--
 .../python/ambari_agent/TestRegistration.py     |  2 +-
 .../src/main/python/ambari_commons/__init__.py  |  5 +----
 .../libraries/functions/packages_analyzer.py    |  4 ++--
 ambari-server/src/main/python/bootstrap.py      | 15 +++++++------
 ambari-server/src/main/python/setupAgent.py     | 10 +++------
 .../src/test/python/TestAmbariServer.py         |  3 ++-
 8 files changed, 30 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f27c22b0/ambari-agent/src/main/python/ambari_agent/HostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 7a1dbb7..2c707b2 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -18,23 +18,25 @@ See the License for the specific language governing permissions and
 limitations under the License.
 '''
 
-import os
 import glob
+import hostname
 import logging
+import os
 import re
-import time
-import subprocess
-import threading
 import shlex
-import platform
-import hostname
-from HostCheckReportFileHandler import HostCheckReportFileHandler
-from Hardware import Hardware
-from ambari_commons import OSCheck, OSConst, Firewall
-from resource_management.libraries.functions import packages_analyzer
 import socket
+import subprocess
+import time
+
+from ambari_commons import OSCheck, OSConst
+from ambari_commons.firewall import Firewall
 from ambari_commons.os_family_impl import OsFamilyImpl
 
+from resource_management.libraries.functions import packages_analyzer
+from ambari_agent.Hardware import Hardware
+from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler
+
+
 logger = logging.getLogger()
 
 # service cmd

http://git-wip-us.apache.org/repos/asf/ambari/blob/f27c22b0/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
index adeb798..c1b93d6 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
@@ -39,14 +39,14 @@ else:
   os_distro_value = ('win2012serverr2','6.3','WindowsServer')
 
 with patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value)):
+  from ambari_commons.firewall import Firewall
+  from ambari_commons.os_check import OSCheck, OSConst
   from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler
   from ambari_agent.HostInfo import HostInfo, HostInfoLinux
   from ambari_agent.Hardware import Hardware
   from ambari_agent.AmbariConfig import AmbariConfig
   from resource_management.core.system import System
-  from ambari_commons import OSCheck, Firewall, FirewallChecks, OSConst
   from resource_management.libraries.functions import packages_analyzer
-  import ambari_commons
 
 @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
 class TestHostInfo(TestCase):

http://git-wip-us.apache.org/repos/asf/ambari/blob/f27c22b0/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
index 92e4b36..b7a7f89 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
@@ -26,9 +26,9 @@ from mock.mock import MagicMock
 from only_for_platform import not_for_platform, PLATFORM_WINDOWS
 
 with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
+  from ambari_commons.os_check import OSCheck
   from ambari_agent.Register import Register
   from ambari_agent.AmbariConfig import AmbariConfig
-  from ambari_commons import OSCheck, Firewall, FirewallChecks
   from ambari_agent.Hardware import Hardware
 
 class TestRegistration(TestCase):

http://git-wip-us.apache.org/repos/asf/ambari/blob/f27c22b0/ambari-common/src/main/python/ambari_commons/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/ambari_commons/__init__.py b/ambari-common/src/main/python/ambari_commons/__init__.py
index df4d7d6..2ae36bf 100644
--- a/ambari-common/src/main/python/ambari_commons/__init__.py
+++ b/ambari-common/src/main/python/ambari_commons/__init__.py
@@ -19,11 +19,8 @@ limitations under the License.
 '''
 
 from ambari_commons.os_check import OSCheck, OSConst
-from ambari_commons.firewall import Firewall, FirewallChecks
 
 __all__ = [
   'OSCheck',
-  'OSConst',
-  'Firewall',
-  'FirewallChecks'
+  'OSConst'
 ]

http://git-wip-us.apache.org/repos/asf/ambari/blob/f27c22b0/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py b/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
index 402b421..888387c 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
@@ -20,11 +20,11 @@ limitations under the License.
 
 import sys
 import logging
-from ambari_commons import shell
 import subprocess
 from threading import Thread
 import threading
-from ambari_commons import OSCheck, OSConst, Firewall
+from ambari_commons import OSCheck, OSConst
+from ambari_commons import shell
 
 __all__ = ["installedPkgsByName", "allInstalledPackages", "allAvailablePackages", "nameMatch",
            "getInstalledRepos", "getInstalledPkgsByRepo", "getInstalledPkgsByNames", "getPackageDetails"]

http://git-wip-us.apache.org/repos/asf/ambari/blob/f27c22b0/ambari-server/src/main/python/bootstrap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/bootstrap.py b/ambari-server/src/main/python/bootstrap.py
index 8ac6a37..6afcaf2 100755
--- a/ambari-server/src/main/python/bootstrap.py
+++ b/ambari-server/src/main/python/bootstrap.py
@@ -18,8 +18,10 @@ See the License for the specific language governing permissions and
 limitations under the License.
 '''
 
-import socket
-from threading import Thread
+# On Linux, the bootstrap process is supposed to run on hosts that may have installed Python 2.4 and above (CentOS 5).
+# Hence, the whole bootstrap code needs to comply with Python 2.4 instead of Python 2.6. Most notably, @-decorators and
+# {}-format() are to be avoided.
+
 import time
 import sys
 import logging
@@ -29,7 +31,6 @@ import subprocess
 import threading
 import traceback
 import re
-from pprint import pformat
 from datetime import datetime
 
 AMBARI_PASSPHRASE_VAR_NAME = "AMBARI_PASSPHRASE"
@@ -40,7 +41,7 @@ MAX_PARALLEL_BOOTSTRAPS = 20
 POLL_INTERVAL_SEC = 1
 DEBUG = False
 DEFAULT_AGENT_TEMP_FOLDER = "/var/lib/ambari-agent/data/tmp"
-PYTHON_ENV="env PYTHONPATH=$PYTHONPATH:{0} ".format(DEFAULT_AGENT_TEMP_FOLDER)
+PYTHON_ENV="env PYTHONPATH=$PYTHONPATH:" + DEFAULT_AGENT_TEMP_FOLDER
 
 
 class HostLog:
@@ -332,8 +333,6 @@ class Bootstrap(threading.Thread):
       retcode2 = ssh.run()
       self.host_log.write("\n")
 
-
-
     self.host_log.write("==========================\n")
     self.host_log.write("Copying setup script file...")
     fileToCopy = params.setup_agent_file
@@ -397,9 +396,9 @@ class Bootstrap(threading.Thread):
     self.host_log.write("==========================\n")
     self.host_log.write("Running OS type check...")
 
-    command = "chmod a+x %s && %s %s" % \
+    command = "chmod a+x %s && %s %s %s" % \
               (self.getOsCheckScriptRemoteLocation(),
-               PYTHON_ENV + self.getOsCheckScriptRemoteLocation(), params.cluster_os_type)
+               PYTHON_ENV, self.getOsCheckScriptRemoteLocation(), params.cluster_os_type)
 
     ssh = SSH(params.user, params.sshkey_file, self.host, command,
               params.bootdir, self.host_log)

http://git-wip-us.apache.org/repos/asf/ambari/blob/f27c22b0/ambari-server/src/main/python/setupAgent.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/setupAgent.py b/ambari-server/src/main/python/setupAgent.py
index 8216c98..b2c2d25 100755
--- a/ambari-server/src/main/python/setupAgent.py
+++ b/ambari-server/src/main/python/setupAgent.py
@@ -22,15 +22,12 @@ import socket
 import time
 import sys
 import logging
-import pprint
 import os
 import subprocess
-import threading
-import traceback
-import stat
-from pprint import pformat
+
 from ambari_commons import OSCheck
 
+
 AMBARI_PASSPHRASE_VAR = "AMBARI_PASSPHRASE"
 
 
@@ -212,8 +209,7 @@ def parseArguments(argv=None):
 
 def run_setup(argv=None):
   # Parse passed arguments
-  expected_hostname, passPhrase, hostname,\
-  user_run_as, projectVersion, server_port = parseArguments(argv)
+  expected_hostname, passPhrase, hostname, user_run_as, projectVersion, server_port = parseArguments(argv)
   checkServerReachability(hostname, server_port)
   
   if projectVersion == "null" or projectVersion == "{ambariVersion}" or projectVersion == "":

http://git-wip-us.apache.org/repos/asf/ambari/blob/f27c22b0/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 8f13295..0e5a732 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -50,7 +50,8 @@ with patch("platform.linux_distribution", return_value = os_distro_value):
       with patch("glob.glob", return_value = ['/etc/init.d/postgresql-9.3']):
         _ambari_server_ = __import__('ambari-server')
 
-        from ambari_commons import Firewall, OSCheck, OSConst
+        from ambari_commons.firewall import Firewall
+        from ambari_commons.os_check import OSCheck, OSConst
         from ambari_commons.exceptions import FatalException, NonFatalException
         from ambari_commons.logging_utils import get_verbose, set_verbose, get_silent, set_silent, get_debug_mode, \
           print_info_msg, print_warning_msg, print_error_msg