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 Thu, 25 Aug 2016 12:01:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 8ac653f9a -> a16cb5ad9


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

Branch: refs/heads/branch-2.5
Commit: a16cb5ad98cd7146f55bd9fd8d55edd4ec0a5897
Parents: 8ac653f
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Thu Aug 25 15:01:03 2016 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Thu Aug 25 15:01:03 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/a16cb5ad/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