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 2016/09/15 14:28:13 UTC

ambari git commit: AMBARI-17889. Bad error message if user has not performed ambari-server setup for jdbc driver before configuring custom DB.(vbrodetskyi)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 3bf3bc593 -> e3a0cc5f7


AMBARI-17889. Bad error message if user has not performed ambari-server setup for jdbc driver before configuring custom DB.(vbrodetskyi)


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

Branch: refs/heads/branch-2.5
Commit: e3a0cc5f762657c5640724fb19be9a0414db4490
Parents: 3bf3bc5
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Thu Sep 15 17:27:46 2016 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Thu Sep 15 17:27:46 2016 +0300

----------------------------------------------------------------------
 .../custom_actions/scripts/check_host.py        | 53 ++++++++++++++------
 1 file changed, 37 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e3a0cc5f/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/check_host.py b/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
index 3d9dfa8..4077610 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
@@ -279,33 +279,54 @@ class CheckHost(Script):
     jdk_location = config['commandParams']['jdk_location']
     java_home = config['commandParams']['java_home']
     db_name = config['commandParams']['db_name']
+    no_jdbc_error_message = None
 
     if db_name == DB_MYSQL:
       jdbc_driver_mysql_name = default("/hostLevelParams/custom_mysql_jdbc_name", None)
-      jdbc_url = jdk_location + jdbc_driver_mysql_name
-      jdbc_driver_class = JDBC_DRIVER_CLASS_MYSQL
-      jdbc_name = jdbc_driver_mysql_name
+      if not jdbc_driver_mysql_name:
+        no_jdbc_error_message = "The MySQL JDBC driver has not been set. Please ensure that you have executed 'ambari-server setup --jdbc-db=mysql --jdbc-driver=/path/to/jdbc_driver'."
+      else:
+        jdbc_url = jdk_location + jdbc_driver_mysql_name
+        jdbc_driver_class = JDBC_DRIVER_CLASS_MYSQL
+        jdbc_name = jdbc_driver_mysql_name
     elif db_name == DB_ORACLE:
       jdbc_driver_oracle_name = default("/hostLevelParams/custom_oracle_jdbc_name", None)
-      jdbc_url = jdk_location + jdbc_driver_oracle_name
-      jdbc_driver_class = JDBC_DRIVER_CLASS_ORACLE
-      jdbc_name = jdbc_driver_oracle_name
+      if not jdbc_driver_oracle_name:
+        no_jdbc_error_message = "The Oracle JDBC driver has not been set. Please ensure that you have executed 'ambari-server setup --jdbc-db=oracle --jdbc-driver=/path/to/jdbc_driver'."
+      else:
+        jdbc_url = jdk_location + jdbc_driver_oracle_name
+        jdbc_driver_class = JDBC_DRIVER_CLASS_ORACLE
+        jdbc_name = jdbc_driver_oracle_name
     elif db_name == DB_POSTGRESQL:
       jdbc_driver_postgres_name = default("/hostLevelParams/custom_postgres_jdbc_name", None)
-      jdbc_url = jdk_location + jdbc_driver_postgres_name
-      jdbc_driver_class = JDBC_DRIVER_CLASS_POSTGRESQL
-      jdbc_name = jdbc_driver_postgres_name
+      if not jdbc_driver_postgres_name:
+        no_jdbc_error_message = "The Postgres JDBC driver has not been set. Please ensure that you have executed 'ambari-server setup --jdbc-db=postgres --jdbc-driver=/path/to/jdbc_driver'."
+      else:
+        jdbc_url = jdk_location + jdbc_driver_postgres_name
+        jdbc_driver_class = JDBC_DRIVER_CLASS_POSTGRESQL
+        jdbc_name = jdbc_driver_postgres_name
     elif db_name == DB_MSSQL:
       jdbc_driver_mssql_name = default("/hostLevelParams/custom_mssql_jdbc_name", None)
-      jdbc_url = jdk_location + jdbc_driver_mssql_name
-      jdbc_driver_class = JDBC_DRIVER_CLASS_MSSQL
-      jdbc_name = jdbc_driver_mssql_name
+      if not jdbc_driver_mssql_name:
+        no_jdbc_error_message = "The MSSQL JDBC driver has not been set. Please ensure that you have executed 'ambari-server setup --jdbc-db=mssql --jdbc-driver=/path/to/jdbc_driver'."
+      else:
+        jdbc_url = jdk_location + jdbc_driver_mssql_name
+        jdbc_driver_class = JDBC_DRIVER_CLASS_MSSQL
+        jdbc_name = jdbc_driver_mssql_name
     elif db_name == DB_SQLA:
       jdbc_driver_sqla_name = default("/hostLevelParams/custom_sqlanywhere_jdbc_name", None)
-      jdbc_url = jdk_location + jdbc_driver_sqla_name
-      jdbc_driver_class = JDBC_DRIVER_CLASS_SQLA
-      jdbc_name = jdbc_driver_sqla_name
-  
+      if not jdbc_driver_sqla_name:
+        no_jdbc_error_message = "The SQLAnywhere JDBC driver has not been set. Please ensure that you have executed 'ambari-server setup --jdbc-db=sqlanywhere --jdbc-driver=/path/to/jdbc_driver'."
+      else:
+        jdbc_url = jdk_location + jdbc_driver_sqla_name
+        jdbc_driver_class = JDBC_DRIVER_CLASS_SQLA
+        jdbc_name = jdbc_driver_sqla_name
+
+    if no_jdbc_error_message:
+      Logger.warning(no_jdbc_error_message)
+      db_connection_check_structured_output = {"exit_code" : 1, "message": no_jdbc_error_message}
+      return db_connection_check_structured_output
+
     db_connection_url = config['commandParams']['db_connection_url']
     user_name = config['commandParams']['user_name']
     user_passwd = config['commandParams']['user_passwd']