ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-19684. Agent registration fails as local OS is not compatible with primary OS family.(vbrodetskyi)
Date Tue, 24 Jan 2017 11:20:39 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 796f52a47 -> c6c35555e


AMBARI-19684. Agent registration fails as local OS is not compatible with primary OS family.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: c6c35555eb157f3cd80397db428d21441d3ec5e6
Parents: 796f52a
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Tue Jan 24 13:19:28 2017 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Tue Jan 24 13:19:28 2017 +0200

----------------------------------------------------------------------
 ambari-server/conf/unix/create-python-wrap.sh  | 40 +++++++++++++++++++++
 ambari-server/src/main/assemblies/server.xml   |  5 +++
 ambari-server/src/main/python/bootstrap.py     | 31 ++++++++++++++++
 ambari-server/src/main/python/os_check_type.py |  2 +-
 ambari-server/src/test/python/TestBootstrap.py |  4 +--
 5 files changed, 79 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c6c35555/ambari-server/conf/unix/create-python-wrap.sh
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/create-python-wrap.sh b/ambari-server/conf/unix/create-python-wrap.sh
new file mode 100644
index 0000000..3190073
--- /dev/null
+++ b/ambari-server/conf/unix/create-python-wrap.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+PYTHON_WRAPER_DIR="${ROOT}/usr/bin/"
+PYTHON_WRAPER_TARGET="${PYTHON_WRAPER_DIR}/ambari-python-wrap"
+
+# remove old python wrapper
+rm -f "$PYTHON_WRAPER_TARGET"
+
+AMBARI_PYTHON=""
+python_binaries=( "/usr/bin/python" "/usr/bin/python2" "/usr/bin/python2.7" "/usr/bin/python2.6"
)
+for python_binary in "${python_binaries[@]}"
+do
+  $python_binary -c "import sys ; ver = sys.version_info ; sys.exit(not (ver >= (2,6)
and ver<(3,0)))" 1>/dev/null 2>/dev/null
+
+  if [ $? -eq 0 ] ; then
+    AMBARI_PYTHON="$python_binary"
+    break;
+  fi
+done
+
+if [ -z "$AMBARI_PYTHON" ] ; then
+  >&2 echo "Cannot detect python for ambari to use. Please manually set $PYTHON_WRAPER
link to point to correct python binary"
+else
+  mkdir -p "$PYTHON_WRAPER_DIR"
+  ln -s "$AMBARI_PYTHON" "$PYTHON_WRAPER_TARGET"
+fi
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c6c35555/ambari-server/src/main/assemblies/server.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/assemblies/server.xml b/ambari-server/src/main/assemblies/server.xml
index 5055d46..d65232c 100644
--- a/ambari-server/src/main/assemblies/server.xml
+++ b/ambari-server/src/main/assemblies/server.xml
@@ -237,6 +237,11 @@
       <outputDirectory>/var/lib/ambari-server/</outputDirectory>
     </file>
     <file>
+      <fileMode>755</fileMode>
+      <source>conf/unix/create-python-wrap.sh</source>
+      <outputDirectory>/var/lib/ambari-server/</outputDirectory>
+    </file>
+    <file>
       <fileMode>700</fileMode>
       <source>conf/unix/install-helper.sh</source>
       <outputDirectory>/var/lib/ambari-server/</outputDirectory>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c6c35555/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 e576fc8..d836040 100755
--- a/ambari-server/src/main/python/bootstrap.py
+++ b/ambari-server/src/main/python/bootstrap.py
@@ -54,6 +54,8 @@ DEFAULT_AGENT_DATA_FOLDER = "/var/lib/ambari-agent/data"
 DEFAULT_AGENT_LIB_FOLDER = "/var/lib/ambari-agent"
 PYTHON_ENV="env PYTHONPATH=$PYTHONPATH:" + DEFAULT_AGENT_TEMP_FOLDER
 SERVER_AMBARI_SUDO = os.getenv('ROOT','/').rstrip('/') + "/var/lib/ambari-server/ambari-sudo.sh"
+CREATE_PYTHON_WRAP_SCRIPT = os.getenv('ROOT','/').rstrip('/') + "/var/lib/ambari-server/create-python-wrap.sh"
+REMOTE_CREATE_PYTHON_WRAP_SCRIPT = os.path.join(DEFAULT_AGENT_TEMP_FOLDER, 'create-python-wrap.sh')
 AMBARI_SUDO = os.path.join(DEFAULT_AGENT_TEMP_FOLDER, 'ambari-sudo.sh')
 
 class HostLog:
