Repository: ambari Updated Branches: refs/heads/trunk 1d76f9571 -> 32c8cfa85
AMBARI-14533. User should be able to secure hawq after it has been deployed (odiachenko). Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/32c8cfa8 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/32c8cfa8 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/32c8cfa8 Branch: refs/heads/trunk Commit: 32c8cfa852e3cf618d8c0fcb471eb120d93e0b95 Parents: 1d76f95 Author: Oleksandr Diachenko <[email protected]> Authored: Mon Jan 4 10:27:44 2016 -0800 Committer: Oleksandr Diachenko <[email protected]> Committed: Mon Jan 4 10:28:00 2016 -0800 ---------------------------------------------------------------------- .../HAWQ/2.0.0/package/scripts/master_helper.py | 13 ++++++++---- .../HAWQ/2.0.0/package/scripts/params.py | 21 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/32c8cfa8/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py index cf7dc77..e15b64d 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py @@ -84,9 +84,10 @@ def __create_local_dirs(): Execute("chmod 700 {0}".format(params.hawq_master_dir), user=hawq_constants.root_user, timeout=hawq_constants.default_exec_timeout) -def __create_hdfs_dirs(): +def __setup_hdfs_dirs(): """ - Creates the required HDFS directories for HAWQ + Creates the required HDFS directories for HAWQ if they don't exist + or sets proper owner/mode if directory exists """ import params @@ -97,6 +98,7 @@ def __create_hdfs_dirs(): action="create_on_execute", owner=data_dir_owner, group=hawq_constants.hawq_group, + recursive_chown = True, mode=0755) params.HdfsResource(None, action="execute") @@ -105,7 +107,7 @@ def __init_active(): """ Initializes the active master """ - __create_hdfs_dirs() + __setup_hdfs_dirs() utils.exec_hawq_operation(hawq_constants.INIT, "{0} -a -v".format(hawq_constants.MASTER)) @@ -129,6 +131,9 @@ def __start_local_master(): """ import params component_name = __get_component_name() + + __setup_hdfs_dirs() + utils.exec_hawq_operation( hawq_constants.START, "{0} -a -v".format(component_name), @@ -203,4 +208,4 @@ def __is_active_master(): Finds if this node is the active master """ import params - return params.hostname == common.get_local_hawq_site_property("hawq_master_address_host") + return params.hostname == common.get_local_hawq_site_property("hawq_master_address_host") \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/32c8cfa8/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py index 1c247ba..d92cc7f 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py @@ -16,11 +16,19 @@ See the License for the specific language governing permissions and limitations under the License. """ +import os import functools from resource_management import Script from resource_management.libraries.functions.default import default from resource_management.libraries.resources.hdfs_resource import HdfsResource +from resource_management.libraries.resources.execute_hadoop import ExecuteHadoop from resource_management.libraries.functions import get_kinit_path +from resource_management.libraries.functions import conf_select +try: + from resource_management.libraries.functions import hdp_select as hadoop_select +except ImportError: + from resource_management.libraries.functions import phd_select as hadoop_select + config = Script.get_config() @@ -57,6 +65,9 @@ security_enabled = config['configurations']['cluster-env']['security_enabled'] hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab'] kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None)) hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name'] +hadoop_conf_dir = conf_select.get_hadoop_conf_dir() +hadoop_bin_dir = hadoop_select.get_hadoop_dir("bin") +execute_path = os.environ['PATH'] + os.pathsep + hadoop_bin_dir # HDFSResource partial function HdfsResource = functools.partial(HdfsResource, @@ -68,6 +79,16 @@ HdfsResource = functools.partial(HdfsResource, hdfs_site=hdfs_site, default_fs=default_fs) +# ExecuteHadoop partial function +ExecuteHadoop = functools.partial(ExecuteHadoop, + user=hdfs_superuser, + logoutput=True, + conf_dir=hadoop_conf_dir, + security_enabled=security_enabled, + kinit_path_local=kinit_path_local, + keytab=hdfs_user_keytab, + principal=hdfs_principal_name, + bin_dir=execute_path) # YARN # Note: YARN is not mandatory for HAWQ. It is required only when the users set HAWQ to use YARN as resource manager
