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-17514. StackAdvisor fix for Oracle 12C and Add message if user forgot to set jdbc.(vbrodetskyi)
Date Fri, 01 Jul 2016 12:36:29 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 73871ea67 -> 8f9fbe8ef


AMBARI-17514. StackAdvisor fix for Oracle 12C and Add message if user forgot to set jdbc.(vbrodetskyi)


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

Branch: refs/heads/branch-2.4
Commit: 8f9fbe8ef32396069f9cde6f828c1271ab6dcfa1
Parents: 73871ea
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Fri Jul 1 15:35:29 2016 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Fri Jul 1 15:35:29 2016 +0300

----------------------------------------------------------------------
 .../RANGER/0.4.0/package/scripts/params.py        |  1 +
 .../0.4.0/package/scripts/setup_ranger_xml.py     |  5 +++++
 .../RANGER_KMS/0.5.0.2.3/package/scripts/kms.py   |  5 +++++
 .../0.5.0.2.3/package/scripts/params.py           |  1 +
 .../stacks/HDP/2.3/services/stack_advisor.py      | 18 +++++++++++++++---
 .../stacks/2.3/common/test_stack_advisor.py       | 17 +++++++++++++++--
 6 files changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8f9fbe8e/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
index ba8d3b3..a85bde0 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
@@ -151,6 +151,7 @@ oracle_home = default("/configurations/ranger-env/oracle_home", "-")
 #For curl command in ranger to get db connector
 jdk_location = config['hostLevelParams']['jdk_location'] 
 java_share_dir = '/usr/share/java'
+jdbc_jar_name = None
 previous_jdbc_jar_name = None
 if db_flavor.lower() == 'mysql':
   jdbc_jar_name = default("/hostLevelParams/custom_mysql_jdbc_name", None)

http://git-wip-us.apache.org/repos/asf/ambari/blob/8f9fbe8e/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
index e35ea5f..6b04075 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
@@ -286,6 +286,11 @@ def password_validation(password):
 def copy_jdbc_connector(stack_version=None):
   import params
 
+  if params.jdbc_jar_name is None and params.driver_curl_source.endswith("/None"):
+    error_message = "Error! Sorry, but we can't find jdbc driver related to {0} database
to download from {1}. \
+    Please run 'ambari-server setup --jdbc-db={db_name} --jdbc-driver={path_to_jdbc} on server
host.'".format(params.db_flavor, params.jdk_location)
+    Logger.error(error_message)
+
   if params.driver_curl_source and not params.driver_curl_source.endswith("/None"):
     if params.previous_jdbc_jar and os.path.isfile(params.previous_jdbc_jar):
       File(params.previous_jdbc_jar, action='delete')

http://git-wip-us.apache.org/repos/asf/ambari/blob/8f9fbe8e/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
index 133760b..4d24893 100755
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
@@ -309,6 +309,11 @@ def kms(upgrade_type=None):
 def copy_jdbc_connector(stack_version=None):
   import params
 
+  if params.jdbc_jar_name is None and params.driver_curl_source.endswith("/None"):
+    error_message = "Error! Sorry, but we can't find jdbc driver related to {0} database
to download from {1}. \
+    Please run 'ambari-server setup --jdbc-db={db_name} --jdbc-driver={path_to_jdbc} on server
host.'".format(params.db_flavor, params.jdk_location)
+    Logger.error(error_message)
+
   if params.driver_curl_source and not params.driver_curl_source.endswith("/None"):
     if params.previous_jdbc_jar and os.path.isfile(params.previous_jdbc_jar):
       File(params.previous_jdbc_jar, action='delete')

http://git-wip-us.apache.org/repos/asf/ambari/blob/8f9fbe8e/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
index dce6576..f887cc9 100755
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
@@ -104,6 +104,7 @@ default_connectors_map = { "mssql":"sqljdbc4.jar",
                            "sqla":"sajdbc4.jar"}
 
 java_share_dir = '/usr/share/java'
+jdbc_jar_name = None
 previous_jdbc_jar_name = None
 if db_flavor == 'mysql':
   jdbc_jar_name = default("/hostLevelParams/custom_mysql_jdbc_name", None)

