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-17889. Bad error message if user has not performed ambari-server setup for jdbc driver before configuring custom DB.(vbrodetskyi)
Date Tue, 26 Jul 2016 13:56:37 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 277f7d2e1 -> a50a37333


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/a50a3733
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a50a3733
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a50a3733

Branch: refs/heads/trunk
Commit: a50a37333668185d2eadfbe08999235f4cbbe44b
Parents: 277f7d2
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Tue Jul 26 16:56:01 2016 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Tue Jul 26 16:56:01 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/a50a3733/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']


Mime
View raw message