Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DC6BF200D4A for ; Tue, 28 Nov 2017 22:20:24 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id DAEB2160BE7; Tue, 28 Nov 2017 21:20:24 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2E89F160C24 for ; Tue, 28 Nov 2017 22:20:23 +0100 (CET) Received: (qmail 5398 invoked by uid 500); 28 Nov 2017 21:20:21 -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 5141 invoked by uid 99); 28 Nov 2017 21:20:21 -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; Tue, 28 Nov 2017 21:20:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8892AF6021; Tue, 28 Nov 2017 21:20:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jonathanhurley@apache.org To: commits@ambari.apache.org Date: Tue, 28 Nov 2017 21:20:35 -0000 Message-Id: In-Reply-To: <37eff83b5c9b45ef9e7bce9678052861@git.apache.org> References: <37eff83b5c9b45ef9e7bce9678052861@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [16/24] ambari git commit: AMBARI-22484. Stack advisor should disallow lzo enable without accepting license agreement. Additional fixes. (mpapirkovskyy) archived-at: Tue, 28 Nov 2017 21:20:25 -0000 AMBARI-22484. Stack advisor should disallow lzo enable without accepting license agreement. Additional fixes. (mpapirkovskyy) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d301d345 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d301d345 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d301d345 Branch: refs/heads/branch-2.6 Commit: d301d34517d5f48b824b95e9aab01176ec4c4a10 Parents: c0fbb86 Author: Myroslav Papirkovskyi Authored: Wed Nov 22 20:37:22 2017 +0200 Committer: Myroslav Papirkovskyi Committed: Wed Nov 22 20:40:06 2017 +0200 ---------------------------------------------------------------------- .../stackadvisor/StackAdvisorRequest.java | 8 +++++ .../stacks/HDP/2.0.6/services/stack_advisor.py | 36 +++++++++++++++----- .../src/main/resources/stacks/stack_advisor.py | 9 +++++ .../stacks/2.0.6/common/test_stack_advisor.py | 14 ++++++-- 4 files changed, 55 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/d301d345/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java index bc1e079..d750a6c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRequest.java @@ -118,6 +118,9 @@ public class StackAdvisorRequest { this.configGroups = configGroups; } + /** + * @return true if GPL license is accepted, false otherwise + */ public Boolean getGplLicenseAccepted() { return gplLicenseAccepted; } @@ -194,6 +197,11 @@ public class StackAdvisorRequest { return this; } + /** + * Set GPL license acceptance parameter to request. + * @param gplLicenseAccepted is GPL license accepted. + * @return stack advisor request builder. + */ public StackAdvisorRequestBuilder withGPLLicenseAccepted( Boolean gplLicenseAccepted) { this.instance.gplLicenseAccepted = gplLicenseAccepted; http://git-wip-us.apache.org/repos/asf/ambari/blob/d301d345/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py index 6d80f1a..3f8a772 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py @@ -517,20 +517,38 @@ class HDP206StackAdvisor(DefaultStackAdvisor): self.recommendHadoopProxyUsers(configurations, services, hosts) def getLZOSupportValidationItems(self, properties, services): + ''' + Checks GPL license is accepted when GPL software is used. + :param properties: dict of properties' name and value pairs + :param services: list of services + :return: NOT_APPLICABLE messages in case GPL license is not accepted + ''' services_list = self.get_services_list(services) + validations = [] if "HDFS" in services_list: lzo_allowed = services["gpl-license-accepted"] - property_name = "io.compression.codec.lzo.class" - if property_name in properties: - property_value = properties.get(property_name) - if not lzo_allowed and "com.hadoop.compression.lzo.LzoCodec" in property_value: - return [{"config-name": property_name, "item": self.getErrorItem( - "Your Ambari Server has not been configured to download LZO and install it. " - "LZO is GPL software and requires you to accept a license prior to use. " - "Please refer to this documentation to configure Ambari before proceeding.")}] - return [] + self.validatePropertyToLZOCodec("io.compression.codecs", properties, lzo_allowed, validations) + self.validatePropertyToLZOCodec("io.compression.codec.lzo.class", properties, lzo_allowed, validations) + return validations + + def validatePropertyToLZOCodec(self, property_name, properties, lzo_allowed, validations): + ''' + Checks specified property contains LZO codec class and requires GPL license acceptance. + :param property_name: property name + :param properties: dict of properties' name and value pairs + :param lzo_allowed: is gpl license accepted + :param validations: list with validation failures + ''' + lzo_codec_class = "com.hadoop.compression.lzo.LzoCodec" + if property_name in properties: + property_value = properties.get(property_name) + if not lzo_allowed and lzo_codec_class in property_value: + validations.append({"config-name": property_name, "item": self.getNotApplicableItem( + "Your Ambari Server has not been configured to download LZO and install it. " + "LZO is GPL software and requires you to accept a license prior to use. " + "Please refer to the documentation to configure Ambari before proceeding.")}) def recommendHbaseConfigurations(self, configurations, clusterData, services, hosts): # recommendations for HBase env config http://git-wip-us.apache.org/repos/asf/ambari/blob/d301d345/ambari-server/src/main/resources/stacks/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/stack_advisor.py b/ambari-server/src/main/resources/stacks/stack_advisor.py index 8ccbaba..ab3fd4f 100644 --- a/ambari-server/src/main/resources/stacks/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/stack_advisor.py @@ -888,6 +888,15 @@ class DefaultStackAdvisor(StackAdvisor): """ return {"level": "ERROR", "message": message} + def getNotApplicableItem(self, message): + ''' + Creates report about validation error that can not be ignored. + UI should not allow the proceeding of work. + :param message: error description. + :return: report about error. + ''' + return {"level": "NOT_APPLICABLE", "message": message} + def getComponentHostNames(self, servicesDict, serviceName, componentName): for service in servicesDict["services"]: if service["StackServices"]["service_name"] == serviceName: http://git-wip-us.apache.org/repos/asf/ambari/blob/d301d345/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py index e011847..e5adb19 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py @@ -2362,7 +2362,8 @@ class TestHDP206StackAdvisor(TestCase): services = {"gpl-license-accepted": True, "services": [{"StackServices": {"service_name": "HDFS"}}]} # 1) ok: gpl is allowed - properties = {'io.compression.codec.lzo.class': 'com.hadoop.compression.lzo.LzoCodec'} + properties = {'io.compression.codec.lzo.class': 'com.hadoop.compression.lzo.LzoCodec', + 'io.compression.codecs': 'AnotherCodec, com.hadoop.compression.lzo.LzoCodec'} res_expected = [] res = self.stackAdvisor.validateHDFSConfigurationsCoreSite(properties, {}, configurations, services, '') @@ -2373,10 +2374,17 @@ class TestHDP206StackAdvisor(TestCase): res_expected = [{'config-type': 'core-site', 'message': 'Your Ambari Server has not been configured to download LZO and install it. ' 'LZO is GPL software and requires you to accept a license prior to use. ' - 'Please refer to this documentation to configure Ambari before proceeding.', + 'Please refer to the documentation to configure Ambari before proceeding.', + 'type': 'configuration', + 'config-name': 'io.compression.codecs', + 'level': 'NOT_APPLICABLE'}, + {'config-type': 'core-site', + 'message': 'Your Ambari Server has not been configured to download LZO and install it. ' + 'LZO is GPL software and requires you to accept a license prior to use. ' + 'Please refer to the documentation to configure Ambari before proceeding.', 'type': 'configuration', 'config-name': 'io.compression.codec.lzo.class', - 'level': 'ERROR'}] + 'level': 'NOT_APPLICABLE'}] res = self.stackAdvisor.validateHDFSConfigurationsCoreSite(properties, {}, configurations, services, '') self.assertEquals(res, res_expected)