You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2014/05/30 15:09:40 UTC

git commit: AMBARI-5956. DB connection check error if jdk_name does not exist.(vbrodetskyi)

Repository: ambari
Updated Branches:
  refs/heads/trunk fa9903f80 -> b625ae435


AMBARI-5956. DB connection check error if jdk_name does not exist.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: b625ae435b00ef034ae339bdaf5751befa9ee83c
Parents: fa9903f
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Fri May 30 12:35:51 2014 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Fri May 30 12:35:51 2014 +0300

----------------------------------------------------------------------
 .../src/main/resources/custom_actions/check_host.py  | 12 ++++++++++--
 ambari-server/src/test/python/TestCheckHost.py       | 15 +++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b625ae43/ambari-server/src/main/resources/custom_actions/check_host.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/check_host.py b/ambari-server/src/main/resources/custom_actions/check_host.py
index 82ccd67..800b421 100644
--- a/ambari-server/src/main/resources/custom_actions/check_host.py
+++ b/ambari-server/src/main/resources/custom_actions/check_host.py
@@ -124,12 +124,20 @@ class CheckHost(Script):
     db_connection_url = config['commandParams']['db_connection_url']
     user_name = config['commandParams']['user_name']
     user_passwd = config['commandParams']['user_passwd']
-  
+    java_exec = os.path.join(java64_home, "bin","java")
+
+    if ('jdk_name' not in config['commandParams'] or config['commandParams']['jdk_name'] == None \
+        or config['commandParams']['jdk_name'] == '') and not os.path.isfile(java_exec):
+      message = "Custom java is not available on host. Please install it. Java home should be the same as on server. " \
+                "\n"
+      print message
+      db_connection_check_structured_output = {"exit_code" : "1", "message": message}
+      return db_connection_check_structured_output
+
     environment = { "no_proxy": format("{ambari_server_hostname}") }
     artifact_dir = "/tmp/HDP-artifacts/"
     jdk_name = config['commandParams']['jdk_name']
     jdk_curl_target = format("{artifact_dir}/{jdk_name}")
-    java_exec = os.path.join(java64_home, "bin","java")
     java_dir = os.path.dirname(java64_home)
 
     # download DBConnectionVerification.jar from ambari-server resources

http://git-wip-us.apache.org/repos/asf/ambari/blob/b625ae43/ambari-server/src/test/python/TestCheckHost.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestCheckHost.py b/ambari-server/src/test/python/TestCheckHost.py
index b77f071..3afff09 100644
--- a/ambari-server/src/test/python/TestCheckHost.py
+++ b/ambari-server/src/test/python/TestCheckHost.py
@@ -148,6 +148,21 @@ class TestCheckHost(TestCase):
     self.assertEquals(structured_out_mock.call_args[0][0], {'db_connection_check':
                                         {'message': 'DB connection check completed successfully!', 'exit_code': '0'}})
 
+    #test jdk_name and java home are not available
+    mock_config.return_value = {"commandParams" : {"check_execute_list" : "db_connection_check",
+                                                   "java_home" : "test_java_home",
+                                                   "ambari_server_host" : "test_host",
+                                                   "jdk_location" : "test_jdk_location",
+                                                   "db_connection_url" : "test_db_connection_url",
+                                                   "user_name" : "test_user_name",
+                                                   "user_passwd" : "test_user_passwd",
+                                                   "db_name" : "postgresql"}}
+
+    isfile_mock.return_value = False
+    checkHost.actionexecute(None)
+    self.assertEquals(structured_out_mock.call_args[0][0], {'db_connection_check': {'message': 'Custom java is not ' \
+            'available on host. Please install it. Java home should be the same as on server. \n', 'exit_code': '1'}})
+
 
 
   @patch("socket.gethostbyname")