ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject ambari git commit: AMBARI-12018. JCE distribution should be done as part of Kerberos service configure function instead from hooks (refactoring) (Emil Anca via rlevas)
Date Mon, 22 Jun 2015 15:23:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c07374f64 -> 116cd6e67


AMBARI-12018. JCE distribution should be done as part of Kerberos service configure function
instead from hooks (refactoring) (Emil Anca via rlevas)


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

Branch: refs/heads/trunk
Commit: 116cd6e67eba27a6302e36b3b266504200f25025
Parents: c07374f
Author: Emil Anca <eanca@hortonworks.com>
Authored: Mon Jun 22 11:22:39 2015 -0400
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Mon Jun 22 11:22:55 2015 -0400

----------------------------------------------------------------------
 .../package/scripts/kerberos_client.py          |  6 ++++
 .../package/scripts/kerberos_common.py          | 33 +++++++++++++++++++
 .../1.10.3-10/package/scripts/params.py         |  9 ++++++
 .../HDP/2.0.6/hooks/before-ANY/scripts/hook.py  |  3 +-
 .../2.0.6/hooks/before-ANY/scripts/params.py    |  2 --
 .../before-ANY/scripts/shared_initialization.py | 34 --------------------
 .../2.0.6/hooks/before-ANY/test_before_any.py   |  7 +---
 .../stacks/2.2/KERBEROS/test_kerberos_client.py |  6 ++++
 8 files changed, 56 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/116cd6e6/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_client.py
b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_client.py
index 282915a..580545d 100644
--- a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_client.py
+++ b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_client.py
@@ -37,6 +37,8 @@ class KerberosClient(KerberosScript):
     if params.manage_krb5_conf:
       self.write_krb5_conf()
 
+    self.setup_jce()
+
   def status(self, env):
     raise ClientComponentHasNoStatus()
 
@@ -67,5 +69,9 @@ class KerberosClient(KerberosScript):
   def remove_keytab(self, env):
     self.delete_keytab_file()
 
+  def download_install_jce(self, env):
+    self.setup_jce()
+
+
 if __name__ == "__main__":
   KerberosClient().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/116cd6e6/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
index cd9b2ba..d40627a 100644
--- a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
+++ b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_common.py
@@ -428,3 +428,36 @@ class KerberosScript(Script):
             curr_content['keytabs'][principal.replace("_HOST", params.hostname)] = '_REMOVED_'
 
             self.put_structured_out(curr_content)
+
+  def setup_jce(self):
+    import params
+
+    if not params.jdk_name:
+      return
+    jce_curl_target = None
+    if params.jce_policy_zip is not None:
+      jce_curl_target = format("{artifact_dir}/{jce_policy_zip}")
+      Directory(params.artifact_dir,
+                recursive = True,
+                )
+      File(jce_curl_target,
+           content = DownloadSource(format("{jce_location}/{jce_policy_zip}")),
+           )
+    elif params.security_enabled:
+      # Something weird is happening
+      raise Fail("Security is enabled, but JCE policy zip is not specified.")
+
+    # The extraction will occur only after the security flag is set
+    if params.security_enabled:
+      security_dir = format("{java_home}/jre/lib/security")
+
+      File([format("{security_dir}/US_export_policy.jar"), format("{security_dir}/local_policy.jar")],
+           action = "delete",
+           )
+
+      extract_cmd = ("unzip", "-o", "-j", "-q", jce_curl_target, "-d", security_dir)
+      Execute(extract_cmd,
+              only_if = format("test -e {security_dir} && test -f {jce_curl_target}"),
+              path = ['/bin/','/usr/bin'],
+              sudo = True
+      )

http://git-wip-us.apache.org/repos/asf/ambari/blob/116cd6e6/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/params.py
b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/params.py
index beb0479..422c686 100644
--- a/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/params.py
@@ -62,6 +62,15 @@ smoke_user = 'ambari-qa'
 
 manage_identities = 'true'
 
