Ver Fonte

AMBARI-12991. Phoenix rpm should not be installed if not being used in Ambari. (aonishuk)

Andrew Onishuk há 10 anos atrás
pai
commit
7aafe0e59f

+ 13 - 1
ambari-common/src/main/python/resource_management/libraries/script/script.py

@@ -21,6 +21,7 @@ import tempfile
 
 __all__ = ["Script"]
 
+import re
 import os
 import sys
 import logging
@@ -358,6 +359,9 @@ class Script(object):
     List of packages that are required< by service is received from the server
     as a command parameter. The method installs all packages
     from this list
+    
+    exclude_packages - list of regexes (possibly raw strings as well), the
+    packages which match the regex won't be installed
     """
     config = self.get_config()
     if 'host_sys_prepped' in config['hostLevelParams']:
@@ -371,7 +375,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 not package['name'] in exclude_packages:
+          if not Script.matches_any_regexp(package['name'], exclude_packages):
             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
@@ -392,6 +396,14 @@ class Script(object):
                           hadoop_user, self.get_password(hadoop_user),
                           str(config['hostLevelParams']['stack_version']))
       reload_windows_env()
+      
+  @staticmethod
+  def matches_any_regexp(string, regexp_list):
+    for regex in regexp_list:
+      # adding ^ and $ to correctly match raw strings from begining to the end
+      if re.match('^' + regex + '$', string):
+        return True
+    return False
 
   @staticmethod
   def fail_with_error(message):

+ 3 - 1
ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_client.py

@@ -29,7 +29,9 @@ from ambari_commons.os_family_impl import OsFamilyImpl
 
 class HbaseClient(Script):
   def install(self, env):
-    self.install_packages(env)
+    import params
+    
+    self.install_packages(env, params.exclude_packages)
     self.configure(env)
 
   def configure(self, env):

+ 2 - 1
ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_master.py

@@ -39,7 +39,8 @@ class HbaseMaster(Script):
     hbase(name='master')
 
   def install(self, env):
-    self.install_packages(env)
+    import params
+    self.install_packages(env, params.exclude_packages)
 
   def decommission(self, env):
     import params

+ 2 - 1
ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase_regionserver.py

@@ -33,7 +33,8 @@ from ambari_commons.os_family_impl import OsFamilyImpl
 
 class HbaseRegionServer(Script):
   def install(self, env):
-    self.install_packages(env)
+    import params
+    self.install_packages(env, params.exclude_packages)
 
   def configure(self, env):
     import params

+ 8 - 0
ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_linux.py

@@ -106,6 +106,14 @@ regionserver_xmn_percent = config['configurations']['hbase-env']['hbase_regionse
 regionserver_xmn_size = calc_xmn_from_xms(regionserver_heapsize, regionserver_xmn_percent, regionserver_xmn_max)
 
 
+phoenix_hosts = default('/clusterHostInfo/phoenix_query_server_hosts', [])
+has_phoenix = len(phoenix_hosts) > 0
+
+if not has_phoenix:
+  exclude_packages = ['phoenix.+']
+else:
+  exclude_packages = []
+
 pid_dir = status_params.pid_dir
 tmp_dir = config['configurations']['hbase-site']['hbase.tmp.dir']
 local_dir = config['configurations']['hbase-site']['hbase.local.dir']

+ 2 - 1
ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/phoenix_queryserver.py

@@ -27,7 +27,8 @@ from hbase import hbase
 class PhoenixQueryServer(Script):
 
   def install(self, env):
-    self.install_packages(env)
+    import params
+    self.install_packages(env, params.exclude_packages)
 
 
   def get_stack_to_component(self):