ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-18962:Make check_package_condition in script.py overridable by services in stacks (dili)
Date Wed, 30 Nov 2016 16:13:52 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9559a1626 -> 10878592c


AMBARI-18962:Make check_package_condition in script.py overridable by services in stacks (dili)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/10878592
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/10878592
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/10878592

Branch: refs/heads/trunk
Commit: 10878592c2e2f5ac0412be8085c634d471f7358f
Parents: 9559a16
Author: Di Li <dili@apache.org>
Authored: Wed Nov 30 11:13:19 2016 -0500
Committer: Di Li <dili@apache.org>
Committed: Wed Nov 30 11:13:19 2016 -0500

----------------------------------------------------------------------
 .../resource_management/libraries/script/script.py   | 15 +++++++++------
 .../custom_actions/scripts/install_packages.py       |  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/10878592/ambari-common/src/main/python/resource_management/libraries/script/script.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py
b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index f8df842..584775e 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -580,7 +580,7 @@ class Script(object):
       if isinstance(package_list_str, basestring) and len(package_list_str) > 0:
         package_list = json.loads(package_list_str)
         for package in package_list:
-          if Script.check_package_condition(package):
+          if self.check_package_condition(package):
             name = self.format_package_name(package['name'])
             # HACK: On Windows, only install ambari-metrics packages using Choco Package
Installer
             # TODO: Update this once choco packages for hadoop are created. This is because,
service metainfo.xml support
@@ -604,22 +604,25 @@ class Script(object):
                           str(config['hostLevelParams']['stack_version']))
       reload_windows_env()
       
-  @staticmethod
-  def check_package_condition(package):
-    from resource_management.libraries.functions import package_conditions
+  def check_package_condition(self, package):
     condition = package['condition']
-    name = package['name']
     
     if not condition:
       return True
     
+    return self.should_install_package(package)
+
+  def should_install_package(self, package):
+    from resource_management.libraries.functions import package_conditions
+    condition = package['condition']
     try:
       chooser_method = getattr(package_conditions, condition)
     except AttributeError:
+      name = package['name']
       raise Fail("Condition with name '{0}', when installing package {1}. Please check package_conditions.py.".format(condition,
name))
 
     return chooser_method()
-      
+
   @staticmethod
   def matches_any_regexp(string, regexp_list):
     for regex in regexp_list:

http://git-wip-us.apache.org/repos/asf/ambari/blob/10878592/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
index 0e31310..112abe3 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/install_packages.py
@@ -460,7 +460,7 @@ class InstallPackages(Script):
     """
     filtered_package_list = []
     for package in package_list:
-      if Script.check_package_condition(package):
+      if self.check_package_condition(package):
         filtered_package_list.append(package)
     return filtered_package_list
 


Mime
View raw message