http://git-wip-us.apache.org/repos/asf/ambari/blob/8f9fbe8e/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
index 6a3df08..879008b 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
@@ -393,7 +393,7 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
           'MYSQL': {'ranger.ks.jpa.jdbc.driver': 'com.mysql.jdbc.Driver',
                     'ranger.ks.jpa.jdbc.url': 'jdbc:mysql://' + self.getDBConnectionHostPort(rangerKmsDbFlavor,
rangerKmsDbHost) + '/' + rangerKmsDbName},
           'ORACLE': {'ranger.ks.jpa.jdbc.driver': 'oracle.jdbc.driver.OracleDriver',
-                     'ranger.ks.jpa.jdbc.url': 'jdbc:oracle:thin:@//' + self.getDBConnectionHostPort(rangerKmsDbFlavor,
rangerKmsDbHost) + '/' + rangerKmsDbName},
+                     'ranger.ks.jpa.jdbc.url': 'jdbc:oracle:thin:@' + self.getOracleDBConnectionHostPort(rangerKmsDbFlavor,
rangerKmsDbHost, rangerKmsDbName)},
           'POSTGRES': {'ranger.ks.jpa.jdbc.driver': 'org.postgresql.Driver',
                        'ranger.ks.jpa.jdbc.url': 'jdbc:postgresql://' + self.getDBConnectionHostPort(rangerKmsDbFlavor,
rangerKmsDbHost) + '/' + rangerKmsDbName},
           'MSSQL': {'ranger.ks.jpa.jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
@@ -421,6 +421,16 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
         putRangerKmsAuditProperty('xasecure.audit.destination.hdfs.dir', '{0}/{1}/{2}'.format(default_fs,'ranger','audit'))
 
 
+  def getOracleDBConnectionHostPort(self, db_type, db_host, rangerDbName):
+    connection_string = self.getDBConnectionHostPort(db_type, db_host)
+    colon_count = db_host.count(':')
+    if colon_count == 1 and '/' in db_host:
+      connection_string = "//" + connection_string
+    elif colon_count == 0 or colon_count == 1:
+      connection_string = "//" + connection_string + "/" + rangerDbName if rangerDbName else
"//" + connection_string
+
+    return connection_string
+
   def getDBConnectionHostPort(self, db_type, db_host):
     connection_string = ""
     if db_type is None or db_type == "":
@@ -434,6 +444,8 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
           connection_string = db_host
       elif colon_count == 1:
         connection_string = db_host
+      elif colon_count == 2:
+        connection_string = db_host
 
     return connection_string
 
@@ -455,7 +467,7 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
         'MYSQL': {'ranger.jpa.jdbc.driver': 'com.mysql.jdbc.Driver',
                   'ranger.jpa.jdbc.url': 'jdbc:mysql://' + self.getDBConnectionHostPort(rangerDbFlavor,
rangerDbHost) + '/' + rangerDbName},
         'ORACLE': {'ranger.jpa.jdbc.driver': 'oracle.jdbc.driver.OracleDriver',
-                   'ranger.jpa.jdbc.url': 'jdbc:oracle:thin:@//' + self.getDBConnectionHostPort(rangerDbFlavor,
rangerDbHost) + '/' + rangerDbName},
+                   'ranger.jpa.jdbc.url': 'jdbc:oracle:thin:@' + self.getOracleDBConnectionHostPort(rangerDbFlavor,
rangerDbHost, rangerDbName)},
         'POSTGRES': {'ranger.jpa.jdbc.driver': 'org.postgresql.Driver',
                      'ranger.jpa.jdbc.url': 'jdbc:postgresql://' + self.getDBConnectionHostPort(rangerDbFlavor,
rangerDbHost) + '/' + rangerDbName},
         'MSSQL': {'ranger.jpa.jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
@@ -474,7 +486,7 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
         rangerDbHost =   services['configurations']["admin-properties"]["properties"]["db_host"]
         ranger_db_privelege_url_dict = {
           'MYSQL': {'ranger_privelege_user_jdbc_url': 'jdbc:mysql://' + self.getDBConnectionHostPort(rangerDbFlavor,
rangerDbHost)},
-          'ORACLE': {'ranger_privelege_user_jdbc_url': 'jdbc:oracle:thin:@//' + self.getDBConnectionHostPort(rangerDbFlavor,
rangerDbHost)},
+          'ORACLE': {'ranger_privelege_user_jdbc_url': 'jdbc:oracle:thin:@' + self.getOracleDBConnectionHostPort(rangerDbFlavor,
rangerDbHost, None)},
           'POSTGRES': {'ranger_privelege_user_jdbc_url': 'jdbc:postgresql://' + self.getDBConnectionHostPort(rangerDbFlavor,
rangerDbHost) + '/postgres'},
           'MSSQL': {'ranger_privelege_user_jdbc_url': 'jdbc:sqlserver://' + self.getDBConnectionHostPort(rangerDbFlavor,
rangerDbHost) + ';'},
           'SQLA': {'ranger_privelege_user_jdbc_url': 'jdbc:sqlanywhere:host=' + self.getDBConnectionHostPort(rangerDbFlavor,
rangerDbHost) + ';'}

http://git-wip-us.apache.org/repos/asf/ambari/blob/8f9fbe8e/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
index 62d926e..2944f6f 100644
--- a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
@@ -2656,6 +2656,13 @@ class TestHDP23StackAdvisor(TestCase):
         'ranger-kms-audit': {
           'properties': {
           }
+        },
+        'kms-properties': {
+          'properties': {
+            'DB_FLAVOR': 'ORACLE',
+            'db_host' : 'c6401.ambari.apache.org:1521:XE',
+            'db_name' : "XE"
+          }
         }
       },
       "forced-configurations": []
@@ -2665,7 +2672,10 @@ class TestHDP23StackAdvisor(TestCase):
         'properties': {}
       },
       'dbks-site': {
-        'properties': {}
+        'properties': {
+          "ranger.ks.jpa.jdbc.driver" : "oracle.jdbc.driver.OracleDriver",
+          "ranger.ks.jpa.jdbc.url" : "jdbc:oracle:thin:@c6401.ambari.apache.org:1521:XE"
+        }
       },
       'core-site': {
         'properties': {
@@ -2694,7 +2704,10 @@ class TestHDP23StackAdvisor(TestCase):
         'properties': {}
       },
       'dbks-site': {
-        'properties': {}
+        'properties': {
+          "ranger.ks.jpa.jdbc.driver" : "oracle.jdbc.driver.OracleDriver",
+          "ranger.ks.jpa.jdbc.url" : "jdbc:oracle:thin:@c6401.ambari.apache.org:1521:XE"
+        }
       },
       'core-site': {
         'properties': {


Mime
View raw message