@@ -466,6 +468,19 @@ class BootstrapDefault(Bootstrap):
     self.host_log.write("\n")
     return result
 
+  def copyCreatePythonWrapScript(self):
+    # Copying the script which will create python wrap
+    fileToCopy = CREATE_PYTHON_WRAP_SCRIPT
+    target = self.TEMP_FOLDER
+    params = self.shared_state
+    self.host_log.write("==========================\n")
+    self.host_log.write("Copying create-python-wrap script...")
+    scp = SCP(params.user, params.sshPort, params.sshkey_file, self.host, fileToCopy,
+              target, params.bootdir, self.host_log)
+    result = scp.run()
+    self.host_log.write("\n")
+    return result
+
   def copyOsCheckScript(self):
     # Copying the os check script file
     fileToCopy = self.getOsCheckScript()
@@ -610,6 +625,20 @@ class BootstrapDefault(Bootstrap):
            " " + str(passphrase) + " " + str(server)+ " " + quote_bash_args(str(user_run_as))
+ " " + str(version) + \
            " " + str(port)
 
+  def runCreatePythonWrapScript(self):
+    params = self.shared_state
+    self.host_log.write("==========================\n")
+    self.host_log.write("Running create-python-wrap script...")
+
+    command = "chmod a+x %s && %s" % \
+              (REMOTE_CREATE_PYTHON_WRAP_SCRIPT, REMOTE_CREATE_PYTHON_WRAP_SCRIPT)
+
+    ssh = SSH(params.user, params.sshPort, params.sshkey_file, self.host, command,
+              params.bootdir, self.host_log)
+    retcode = ssh.run()
+    self.host_log.write("\n")
+    return retcode
+
   def runOsCheckScript(self):
     params = self.shared_state
     self.host_log.write("==========================\n")
@@ -725,7 +754,9 @@ class BootstrapDefault(Bootstrap):
     action_queue = [self.createTargetDir,
                     self.copyAmbariSudo,
                     self.copyCommonFunctions,
+                    self.copyCreatePythonWrapScript,
                     self.copyOsCheckScript,
+                    self.runCreatePythonWrapScript,
                     self.runOsCheckScript,
                     self.checkSudoPackage
     ]

http://git-wip-us.apache.org/repos/asf/ambari/blob/c6c35555/ambari-server/src/main/python/os_check_type.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/os_check_type.py b/ambari-server/src/main/python/os_check_type.py
index f890504..34de34b 100644
--- a/ambari-server/src/main/python/os_check_type.py
+++ b/ambari-server/src/main/python/os_check_type.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/ambari-python-wrap
 
 '''
 Licensed to the Apache Software Foundation (ASF) under one

http://git-wip-us.apache.org/repos/asf/ambari/blob/c6c35555/ambari-server/src/test/python/TestBootstrap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestBootstrap.py b/ambari-server/src/test/python/TestBootstrap.py
index 8356f91..bea47f4 100644
--- a/ambari-server/src/test/python/TestBootstrap.py
+++ b/ambari-server/src/test/python/TestBootstrap.py
@@ -747,7 +747,7 @@ class TestBootstrap(TestCase):
     hasPassword_mock.return_value = False
     try_to_execute_mock.return_value = {"exitstatus": 0, "log":"log0", "errormsg":"errormsg0"}
     bootstrap_obj.run()
-    self.assertEqual(try_to_execute_mock.call_count, 8) # <- Adjust if changed
+    self.assertEqual(try_to_execute_mock.call_count, 10) # <- Adjust if changed
     self.assertTrue(createDoneFile_mock.called)
     self.assertEqual(bootstrap_obj.getStatus()["return_code"], 0)
 
@@ -758,7 +758,7 @@ class TestBootstrap(TestCase):
     hasPassword_mock.return_value = True
     try_to_execute_mock.return_value = {"exitstatus": 0, "log":"log0", "errormsg":"errormsg0"}
     bootstrap_obj.run()
-    self.assertEqual(try_to_execute_mock.call_count, 11) # <- Adjust if changed
+    self.assertEqual(try_to_execute_mock.call_count, 13) # <- Adjust if changed
     self.assertTrue(createDoneFile_mock.called)
     self.assertEqual(bootstrap_obj.getStatus()["return_code"], 0)
 


Mime
View raw message