+artifact_dir = format("{tmp_dir}/AMBARI-artifacts/")
+jce_policy_zip = default("/hostLevelParams/jce_name", None) # None when jdk is already installed
by user
+jce_location = config['hostLevelParams']['jdk_location']
+jdk_name = default("/hostLevelParams/jdk_name", None)
+java_home = config['hostLevelParams']['java_home']
+java_version = int(config['hostLevelParams']['java_version'])
+
+security_enabled = config['configurations']['cluster-env']['security_enabled']
+
 if config is not None:
   kerberos_command_params = get_property_value(config, 'kerberosCommandParams')
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/116cd6e6/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py
index 1fd36d6..a90c3b5 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py
@@ -25,8 +25,7 @@ class BeforeAnyHook(Hook):
   def hook(self, env):
     import params
     env.set_params(params)
-    
-    setup_jce()
+
     setup_users()
     setup_hadoop_env()
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/116cd6e6/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
index 87719f3..c526d49 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
@@ -37,8 +37,6 @@ config = Script.get_config()
 tmp_dir = Script.get_tmp_dir()
 
 artifact_dir = format("{tmp_dir}/AMBARI-artifacts/")
-jce_policy_zip = default("/hostLevelParams/jce_name", None) # None when jdk is already installed
by user
-jce_location = config['hostLevelParams']['jdk_location']
 jdk_name = default("/hostLevelParams/jdk_name", None)
 java_home = config['hostLevelParams']['java_home']
 java_version = int(config['hostLevelParams']['java_version'])

http://git-wip-us.apache.org/repos/asf/ambari/blob/116cd6e6/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
index 699fe5f..0ce7280 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
@@ -23,40 +23,6 @@ from copy import copy
 from resource_management.libraries.functions.version import compare_versions
 from resource_management import *
 
-
-
-def setup_jce():
-  import params
-  
-  if not params.jdk_name:
-    return
-  
-  if params.jce_policy_zip is not None:
-    jce_curl_target = format("{artifact_dir}/{jce_policy_zip}")
-    Directory(params.artifact_dir,
-         recursive = True,
-    )
-    File(jce_curl_target,
-         content = DownloadSource(format("{jce_location}/{jce_policy_zip}")),
-    )
-  elif params.security_enabled:
-    # Something weird is happening
-    raise Fail("Security is enabled, but JCE policy zip is not specified.")
-  
-  if params.security_enabled:
-    security_dir = format("{java_home}/jre/lib/security")
-    
-    File([format("{security_dir}/US_export_policy.jar"), format("{security_dir}/local_policy.jar")],
-         action = "delete",
-    )
-    
-    extract_cmd = ("unzip", "-o", "-j", "-q", jce_curl_target, "-d", security_dir) 
-    Execute(extract_cmd,
-            only_if = format("test -e {security_dir} && test -f {jce_curl_target}"),
-            path = ['/bin/','/usr/bin'],
-            sudo = True
-    )
-
 def setup_users():
   """
   Creates users before cluster installation

http://git-wip-us.apache.org/repos/asf/ambari/blob/116cd6e6/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
index 129907f..98ac1b2 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
@@ -41,12 +41,7 @@ class TestHookBeforeInstall(RMFTestCase):
                        command="hook",
                        config_file="default.json"
     )
-    self.assertResourceCalled('Directory', '/tmp/AMBARI-artifacts/',
-        recursive = True,
-    )
-    self.assertResourceCalled('File', '/tmp/AMBARI-artifacts//UnlimitedJCEPolicyJDK7.zip',
-        content = DownloadSource('http://c6401.ambari.apache.org:8080/resources//UnlimitedJCEPolicyJDK7.zip'),
-    )
+
     self.assertResourceCalled('Group', 'hadoop',
         ignore_failures = False,
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/116cd6e6/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py b/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py
index 85f3f7c..105e741 100644
--- a/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py
+++ b/ambari-server/src/test/python/stacks/2.2/KERBEROS/test_kerberos_client.py
@@ -93,6 +93,12 @@ class TestKerberosClient(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
 
+    self.assertResourceCalled('Directory', '/tmp/AMBARI-artifacts/',
+                              recursive = True,
+                              )
+    self.assertResourceCalled('File', '/tmp/AMBARI-artifacts//UnlimitedJCEPolicyJDK7.zip',
+                            content = DownloadSource('http://c6401.ambari.apache.org:8080/resources//UnlimitedJCEPolicyJDK7.zip'),
+                            )
     self.assertNoMoreResources()
 
   def test_configure_unmanaged_ad(self):


Mime
View raw message