Repository: ambari Updated Branches: refs/heads/branch-1.6.1 07a96f75f -> 709649cef refs/heads/trunk a6b1217e4 -> b8eb0bb6a
AMBARI-6185. Secure cluster: JCE policy files not distributed on non-client hosts. (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b8eb0bb6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b8eb0bb6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b8eb0bb6 Branch: refs/heads/trunk Commit: b8eb0bb6a643419f453cacf81749b7c20867d458 Parents: a6b1217 Author: Andrew Onishuk <[email protected]> Authored: Wed Jun 25 19:47:30 2014 +0300 Committer: Andrew Onishuk <[email protected]> Committed: Wed Jun 25 19:47:30 2014 +0300 ---------------------------------------------------------------------- .../HDP/1.3.2/hooks/before-ANY/scripts/hook.py | 33 +++++++++++ .../1.3.2/hooks/before-ANY/scripts/params.py | 33 +++++++++++ .../before-ANY/scripts/shared_initialization.py | 58 ++++++++++++++++++++ .../1.3.2/hooks/before-INSTALL/scripts/hook.py | 9 +-- .../scripts/shared_initialization.py | 24 -------- .../1.3.2/hooks/before-RESTART/scripts/hook.py | 4 +- .../1.3.2/hooks/before-START/scripts/hook.py | 9 +-- .../HDP/2.0.6/hooks/before-ANY/scripts/hook.py | 33 +++++++++++ .../2.0.6/hooks/before-ANY/scripts/params.py | 33 +++++++++++ .../before-ANY/scripts/shared_initialization.py | 58 ++++++++++++++++++++ .../2.0.6/hooks/before-INSTALL/scripts/hook.py | 8 ++- .../scripts/shared_initialization.py | 26 +-------- .../2.0.6/hooks/before-RESTART/scripts/hook.py | 4 +- .../2.0.6/hooks/before-START/scripts/hook.py | 9 +-- .../hooks/before-INSTALL/test_before_install.py | 28 ++-------- .../hooks/before-START/test_before_start.py | 15 ++++- .../hooks/before-INSTALL/test_before_install.py | 24 ++------ .../hooks/before-START/test_before_start.py | 15 ++++- 18 files changed, 308 insertions(+), 115 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/hook.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/hook.py new file mode 100644 index 0000000..0f97e28 --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/hook.py @@ -0,0 +1,33 @@ +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +""" + +from resource_management import * +from shared_initialization import * + +class BeforeAnyHook(Hook): + + def hook(self, env): + import params + env.set_params(params) + + setup_jce() + +if __name__ == "__main__": + BeforeAnyHook().execute() + http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/params.py new file mode 100644 index 0000000..c7b01d6 --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/params.py @@ -0,0 +1,33 @@ +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +""" + +from resource_management import * + +config = Script.get_config() + +_authentication = config['configurations']['core-site']['hadoop.security.authentication'] +security_enabled = ( not is_empty(_authentication) and _authentication == 'kerberos') + +artifact_dir = "/tmp/HDP-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'] + +ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0] http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/shared_initialization.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/shared_initialization.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/shared_initialization.py new file mode 100644 index 0000000..70a1623 --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-ANY/scripts/shared_initialization.py @@ -0,0 +1,58 @@ +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +""" + +import os + +from resource_management import * + + + +def setup_jce(): + import params + + if not params.jdk_name: + return + + environment = { + "no_proxy": format("{ambari_server_hostname}") + } + + if params.jce_policy_zip is not None: + jce_curl_target = format("{artifact_dir}/{jce_policy_zip}") + download_jce = format("mkdir -p {artifact_dir}; \ + curl -kf --retry 10 \ + {jce_location}/{jce_policy_zip} -o {jce_curl_target}") + Execute( download_jce, + path = ["/bin","/usr/bin/"], + not_if =format("test -e {jce_curl_target}"), + ignore_failures = True, + environment = environment + ) + 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") + extract_cmd = format("rm -f local_policy.jar; rm -f US_export_policy.jar; unzip -o -j -q {jce_curl_target}") + Execute(extract_cmd, + only_if = format("test -e {security_dir} && test -f {jce_curl_target}"), + cwd = security_dir, + path = ['/bin/','/usr/bin'] + ) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/hook.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/hook.py index 626b199..372df02 100644 --- a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/hook.py +++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/hook.py @@ -22,17 +22,18 @@ from resource_management import * from shared_initialization import * from repo_initialization import install_repos -#TODO this must be "CONFIGURE" hook when CONFIGURE command will be implemented -class BeforeConfigureHook(Hook): +class BeforeInstallHook(Hook): def hook(self, env): import params - + + self.run_custom_hook('before-ANY') env.set_params(params) + install_repos() setup_java() setup_users() install_packages() if __name__ == "__main__": - BeforeConfigureHook().execute() + BeforeInstallHook().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/shared_initialization.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/shared_initialization.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/shared_initialization.py index 3a0bf93..554db28 100644 --- a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/shared_initialization.py +++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-INSTALL/scripts/shared_initialization.py @@ -170,29 +170,5 @@ def setup_java(): not_if = format("test -e {java_exec}") ) - if params.jce_policy_zip is not None: - jce_curl_target = format("{artifact_dir}/{jce_policy_zip}") - download_jce = format("mkdir -p {artifact_dir}; curl -kf " - "--retry 10 {jce_location}/{jce_policy_zip} " - "-o {jce_curl_target}") - Execute( download_jce, - path = ["/bin","/usr/bin/"], - not_if =format("test -e {jce_curl_target}"), - environment = environment, - ignore_failures = True - ) - 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") - extract_cmd = format("rm -f local_policy.jar; rm -f US_export_policy.jar; unzip -o -j -q {jce_curl_target}") - Execute(extract_cmd, - only_if = format("test -e {security_dir} && test -f {jce_curl_target}"), - cwd = security_dir, - path = ['/bin/','/usr/bin'] - ) - def install_packages(): Package(['unzip']) http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py index 05977c3..14b9d99 100644 --- a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py +++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py @@ -19,11 +19,11 @@ limitations under the License. from resource_management import * -class BeforeConfigureHook(Hook): +class BeforeRestartHook(Hook): def hook(self, env): self.run_custom_hook('before-START') if __name__ == "__main__": - BeforeConfigureHook().execute() + BeforeRestartHook().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/hook.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/hook.py index 8ad8c70..04bdc16 100644 --- a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/hook.py +++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/hook.py @@ -21,18 +21,19 @@ import sys from resource_management import * from shared_initialization import * -#TODO this must be "CONFIGURE" hook when CONFIGURE command will be implemented -class BeforeConfigureHook(Hook): +class BeforeStartHook(Hook): def hook(self, env): import params - env.set_params(params) + self.run_custom_hook('before-ANY') self.run_custom_hook('after-INSTALL') + env.set_params(params) + setup_hadoop() setup_database() setup_configs() create_javahome_symlink() if __name__ == "__main__": - BeforeConfigureHook().execute() + BeforeStartHook().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/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 new file mode 100644 index 0000000..0f97e28 --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py @@ -0,0 +1,33 @@ +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +""" + +from resource_management import * +from shared_initialization import * + +class BeforeAnyHook(Hook): + + def hook(self, env): + import params + env.set_params(params) + + setup_jce() + +if __name__ == "__main__": + BeforeAnyHook().execute() + http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/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 new file mode 100644 index 0000000..c7b01d6 --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py @@ -0,0 +1,33 @@ +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +""" + +from resource_management import * + +config = Script.get_config() + +_authentication = config['configurations']['core-site']['hadoop.security.authentication'] +security_enabled = ( not is_empty(_authentication) and _authentication == 'kerberos') + +artifact_dir = "/tmp/HDP-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'] + +ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0] http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/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 new file mode 100644 index 0000000..70a1623 --- /dev/null +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py @@ -0,0 +1,58 @@ +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +""" + +import os + +from resource_management import * + + + +def setup_jce(): + import params + + if not params.jdk_name: + return + + environment = { + "no_proxy": format("{ambari_server_hostname}") + } + + if params.jce_policy_zip is not None: + jce_curl_target = format("{artifact_dir}/{jce_policy_zip}") + download_jce = format("mkdir -p {artifact_dir}; \ + curl -kf --retry 10 \ + {jce_location}/{jce_policy_zip} -o {jce_curl_target}") + Execute( download_jce, + path = ["/bin","/usr/bin/"], + not_if =format("test -e {jce_curl_target}"), + ignore_failures = True, + environment = environment + ) + 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") + extract_cmd = format("rm -f local_policy.jar; rm -f US_export_policy.jar; unzip -o -j -q {jce_curl_target}") + Execute(extract_cmd, + only_if = format("test -e {security_dir} && test -f {jce_curl_target}"), + cwd = security_dir, + path = ['/bin/','/usr/bin'] + ) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/hook.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/hook.py index 6904e9d..a8a5662 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/hook.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/hook.py @@ -21,17 +21,19 @@ import sys from resource_management import * from shared_initialization import * from repo_initialization import * -#TODO this must be "CONFIGURE" hook when CONFIGURE command will be implemented -class BeforeConfigureHook(Hook): + +class BeforeInstallHook(Hook): def hook(self, env): import params + self.run_custom_hook('before-ANY') env.set_params(params) + install_repos() install_packages() setup_java() setup_users() if __name__ == "__main__": - BeforeConfigureHook().execute() + BeforeInstallHook().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/shared_initialization.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/shared_initialization.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/shared_initialization.py index a1196a8..6116763 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/shared_initialization.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/shared_initialization.py @@ -157,7 +157,7 @@ def set_uid(user, user_dirs): mode=0555) Execute(format("/tmp/changeUid.sh {user} {user_dirs} 2>/dev/null"), not_if = format("test $(id -u {user}) -gt 1000")) - + def setup_java(): """ Installs jdk using specific params, that comes from ambari-server @@ -192,29 +192,5 @@ def setup_java(): not_if = format("test -e {java_exec}") ) - if params.jce_policy_zip is not None: - jce_curl_target = format("{artifact_dir}/{jce_policy_zip}") - download_jce = format("mkdir -p {artifact_dir}; \ - curl -kf --retry 10 \ - {jce_location}/{jce_policy_zip} -o {jce_curl_target}") - Execute( download_jce, - path = ["/bin","/usr/bin/"], - not_if =format("test -e {jce_curl_target}"), - ignore_failures = True, - environment = environment - ) - 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") - extract_cmd = format("rm -f local_policy.jar; rm -f US_export_policy.jar; unzip -o -j -q {jce_curl_target}") - Execute(extract_cmd, - only_if = format("test -e {security_dir} && test -f {jce_curl_target}"), - cwd = security_dir, - path = ['/bin/','/usr/bin'] - ) - def install_packages(): Package(['unzip', 'curl']) http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py index 05977c3..14b9d99 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py @@ -19,11 +19,11 @@ limitations under the License. from resource_management import * -class BeforeConfigureHook(Hook): +class BeforeRestartHook(Hook): def hook(self, env): self.run_custom_hook('before-START') if __name__ == "__main__": - BeforeConfigureHook().execute() + BeforeRestartHook().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/hook.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/hook.py index 703889e..a18a776 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/hook.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/hook.py @@ -21,17 +21,18 @@ import sys from resource_management import * from shared_initialization import * -#TODO this must be "CONFIGURE" hook when CONFIGURE command will be implemented -class BeforeConfigureHook(Hook): +class BeforeStartHook(Hook): def hook(self, env): import params - env.set_params(params) + self.run_custom_hook('before-ANY') self.run_custom_hook('after-INSTALL') + env.set_params(params) + setup_hadoop() setup_configs() create_javahome_symlink() if __name__ == "__main__": - BeforeConfigureHook().execute() + BeforeStartHook().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/test/python/stacks/1.3.2/hooks/before-INSTALL/test_before_install.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/1.3.2/hooks/before-INSTALL/test_before_install.py b/ambari-server/src/test/python/stacks/1.3.2/hooks/before-INSTALL/test_before_install.py index 58084d0..ce9dbbc 100644 --- a/ambari-server/src/test/python/stacks/1.3.2/hooks/before-INSTALL/test_before_install.py +++ b/ambari-server/src/test/python/stacks/1.3.2/hooks/before-INSTALL/test_before_install.py @@ -18,13 +18,15 @@ See the License for the specific language governing permissions and limitations under the License. ''' +from mock.mock import MagicMock, call, patch +from resource_management import * from stacks.utils.RMFTestCase import * -from resource_management.core.exceptions import * [email protected](Hook, "run_custom_hook", new = MagicMock()) class TestHookBeforeInstall(RMFTestCase): def test_hook_default(self): self.executeScript("1.3.2/hooks/before-INSTALL/scripts/hook.py", - classname="BeforeConfigureHook", + classname="BeforeInstallHook", command="hook", config_file="default.json" ) @@ -45,12 +47,6 @@ class TestHookBeforeInstall(RMFTestCase): not_if = 'test -e /usr/jdk64/jdk1.7.0_45/bin/java', path = ['/bin', '/usr/bin/'], ) - self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/; curl -kf --retry 10 http://c6401.ambari.apache.org:8080/resources//UnlimitedJCEPolicyJDK7.zip -o /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip', - not_if = 'test -e /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip', - ignore_failures = True, - path = ['/bin', '/usr/bin/'], - environment = {'no_proxy': 'c6401.ambari.apache.org'} - ) self.assertResourceCalled('Group', 'hadoop', ignore_failures = False, ) @@ -138,18 +134,4 @@ class TestHookBeforeInstall(RMFTestCase): ignore_failures = False, ) self.assertResourceCalled('Package', 'unzip',) - self.assertNoMoreResources() - - - def test_that_jce_is_required_in_secured_cluster(self): - try: - self.executeScript("1.3.2/hooks/before-INSTALL/scripts/hook.py", - classname="BeforeConfigureHook", - command="hook", - config_file="secured_no_jce_name.json" - ) - self.fail("Should throw an exception") - except Fail: - pass # Expected - - + self.assertNoMoreResources() \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/test/python/stacks/1.3.2/hooks/before-START/test_before_start.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/1.3.2/hooks/before-START/test_before_start.py b/ambari-server/src/test/python/stacks/1.3.2/hooks/before-START/test_before_start.py index fc906b1..8646747 100644 --- a/ambari-server/src/test/python/stacks/1.3.2/hooks/before-START/test_before_start.py +++ b/ambari-server/src/test/python/stacks/1.3.2/hooks/before-START/test_before_start.py @@ -27,7 +27,7 @@ from stacks.utils.RMFTestCase import * class TestHookBeforeStart(RMFTestCase): def test_hook_default(self, mockHook): self.executeScript("1.3.2/hooks/before-START/scripts/hook.py", - classname="BeforeConfigureHook", + classname="BeforeStartHook", command="hook", config_file="default.json" ) @@ -85,7 +85,7 @@ class TestHookBeforeStart(RMFTestCase): def test_hook_secured(self, mockHook): self.executeScript("1.3.2/hooks/before-START/scripts/hook.py", - classname="BeforeConfigureHook", + classname="BeforeStartHook", command="hook", config_file="secured.json" ) @@ -136,3 +136,14 @@ class TestHookBeforeStart(RMFTestCase): group = 'hadoop', ) self.assertNoMoreResources() + +def test_that_jce_is_required_in_secured_cluster(self): + try: + self.executeScript("2.0.6/hooks/before-START/scripts/hook.py", + classname="BeforeStartHook", + command="hook", + config_file="secured_no_jce_name.json" + ) + self.fail("Should throw an exception") + except Fail: + pass # Expected http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py index 92eed49..8227ff2 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py +++ b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-INSTALL/test_before_install.py @@ -18,13 +18,15 @@ See the License for the specific language governing permissions and limitations under the License. ''' +from mock.mock import MagicMock, call, patch +from resource_management import * from stacks.utils.RMFTestCase import * -from resource_management.core.exceptions import * [email protected](Hook, "run_custom_hook", new = MagicMock()) class TestHookBeforeInstall(RMFTestCase): def test_hook_default(self): self.executeScript("2.0.6/hooks/before-INSTALL/scripts/hook.py", - classname="BeforeConfigureHook", + classname="BeforeInstallHook", command="hook", config_file="default.json" ) @@ -47,12 +49,6 @@ class TestHookBeforeInstall(RMFTestCase): not_if = 'test -e /usr/jdk64/jdk1.7.0_45/bin/java', path = ['/bin', '/usr/bin/'], ) - self.assertResourceCalled('Execute', 'mkdir -p /tmp/HDP-artifacts/; curl -kf --retry 10 http://c6401.ambari.apache.org:8080/resources//UnlimitedJCEPolicyJDK7.zip -o /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip', - not_if = 'test -e /tmp/HDP-artifacts//UnlimitedJCEPolicyJDK7.zip', - ignore_failures = True, - path = ['/bin', '/usr/bin/'], - environment = {'no_proxy': 'c6401.ambari.apache.org'}, - ) self.assertResourceCalled('Group', 'hadoop', ignore_failures = False, ) @@ -159,15 +155,3 @@ class TestHookBeforeInstall(RMFTestCase): groups = ['users'], ) self.assertNoMoreResources() - - - def test_that_jce_is_required_in_secured_cluster(self): - try: - self.executeScript("2.0.6/hooks/before-INSTALL/scripts/hook.py", - classname="BeforeConfigureHook", - command="hook", - config_file="secured_no_jce_name.json" - ) - self.fail("Should throw an exception") - except Fail: - pass # Expected http://git-wip-us.apache.org/repos/asf/ambari/blob/b8eb0bb6/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py index 9274fd5..1eafe66 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py +++ b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py @@ -27,7 +27,7 @@ from stacks.utils.RMFTestCase import * class TestHookBeforeStart(RMFTestCase): def test_hook_default(self): self.executeScript("2.0.6/hooks/before-START/scripts/hook.py", - classname="BeforeConfigureHook", + classname="BeforeStartHook", command="hook", config_file="default.json" ) @@ -87,7 +87,7 @@ class TestHookBeforeStart(RMFTestCase): def test_hook_secured(self): self.executeScript("2.0.6/hooks/before-START/scripts/hook.py", - classname="BeforeConfigureHook", + classname="BeforeStartHook", command="hook", config_file="secured.json" ) @@ -144,3 +144,14 @@ class TestHookBeforeStart(RMFTestCase): group = 'hadoop', ) self.assertNoMoreResources() + +def test_that_jce_is_required_in_secured_cluster(self): + try: + self.executeScript("2.0.6/hooks/before-START/scripts/hook.py", + classname="BeforeStartHook", + command="hook", + config_file="secured_no_jce_name.json" + ) + self.fail("Should throw an exception") + except Fail: + pass # Expected
