You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mp...@apache.org on 2017/11/22 18:40:30 UTC
ambari git commit: AMBARI-22484. Stack advisor should disallow lzo
enable without accepting license agreement. Additional fixes. (mpapirkovskyy)
Repository: ambari
Updated Branches:
refs/heads/branch-feature-AMBARI-22457 c0fbb86a4 -> d301d3451
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-feature-AMBARI-22457
Commit: d301d34517d5f48b824b95e9aab01176ec4c4a10
Parents: c0fbb86
Author: Myroslav Papirkovskyi <mp...@hortonworks.com>
Authored: Wed Nov 22 20:37:22 2017 +0200
Committer: Myroslav Papirkovskyi <mp...@hortonworks.com>
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)