Repository: ambari Updated Branches: refs/heads/trunk 439372473 -> e78b92b8d
AMBARI-19446: Able to skip writing configuration files when the config type doesn't exist in the command JSON file (dili Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e78b92b8 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e78b92b8 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e78b92b8 Branch: refs/heads/trunk Commit: e78b92b8da7e573848b26cae951195a46fed2cff Parents: 4393724 Author: Di Li <[email protected]> Authored: Mon Jan 16 14:23:41 2017 -0500 Committer: Di Li <[email protected]> Committed: Mon Jan 16 14:23:41 2017 -0500 ---------------------------------------------------------------------- .../libraries/functions/get_config.py | 45 ++++++++++++++++++++ .../HIVE/0.12.0.2.0/package/scripts/hive.py | 17 +++++--- .../KNOX/0.5.0.2.2/package/scripts/knox.py | 35 +++++++++------ .../0.5.0.2.2/package/scripts/params_linux.py | 2 +- .../0.5.0.2.2/package/scripts/params_windows.py | 2 +- .../SQOOP/1.4.4.2.0/package/scripts/sqoop.py | 21 +++++---- 6 files changed, 90 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/e78b92b8/ambari-common/src/main/python/resource_management/libraries/functions/get_config.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/get_config.py b/ambari-common/src/main/python/resource_management/libraries/functions/get_config.py new file mode 100644 index 0000000..57af51f --- /dev/null +++ b/ambari-common/src/main/python/resource_management/libraries/functions/get_config.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +""" +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. + +Ambari Agent + +""" + +from resource_management.core.logger import Logger + +__all__ = ["get_config"] + +def get_config(config_type, default=None): + """ + @param config_type: config_type + """ + + import params + if params.config: + all_configurations = params.config.get('configurations', default) + if all_configurations: + config = all_configurations.get(config_type, default) + if not config: + Logger.warning("No configurations for config type {0}. Use default instead.".format(config_type)) + return config + else: + Logger.warning("No service configurations available in the \"configurations\" section. Use default instead.".format(config_type)) + return default + else: + Logger.warning("No service configurations available. Use default instead.".format(config_type)) + return default http://git-wip-us.apache.org/repos/asf/ambari/blob/e78b92b8/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py index 0db3faf..f825982 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py @@ -25,6 +25,7 @@ from urlparse import urlparse from resource_management.libraries.script.script import Script from resource_management.libraries.resources.hdfs_resource import HdfsResource from resource_management.libraries.functions.copy_tarball import copy_to_hdfs +from resource_management.libraries.functions.get_config import get_config from resource_management.libraries.functions import StackFeature from resource_management.libraries.functions.stack_features import check_stack_feature from resource_management.core.resources.service import ServiceConfig @@ -270,13 +271,15 @@ def setup_metastore(): import params if params.hive_metastore_site_supported: - XmlConfig("hivemetastore-site.xml", - conf_dir=params.hive_server_conf_dir, - configurations=params.config['configurations']['hivemetastore-site'], - configuration_attributes=params.config['configuration_attributes']['hivemetastore-site'], - owner=params.hive_user, - group=params.user_group, - mode=0600) + hivemetastore_site_config = get_config("hivemetastore-site") + if hivemetastore_site_config: + XmlConfig("hivemetastore-site.xml", + conf_dir=params.hive_server_conf_dir, + configurations=params.config['configurations']['hivemetastore-site'], + configuration_attributes=params.config['configuration_attributes']['hivemetastore-site'], + owner=params.hive_user, + group=params.user_group, + mode=0600) File(os.path.join(params.hive_server_conf_dir, "hadoop-metrics2-hivemetastore.properties"), owner=params.hive_user, http://git-wip-us.apache.org/repos/asf/ambari/blob/e78b92b8/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py index cce9c5f..34b5643 100644 --- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py +++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py @@ -22,6 +22,7 @@ from resource_management.libraries.script.script import Script from resource_management.libraries.resources.xml_config import XmlConfig from resource_management.core.resources.service import ServiceConfig from resource_management.libraries.functions.format import format +from resource_management.libraries.functions.get_config import get_config from resource_management.libraries.resources.template_config import TemplateConfig from resource_management.core.resources.system import File, Execute, Directory from resource_management.core.shell import as_user @@ -61,17 +62,20 @@ def knox(): content=InlineTemplate(params.topology_template) ) - File(os.path.join(params.knox_conf_dir, "topologies", "admin.xml"), - group=params.knox_group, - owner=params.knox_user, - content=InlineTemplate(params.admin_topology_template) - ) + if params.admin_topology_template: + File(os.path.join(params.knox_conf_dir, "topologies", "admin.xml"), + group=params.knox_group, + owner=params.knox_user, + content=InlineTemplate(params.admin_topology_template) + ) if params.version_formatted and check_stack_feature(StackFeature.KNOX_SSO_TOPOLOGY, params.version_formatted): + knoxsso_topology_template_content = get_config("knoxsso-topology") + if knoxsso_topology_template_content: File(os.path.join(params.knox_conf_dir, "topologies", "knoxsso.xml"), - group=params.knox_group, - owner=params.knox_user, - content=InlineTemplate(params.knoxsso_topology_template) + group=params.knox_group, + owner=params.knox_user, + content=InlineTemplate(params.knoxsso_topology_template) ) if params.security_enabled: @@ -118,20 +122,23 @@ def knox(): owner=params.knox_user, content=InlineTemplate(params.topology_template) ) - File(format("{params.knox_conf_dir}/topologies/admin.xml"), - group=params.knox_group, - owner=params.knox_user, - content=InlineTemplate(params.admin_topology_template) - ) + + if params.admin_topology_template: + File(format("{params.knox_conf_dir}/topologies/admin.xml"), + group=params.knox_group, + owner=params.knox_user, + content=InlineTemplate(params.admin_topology_template) + ) if params.version_formatted and check_stack_feature(StackFeature.KNOX_SSO_TOPOLOGY, params.version_formatted): + knoxsso_topology_template_content = get_config("knoxsso-topology") + if knoxsso_topology_template_content: File(os.path.join(params.knox_conf_dir, "topologies", "knoxsso.xml"), group=params.knox_group, owner=params.knox_user, content=InlineTemplate(params.knoxsso_topology_template) ) - if params.security_enabled: TemplateConfig( format("{knox_conf_dir}/krb5JAASLogin.conf"), owner = params.knox_user, http://git-wip-us.apache.org/repos/asf/ambari/blob/e78b92b8/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py index c471bc3..dd5fc3a 100644 --- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py +++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py @@ -244,7 +244,7 @@ knox_host_name = config['clusterHostInfo']['knox_gateway_hosts'][0] knox_host_name_in_cluster = config['hostname'] knox_host_port = config['configurations']['gateway-site']['gateway.port'] topology_template = config['configurations']['topology']['content'] -admin_topology_template = config['configurations']['admin-topology']['content'] +admin_topology_template = default('/configurations/admin-topology/content', None) knoxsso_topology_template = config['configurations']['knoxsso-topology']['content'] gateway_log4j = config['configurations']['gateway-log4j']['content'] ldap_log4j = config['configurations']['ldap-log4j']['content'] http://git-wip-us.apache.org/repos/asf/ambari/blob/e78b92b8/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py index 53a3316..631146d 100644 --- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py +++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py @@ -57,7 +57,7 @@ knox_host_name = config['clusterHostInfo']['knox_gateway_hosts'][0] knox_host_name_in_cluster = config['hostname'] knox_master_secret = config['configurations']['knox-env']['knox_master_secret'] topology_template = config['configurations']['topology']['content'] -admin_topology_template = config['configurations']['admin-topology']['content'] +admin_topology_template = default('/configurations/admin-topology/content', None) knoxsso_topology_template = config['configurations']['knoxsso-topology']['content'] gateway_log4j = config['configurations']['gateway-log4j']['content'] security_enabled = config['configurations']['cluster-env']['security_enabled'] http://git-wip-us.apache.org/repos/asf/ambari/blob/e78b92b8/ambari-server/src/main/resources/common-services/SQOOP/1.4.4.2.0/package/scripts/sqoop.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/SQOOP/1.4.4.2.0/package/scripts/sqoop.py b/ambari-server/src/main/resources/common-services/SQOOP/1.4.4.2.0/package/scripts/sqoop.py index d005cbe..436402c 100644 --- a/ambari-server/src/main/resources/common-services/SQOOP/1.4.4.2.0/package/scripts/sqoop.py +++ b/ambari-server/src/main/resources/common-services/SQOOP/1.4.4.2.0/package/scripts/sqoop.py @@ -22,6 +22,7 @@ import os # Local Imports from resource_management.core.source import InlineTemplate, DownloadSource from resource_management.libraries.functions import format +from resource_management.libraries.functions.get_config import get_config from resource_management.libraries.resources.xml_config import XmlConfig from resource_management.core.resources.system import File, Link, Directory from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl @@ -53,15 +54,17 @@ def sqoop(type=None): ) configs = {} - configs.update(params.config['configurations']['sqoop-site']) - - XmlConfig("sqoop-site.xml", - conf_dir = params.sqoop_conf_dir, - configurations = configs, - configuration_attributes=params.config['configuration_attributes']['sqoop-site'], - owner = params.sqoop_user, - group = params.user_group - ) + sqoop_site_config = get_config('sqoop-site') + if sqoop_site_config: + configs.update(sqoop_site_config) + + XmlConfig("sqoop-site.xml", + conf_dir = params.sqoop_conf_dir, + configurations = configs, + configuration_attributes=params.config['configuration_attributes']['sqoop-site'], + owner = params.sqoop_user, + group = params.user_group + ) # Generate atlas-application.properties.xml file and symlink the hook jars if params.enable_atlas_hook:
