Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8A83218659 for ; Mon, 26 Oct 2015 16:28:17 +0000 (UTC) Received: (qmail 6430 invoked by uid 500); 26 Oct 2015 16:28:08 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 6405 invoked by uid 500); 26 Oct 2015 16:28:08 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 6396 invoked by uid 99); 26 Oct 2015 16:28:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Oct 2015 16:28:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D758AE0231; Mon, 26 Oct 2015 16:28:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dsen@apache.org To: commits@ambari.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-13545 Invalidate enabling Storm ranger plugin in non kerberos environment (dsen) Date: Mon, 26 Oct 2015 16:28:07 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/trunk 395ff0941 -> 88bb0a73d AMBARI-13545 Invalidate enabling Storm ranger plugin in non kerberos environment (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/88bb0a73 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/88bb0a73 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/88bb0a73 Branch: refs/heads/trunk Commit: 88bb0a73d3e782b0ccd1fe2d09885bcc383e39f8 Parents: 395ff09 Author: Dmytro Sen Authored: Mon Oct 26 18:27:51 2015 +0200 Committer: Dmytro Sen Committed: Mon Oct 26 18:27:51 2015 +0200 ---------------------------------------------------------------------- .../stacks/HDP/2.2/services/stack_advisor.py | 25 ++++++++- .../stacks/2.2/common/test_stack_advisor.py | 55 ++++++++++++++++++++ .../stacks/2.3/common/test_stack_advisor.py | 4 +- 3 files changed, 81 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/88bb0a73/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py index 707a641..2a2944c 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py @@ -38,7 +38,8 @@ class HDP22StackAdvisor(HDP21StackAdvisor): "AMBARI_METRICS": self.recommendAmsConfigurations, "YARN": self.recommendYARNConfigurations, "STORM": self.recommendStormConfigurations, - "KNOX": self.recommendKnoxConfigurations + "KNOX": self.recommendKnoxConfigurations, + "RANGER": self.recommendRangerConfigurations } parentRecommendConfDict.update(childRecommendConfDict) return parentRecommendConfDict @@ -829,6 +830,15 @@ class HDP22StackAdvisor(HDP21StackAdvisor): putKnoxTopologyContent('content', newTopologyXmlContent) + def recommendRangerConfigurations(self, configurations, clusterData, services, hosts): + super(HDP22StackAdvisor, self).recommendRangerConfigurations(configurations, clusterData, services, hosts) + putRangerEnvProperty = self.putProperty(configurations, "ranger-env") + cluster_env = getServicesSiteProperties(services, "cluster-env") + security_enabled = cluster_env is not None and "security_enabled" in cluster_env and \ + cluster_env["security_enabled"].lower() == "true" + if "ranger-env" in configurations and not security_enabled: + putRangerEnvProperty("ranger-storm-plugin-enabled", "No") + def getServiceConfigurationValidators(self): parentValidators = super(HDP22StackAdvisor, self).getServiceConfigurationValidators() childValidators = { @@ -847,7 +857,8 @@ class HDP22StackAdvisor(HDP21StackAdvisor): "KAFKA": {"ranger-kafka-plugin-properties": self.validateKafkaRangerPluginConfigurations}, "STORM": {"ranger-storm-plugin-properties": self.validateStormRangerPluginConfigurations}, "MAPREDUCE2": {"mapred-site": self.validateMapReduce2Configurations}, - "TEZ": {"tez-site": self.validateTezConfigurations} + "TEZ": {"tez-site": self.validateTezConfigurations}, + "RANGER": {"ranger-env": self.validateRangerConfigurationsEnv} } self.mergeValidators(parentValidators, childValidators) return parentValidators @@ -1379,6 +1390,16 @@ class HDP22StackAdvisor(HDP21StackAdvisor): "ranger-yarn-plugin-properties/ranger-yarn-plugin-enabled must correspond ranger-env/ranger-yarn-plugin-enabled")}) return self.toConfigurationValidationProblems(validationItems, "ranger-yarn-plugin-properties") + def validateRangerConfigurationsEnv(self, properties, recommendedDefaults, configurations, services, hosts): + validationItems = [] + if "ranger-storm-plugin-enabled" in properties and "ranger-storm-plugin-enabled" in recommendedDefaults and \ + properties["ranger-storm-plugin-enabled"] != recommendedDefaults["ranger-storm-plugin-enabled"]: + validationItems.append({"config-name": "ranger-storm-plugin-enabled", + "item": self.getWarnItem( + "Ranger Storm plugin should not be enabled in non-kerberos environment.")}) + + return self.toConfigurationValidationProblems(validationItems, "ranger-env") + def getMastersWithMultipleInstances(self): result = super(HDP22StackAdvisor, self).getMastersWithMultipleInstances() result.extend(['METRICS_COLLECTOR']) http://git-wip-us.apache.org/repos/asf/ambari/blob/88bb0a73/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py index 7abdcd0..a877370 100644 --- a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py @@ -3494,3 +3494,58 @@ class TestHDP22StackAdvisor(TestCase): res = self.stackAdvisor.validateStormRangerPluginConfigurations(properties, recommendedDefaults, configurations, services, {}) self.assertEquals(res, res_expected) + + def test_recommendRangerConfigurations(self): + clusterData = {} + # Recommend ranger-storm-plugin-enabled=No on non-kerberos cluster + services = { + "Versions" : { + "stack_version" : "2.3", + }, + "services": [ + { + "StackServices": { + "service_name": "RANGER" + }, + "components": [ + { + "StackServiceComponents": { + "component_name": "RANGER_ADMIN", + "hostnames": ["host1"] + } + } + ] + }, + ], + "configurations": { + "cluster-env": { + "properties": { + "security_enabled": "false", + } + }, + }, + } + + expected = { + 'admin-properties': {'properties': {'policymgr_external_url': 'http://host1:6080'}}, 'ranger-env': {'properties': {'ranger-storm-plugin-enabled': 'No'}} + } + + recommendedConfigurations = {} + self.stackAdvisor.recommendRangerConfigurations(recommendedConfigurations, clusterData, services, None) + self.assertEquals(recommendedConfigurations, expected) + + def test_validateRangerConfigurationsEnv(self): + properties = { + "ranger-storm-plugin-enabled": "Yes", + } + recommendedDefaults = { + "ranger-storm-plugin-enabled": "No", + } + configurations = {} + services = {} + + # Test with ranger plugin enabled, validation fails + res_expected = [{'config-type': 'ranger-env', 'message': 'Ranger Storm plugin should not be enabled in non-kerberos environment.', 'type': 'configuration', 'config-name': 'ranger-storm-plugin-enabled', 'level': 'WARN'}] + res = self.stackAdvisor.validateRangerConfigurationsEnv(properties, recommendedDefaults, configurations, services, {}) + self.assertEquals(res, res_expected) + http://git-wip-us.apache.org/repos/asf/ambari/blob/88bb0a73/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 33ad293..b886117 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 @@ -1095,7 +1095,9 @@ class TestHDP23StackAdvisor(TestCase): } }, 'ranger-env': { - 'properties': {} + 'properties': { + 'ranger-storm-plugin-enabled': 'No', + } } }