Pārlūkot izejas kodu

AMBARI-10244. Ubuntu7 title for debian7 repourl is confusing (aonishuk)

Andrew Onishuk 10 gadi atpakaļ
vecāks
revīzija
36ac578245
58 mainītis faili ar 426 papildinājumiem un 286 dzēšanām
  1. 17 14
      ambari-agent/src/main/python/ambari_agent/HostCleanup.py
  2. 10 7
      ambari-agent/src/main/python/ambari_agent/HostInfo.py
  3. 15 2
      ambari-agent/src/test/python/resource_management/TestMonitorWebserverResource.py
  4. 41 10
      ambari-agent/src/test/python/resource_management/TestRepositoryResource.py
  5. 2 2
      ambari-common/src/main/python/ambari_commons/firewall.py
  6. 22 15
      ambari-common/src/main/python/ambari_commons/os_check.py
  7. 10 3
      ambari-common/src/main/python/ambari_commons/resources/os_family.json
  8. 3 0
      ambari-common/src/main/python/resource_management/core/providers/__init__.py
  9. 1 1
      ambari-common/src/main/python/resource_management/core/system.py
  10. 1 0
      ambari-common/src/main/python/resource_management/libraries/functions/__init__.py
  11. 47 0
      ambari-common/src/main/python/resource_management/libraries/functions/get_lzo_packages.py
  12. 6 6
      ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
  13. 3 0
      ambari-common/src/main/python/resource_management/libraries/providers/__init__.py
  14. 2 1
      ambari-common/src/main/python/resource_management/libraries/providers/monitor_webserver.py
  15. 7 7
      ambari-common/src/main/python/resource_management/libraries/providers/repository.py
  16. 1 2
      ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
  17. 49 0
      ambari-server/src/main/java/org/apache/ambari/server/state/stack/JsonOsFamilyEntry.java
  18. 1 2
      ambari-server/src/main/java/org/apache/ambari/server/state/stack/LatestRepoCallable.java
  19. 41 15
      ambari-server/src/main/java/org/apache/ambari/server/state/stack/OsFamily.java
  20. 4 4
      ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
  21. 21 16
      ambari-server/src/main/python/ambari_server/utils.py
  22. 10 24
      ambari-server/src/main/python/bootstrap.py
  23. 2 1
      ambari-server/src/main/resources/common-services/GANGLIA/3.5.0/package/scripts/functions.py
  24. 2 1
      ambari-server/src/main/resources/common-services/GANGLIA/3.5.0/package/scripts/ganglia_server.py
  25. 5 4
      ambari-server/src/main/resources/common-services/GANGLIA/3.5.0/package/scripts/params.py
  26. 2 3
      ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs.py
  27. 4 20
      ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params.py
  28. 2 1
      ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params.py
  29. 2 1
      ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/status_params.py
  30. 7 10
      ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_server.py
  31. 3 4
      ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/params.py
  32. 2 2
      ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py
  33. 2 16
      ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py
  34. 2 1
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/params.py
  35. 2 1
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
  36. 2 1
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py
  37. 2 1
      ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/params.py
  38. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/repos/repoinfo.xml
  39. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/ACCUMULO/metainfo.xml
  40. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/FALCON/metainfo.xml
  41. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/FLUME/metainfo.xml
  42. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/HBASE/metainfo.xml
  43. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/HDFS/metainfo.xml
  44. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/HIVE/metainfo.xml
  45. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/KAFKA/metainfo.xml
  46. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/KNOX/metainfo.xml
  47. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/OOZIE/metainfo.xml
  48. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/metainfo.xml
  49. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/metainfo.xml
  50. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/SLIDER/metainfo.xml
  51. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/SPARK/metainfo.xml
  52. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/SQOOP/metainfo.xml
  53. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/STORM/metainfo.xml
  54. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/TEZ/metainfo.xml
  55. 2 2
      ambari-server/src/main/resources/stacks/HDP/2.3/services/YARN/metainfo.xml
  56. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/ZOOKEEPER/metainfo.xml
  57. 37 24
      ambari-server/src/test/python/TestBootstrap.py
  58. 14 44
      ambari-server/src/test/python/TestUtils.py

+ 17 - 14
ambari-agent/src/main/python/ambari_agent/HostCleanup.py

@@ -41,12 +41,6 @@ from ambari_commons.os_family_impl import OsFamilyImpl, OsFamilyFuncImpl
 
 
 logger = logging.getLogger()
 logger = logging.getLogger()
 
 
-PACKAGE_ERASE_CMD = {
-  "redhat": "yum erase -y {0}",
-  "suse": "zypper -n -q remove {0}",
-  "ubuntu": "/usr/bin/apt-get -y -q remove {0}"
-}
-
 USER_ERASE_CMD = "userdel -rf {0}"
 USER_ERASE_CMD = "userdel -rf {0}"
 GROUP_ERASE_CMD = "groupdel {0}"
 GROUP_ERASE_CMD = "groupdel {0}"
 PROC_KILL_CMD = "kill -9 {0}"
 PROC_KILL_CMD = "kill -9 {0}"
@@ -55,6 +49,7 @@ ALT_ERASE_CMD = "alternatives --remove {0} {1}"
 
 
 REPO_PATH_RHEL = "/etc/yum.repos.d"
 REPO_PATH_RHEL = "/etc/yum.repos.d"
 REPO_PATH_SUSE = "/etc/zypp/repos.d/"
 REPO_PATH_SUSE = "/etc/zypp/repos.d/"
+REPO_PATH_UBUNTU = "/etc/apt/sources.list.d"
 SKIP_LIST = []
 SKIP_LIST = []
 TMP_HOST_CHECK_FILE_NAME = "tmp_hostcheck.result"
 TMP_HOST_CHECK_FILE_NAME = "tmp_hostcheck.result"
 HOST_CHECK_FILE_NAME = "hostcheck.result"
 HOST_CHECK_FILE_NAME = "hostcheck.result"
@@ -90,6 +85,17 @@ DIRNAME_PATTERNS = [
 REPOSITORY_BLACK_LIST = ["ambari.repo"]
 REPOSITORY_BLACK_LIST = ["ambari.repo"]
 PACKAGES_BLACK_LIST = ["ambari-server", "ambari-agent"]
 PACKAGES_BLACK_LIST = ["ambari-server", "ambari-agent"]
 
 
+def get_erase_cmd():
+  if OSCheck.is_redhat_family():
+    return "yum erase -y {0}"
+  elif OSCheck.is_suse_family():
+    return "zypper -n -q remove {0}"
+  elif OSCheck.is_ubuntu_family():
+    return "/usr/bin/apt-get -y -q remove {0}"
+  else:
+    raise Exception("Unsupported OS family '{0}', cannot remove package. ".format(OSCheck.get_os_family()))
+
+
 class HostCleanup:
 class HostCleanup:
 
 
   SELECT_ALL_PERFORMED_MARKER = "/var/lib/ambari-agent/data/hdp-select-set-all.performed"
   SELECT_ALL_PERFORMED_MARKER = "/var/lib/ambari-agent/data/hdp-select-set-all.performed"
@@ -349,10 +355,12 @@ class HostCleanup:
         repoNameList.append("name=" + repoName)
         repoNameList.append("name=" + repoName)
     if repoNameList:
     if repoNameList:
       # get list of files
       # get list of files
-      if osType == 'suse':
+      if OSCheck.is_suse_family():
         fileList = self.get_files_in_dir(REPO_PATH_SUSE)
         fileList = self.get_files_in_dir(REPO_PATH_SUSE)
-      elif osType == "redhat":
+      elif OSCheck.is_redhat_family():
         fileList = self.get_files_in_dir(REPO_PATH_RHEL)
         fileList = self.get_files_in_dir(REPO_PATH_RHEL)
+      elif OSCheck.is_ubuntu_family():
+        fileList = self.get_files_in_dir(REPO_PATH_UBUNTU)
       else:
       else:
         logger.warn("Unsupported OS type, cannot get repository location.")
         logger.warn("Unsupported OS type, cannot get repository location.")
         return []
         return []
@@ -376,12 +384,7 @@ class HostCleanup:
       packageStr = ' '.join(packageList)
       packageStr = ' '.join(packageList)
       logger.debug("Erasing packages: " + packageStr)
       logger.debug("Erasing packages: " + packageStr)
     if packageStr is not None and packageStr:
     if packageStr is not None and packageStr:
-      os_name = OSCheck.get_os_family()
-      command = ''
-      if os_name in PACKAGE_ERASE_CMD:
-        command = PACKAGE_ERASE_CMD[os_name].format(packageStr)
-      else:
-        logger.warn("Unsupported OS type, cannot remove package.")
+      command = get_erase_cmd().format(packageStr)
 
 
       if command != '':
       if command != '':
         logger.debug('Executing: ' + str(command))
         logger.debug('Executing: ' + str(command))

+ 10 - 7
ambari-agent/src/main/python/ambari_agent/HostInfo.py

@@ -72,10 +72,7 @@ class HostInfo(object):
     osType = OSCheck.get_os_family()
     osType = OSCheck.get_os_family()
     for service in services:
     for service in services:
       svcCheckResult = {}
       svcCheckResult = {}
-      if isinstance(service, dict):
-        serviceName = service[osType]
-      else:
-        serviceName = service
+      serviceName = service
       svcCheckResult['name'] = serviceName
       svcCheckResult['name'] = serviceName
       svcCheckResult['status'] = "UNKNOWN"
       svcCheckResult['status'] = "UNKNOWN"
       svcCheckResult['desc'] = ""
       svcCheckResult['desc'] = ""
@@ -121,6 +118,12 @@ class HostInfo(object):
       pass
       pass
     return False
     return False
 
 
+def get_ntp_service():
+  if OSCheck.is_redhat_family():
+    return "ntpd"
+  elif OSCheck.is_suse_family() or OSCheck.is_ubuntu_family():
+    return "ntp"
+
 
 
 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
 class HostInfoLinux(HostInfo):
 class HostInfoLinux(HostInfo):
@@ -135,11 +138,11 @@ class HostInfoLinux(HostInfo):
     "ganglia-web"
     "ganglia-web"
   ]
   ]
 
 
+
   # List of live services checked for on the host, takes a map of plan strings
   # List of live services checked for on the host, takes a map of plan strings
   DEFAULT_LIVE_SERVICES = [
   DEFAULT_LIVE_SERVICES = [
-    {OSConst.REDHAT_FAMILY: "ntpd", OSConst.SUSE_FAMILY: "ntp", OSConst.UBUNTU_FAMILY: "ntp"}
+    get_ntp_service()
   ]
   ]
-
   # Set of default users (need to be replaced with the configured user names)
   # Set of default users (need to be replaced with the configured user names)
   DEFAULT_USERS = [
   DEFAULT_USERS = [
     "hive", "ambari-qa", "oozie", "hbase", "hcat", "mapred",
     "hive", "ambari-qa", "oozie", "hbase", "hcat", "mapred",
@@ -326,7 +329,7 @@ class HostInfoWindows(HostInfo):
   GET_USERS_CMD = '$accounts=(Get-WmiObject -Class Win32_UserAccount -Namespace "root\cimv2" -Filter "LocalAccount=\'$True\'" -ComputerName "LocalHost" -ErrorAction Stop); foreach ($acc in $accounts) {echo $acc.Name}'
   GET_USERS_CMD = '$accounts=(Get-WmiObject -Class Win32_UserAccount -Namespace "root\cimv2" -Filter "LocalAccount=\'$True\'" -ComputerName "LocalHost" -ErrorAction Stop); foreach ($acc in $accounts) {echo $acc.Name}'
   GET_JAVA_PROC_CMD = 'foreach ($process in (gwmi Win32_Process -Filter "name = \'java.exe\'")){echo $process.ProcessId;echo $process.CommandLine; echo $process.GetOwner().User}'
   GET_JAVA_PROC_CMD = 'foreach ($process in (gwmi Win32_Process -Filter "name = \'java.exe\'")){echo $process.ProcessId;echo $process.CommandLine; echo $process.GetOwner().User}'
   DEFAULT_LIVE_SERVICES = [
   DEFAULT_LIVE_SERVICES = [
-    {OSConst.WINSRV_FAMILY: "W32Time"}
+    "W32Time"
   ]
   ]
   DEFAULT_USERS = ["hadoop"]
   DEFAULT_USERS = ["hadoop"]
 
 

+ 15 - 2
ambari-agent/src/test/python/resource_management/TestMonitorWebserverResource.py

@@ -23,11 +23,18 @@ from resource_management.libraries.providers.monitor_webserver\
   import MonitorWebserverProvider
   import MonitorWebserverProvider
 from resource_management.libraries.resources.monitor_webserver\
 from resource_management.libraries.resources.monitor_webserver\
   import MonitorWebserver
   import MonitorWebserver
+from ambari_commons.os_check import OSCheck
 
 
 
 
 class TestMonitorWebserverResource(TestCase):
 class TestMonitorWebserverResource(TestCase):
+  @patch.object(OSCheck, "is_suse_family")
+  @patch.object(OSCheck, "is_ubuntu_family")
+  @patch.object(OSCheck, "is_redhat_family")
   @patch.object(System, "os_family", new='redhat')
   @patch.object(System, "os_family", new='redhat')
-  def test_setup_redhat(self):
+  def test_setup_redhat(self, is_redhat_family, is_ubuntu_family, is_suse_family):
+    is_redhat_family.return_value = True
+    is_ubuntu_family.return_value = False
+    is_suse_family.return_value = False
     with Environment(test_mode=True) as env:
     with Environment(test_mode=True) as env:
       MonitorWebserverProvider(MonitorWebserver("start")).action_start()
       MonitorWebserverProvider(MonitorWebserver("start")).action_start()
     defined_resources = env.resource_list
     defined_resources = env.resource_list
@@ -50,8 +57,14 @@ class TestMonitorWebserverResource(TestCase):
                          ' Execute[\'(\'/etc/init.d/apache2\', \'start\')\']]'
                          ' Execute[\'(\'/etc/init.d/apache2\', \'start\')\']]'
     self.assertEqual(str(defined_resources), expected_resources)
     self.assertEqual(str(defined_resources), expected_resources)
 
 
+  @patch.object(OSCheck, "is_suse_family")
+  @patch.object(OSCheck, "is_ubuntu_family")
+  @patch.object(OSCheck, "is_redhat_family")
   @patch.object(System, "os_family", new='redhat')
   @patch.object(System, "os_family", new='redhat')
-  def test_stop_redhat(self):
+  def test_stop_redhat(self, is_redhat_family, is_ubuntu_family, is_suse_family):
+    is_redhat_family.return_value = True
+    is_ubuntu_family.return_value = False
+    is_suse_family.return_value = False
     with Environment(test_mode=True) as env:
     with Environment(test_mode=True) as env:
       MonitorWebserverProvider(MonitorWebserver("stop")).action_stop()
       MonitorWebserverProvider(MonitorWebserver("stop")).action_stop()
     defined_resources = env.resource_list
     defined_resources = env.resource_list

+ 41 - 10
ambari-agent/src/test/python/resource_management/TestRepositoryResource.py

@@ -23,7 +23,7 @@ from mock.mock import patch, MagicMock
 
 
 from resource_management import *
 from resource_management import *
 from resource_management.libraries.providers import repository
 from resource_management.libraries.providers import repository
-
+from ambari_commons.os_check import OSCheck
 
 
 class DummyTemplate(object):
 class DummyTemplate(object):
 
 
@@ -53,9 +53,16 @@ gpgcheck=0
 
 
 
 
 class TestRepositoryResource(TestCase):
 class TestRepositoryResource(TestCase):
-    @patch.object(System, "os_family", new='redhat')
+    @patch.object(OSCheck, "is_suse_family")
+    @patch.object(OSCheck, "is_ubuntu_family")
+    @patch.object(OSCheck, "is_redhat_family")
     @patch("resource_management.libraries.providers.repository.File")
     @patch("resource_management.libraries.providers.repository.File")
-    def test_create_repo_redhat(self, file_mock):
+    @patch.object(System, "os_family", new='redhat')
+    def test_create_repo_redhat(self, file_mock,
+                                is_redhat_family, is_ubuntu_family, is_suse_family):
+        is_redhat_family.return_value = True
+        is_ubuntu_family.return_value = False
+        is_suse_family.return_value = False
         with Environment('/') as env:
         with Environment('/') as env:
           with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
           with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
             Repository('hadoop',
             Repository('hadoop',
@@ -85,9 +92,16 @@ class TestRepositoryResource(TestCase):
             self.assertEqual('dummy.j2', template)
             self.assertEqual('dummy.j2', template)
 
 
 
 
+    @patch.object(OSCheck, "is_suse_family")
+    @patch.object(OSCheck, "is_ubuntu_family")
+    @patch.object(OSCheck, "is_redhat_family")
     @patch.object(System, "os_family", new='suse')
     @patch.object(System, "os_family", new='suse')
     @patch("resource_management.libraries.providers.repository.File")
     @patch("resource_management.libraries.providers.repository.File")
-    def test_create_repo_suse(self, file_mock):
+    def test_create_repo_suse(self, file_mock,
+                              is_redhat_family, is_ubuntu_family, is_suse_family):
+        is_redhat_family.return_value = False
+        is_ubuntu_family.return_value = False
+        is_suse_family.return_value = True
         with Environment('/') as env:
         with Environment('/') as env:
           with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
           with patch.object(repository,"Template", new=DummyTemplate.create(RHEL_SUSE_DEFAULT_TEMPLATE)):
             Repository('hadoop',
             Repository('hadoop',
@@ -116,6 +130,9 @@ class TestRepositoryResource(TestCase):
             self.assertEqual(expected_template_arguments, template_item.context._dict)
             self.assertEqual(expected_template_arguments, template_item.context._dict)
             self.assertEqual('dummy.j2', template)
             self.assertEqual('dummy.j2', template)
     
     
+    @patch.object(OSCheck, "is_suse_family")
+    @patch.object(OSCheck, "is_ubuntu_family")
+    @patch.object(OSCheck, "is_redhat_family")
     @patch("resource_management.libraries.providers.repository.checked_call")
     @patch("resource_management.libraries.providers.repository.checked_call")
     @patch.object(tempfile, "NamedTemporaryFile")
     @patch.object(tempfile, "NamedTemporaryFile")
     @patch("resource_management.libraries.providers.repository.Execute")
     @patch("resource_management.libraries.providers.repository.Execute")
@@ -125,7 +142,10 @@ class TestRepositoryResource(TestCase):
     @patch.object(System, "os_release_name", new='precise')        
     @patch.object(System, "os_release_name", new='precise')        
     @patch.object(System, "os_family", new='ubuntu')
     @patch.object(System, "os_family", new='ubuntu')
     def test_create_repo_ubuntu_repo_exists(self, file_mock, execute_mock,
     def test_create_repo_ubuntu_repo_exists(self, file_mock, execute_mock,
-                                            tempfile_mock, checked_call_mock):
+                                            tempfile_mock, checked_call_mock, is_redhat_family, is_ubuntu_family, is_suse_family):
+      is_redhat_family.return_value = False
+      is_ubuntu_family.return_value = True
+      is_suse_family.return_value = False
       tempfile_mock.return_value = MagicMock(spec=file)
       tempfile_mock.return_value = MagicMock(spec=file)
       tempfile_mock.return_value.__enter__.return_value.name = "/tmp/1.txt"
       tempfile_mock.return_value.__enter__.return_value.name = "/tmp/1.txt"
       checked_call_mock.return_value = 0, "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123ABCD"
       checked_call_mock.return_value = 0, "The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123ABCD"
@@ -253,9 +273,15 @@ class TestRepositoryResource(TestCase):
       self.assertEqual(file_mock.call_count, 0)
       self.assertEqual(file_mock.call_count, 0)
       self.assertEqual(execute_mock.call_count, 0)
       self.assertEqual(execute_mock.call_count, 0)
 
 
-    @patch.object(System, "os_family", new='redhat')
+    @patch.object(OSCheck, "is_suse_family")
+    @patch.object(OSCheck, "is_ubuntu_family")
+    @patch.object(OSCheck, "is_redhat_family")
     @patch("resource_management.libraries.providers.repository.File")
     @patch("resource_management.libraries.providers.repository.File")
-    def test_remove_repo_redhat(self, file_mock):
+    def test_remove_repo_redhat(self, file_mock,
+                              is_redhat_family, is_ubuntu_family, is_suse_family):
+        is_redhat_family.return_value = True
+        is_ubuntu_family.return_value = False
+        is_suse_family.return_value = False
         with Environment('/') as env:
         with Environment('/') as env:
             Repository('hadoop',
             Repository('hadoop',
                        action='remove',
                        action='remove',
@@ -270,13 +296,18 @@ class TestRepositoryResource(TestCase):
                                   'mirror_list': 'https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
                                   'mirror_list': 'https://mirrors.base_url.org/?repo=Repository&arch=$basearch',
                                   'repo_file_name': 'Repository'}
                                   'repo_file_name': 'Repository'}
             self.assertEqual(defined_arguments, expected_arguments)
             self.assertEqual(defined_arguments, expected_arguments)
-            self.assertEqual(file_mock.call_args[1]['action'], 'delete')
-            self.assertEqual(file_mock.call_args[0][0], '/etc/yum.repos.d/Repository.repo')
 
 
 
 
+    @patch.object(OSCheck, "is_suse_family")
+    @patch.object(OSCheck, "is_ubuntu_family")
+    @patch.object(OSCheck, "is_redhat_family")
     @patch.object(System, "os_family", new='suse')
     @patch.object(System, "os_family", new='suse')
     @patch("resource_management.libraries.providers.repository.File")
     @patch("resource_management.libraries.providers.repository.File")
-    def test_remove_repo_suse(self, file_mock):
+    def test_remove_repo_suse(self, file_mock,
+                              is_redhat_family, is_ubuntu_family, is_suse_family):
+        is_redhat_family.return_value = False
+        is_ubuntu_family.return_value = False
+        is_suse_family.return_value = True
         with Environment('/') as env:
         with Environment('/') as env:
             Repository('hadoop',
             Repository('hadoop',
                        action='remove',
                        action='remove',

+ 2 - 2
ambari-common/src/main/python/ambari_commons/firewall.py

@@ -44,11 +44,11 @@ class FirewallWindows(Firewall):
 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
 class FirewallLinux(Firewall):
 class FirewallLinux(Firewall):
   def getFirewallObject(self):
   def getFirewallObject(self):
-    if self.OS_TYPE == OSConst.OS_UBUNTU:
+    if OSCheck.is_ubuntu_family():
       return UbuntuFirewallChecks()
       return UbuntuFirewallChecks()
     elif self.OS_TYPE == OSConst.OS_FEDORA and int(self.OS_VERSION) >= 18:
     elif self.OS_TYPE == OSConst.OS_FEDORA and int(self.OS_VERSION) >= 18:
       return Fedora18FirewallChecks()
       return Fedora18FirewallChecks()
-    elif self.OS_FAMILY == OSConst.SUSE_FAMILY:
+    elif OSCheck.is_suse_family():
       return SuseFirewallChecks()
       return SuseFirewallChecks()
     else:
     else:
       return FirewallChecks()
       return FirewallChecks()

+ 22 - 15
ambari-common/src/main/python/ambari_commons/os_check.py

@@ -57,6 +57,7 @@ RESOURCES_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resou
 OSFAMILY_JSON_RESOURCE = "os_family.json"
 OSFAMILY_JSON_RESOURCE = "os_family.json"
 JSON_OS_TYPE = "distro"
 JSON_OS_TYPE = "distro"
 JSON_OS_VERSION = "versions"
 JSON_OS_VERSION = "versions"
+JSON_EXTENDS = "extends"
 
 
 #windows family constants
 #windows family constants
 SYSTEM_WINDOWS = "Windows"
 SYSTEM_WINDOWS = "Windows"
@@ -104,6 +105,9 @@ class OS_CONST_TYPE(type):
           'name': family,
           'name': family,
           'os_list': json_data[family][JSON_OS_TYPE]
           'os_list': json_data[family][JSON_OS_TYPE]
         }]
         }]
+        
+        if JSON_EXTENDS in json_data[family]:
+          cls.OS_FAMILY_COLLECTION[-1][JSON_EXTENDS] = json_data[family][JSON_EXTENDS]
     except:
     except:
       raise Exception("Couldn't load '%s' file" % OSFAMILY_JSON_RESOURCE)
       raise Exception("Couldn't load '%s' file" % OSFAMILY_JSON_RESOURCE)
 
 
@@ -216,6 +220,15 @@ class OSCheck:
 
 
     return os_family.lower()
     return os_family.lower()
 
 
+  @staticmethod
+  def get_os_family_parent(os_family):
+    for os_family_item in OSConst.OS_FAMILY_COLLECTION:
+      if os_family_item['name'] == os_family:
+        if JSON_EXTENDS in os_family_item:
+          return os_family_item[JSON_EXTENDS]
+        else:
+          return None
+
   @staticmethod
   @staticmethod
   def get_os_version():
   def get_os_version():
     """
     """
@@ -264,14 +277,9 @@ class OSCheck:
     """
     """
      Return true if it is so or false if not
      Return true if it is so or false if not
 
 
-     This is safe check for debian family, doesn't generate exception
+     This is safe check for ubuntu/debian families, doesn't generate exception
     """
     """
-    try:
-      if OSCheck.get_os_family() == OSConst.UBUNTU_FAMILY:
-        return True
-    except Exception:
-      pass
-    return False
+    return OSCheck.is_in_family(OSCheck.get_os_family(), OSConst.UBUNTU_FAMILY)
 
 
   @staticmethod
   @staticmethod
   def is_suse_family():
   def is_suse_family():
@@ -280,12 +288,7 @@ class OSCheck:
 
 
      This is safe check for suse family, doesn't generate exception
      This is safe check for suse family, doesn't generate exception
     """
     """
-    try:
-      if OSCheck.get_os_family() == OSConst.SUSE_FAMILY:
-        return True
-    except Exception:
-      pass
-    return False
+    return OSCheck.is_in_family(OSCheck.get_os_family(), OSConst.SUSE_FAMILY)
 
 
   @staticmethod
   @staticmethod
   def is_redhat_family():
   def is_redhat_family():
@@ -294,12 +297,16 @@ class OSCheck:
 
 
      This is safe check for redhat family, doesn't generate exception
      This is safe check for redhat family, doesn't generate exception
     """
     """
+    return OSCheck.is_in_family(OSCheck.get_os_family(), OSConst.REDHAT_FAMILY)
+  
+  @staticmethod
+  def is_in_family(current_family, family):
     try:
     try:
-      if OSCheck.get_os_family() == OSConst.REDHAT_FAMILY:
+      if current_family == family or OSCheck.get_os_family_parent(current_family) and OSCheck.is_in_family(OSCheck.get_os_family_parent(current_family), family):
         return True
         return True
     except Exception:
     except Exception:
       pass
       pass
-    return False
+    return False    
 
 
   @staticmethod
   @staticmethod
   def is_redhat7():
   def is_redhat7():

+ 10 - 3
ambari-common/src/main/python/ambari_commons/resources/os_family.json

@@ -21,13 +21,20 @@
       7
       7
     ]
     ]
   },
   },
-  "ubuntu": {
+  "debian": {
+    "extends" : "ubuntu",
     "distro": [
     "distro": [
-      "ubuntu",
       "debian"
       "debian"
     ],
     ],
     "versions": [
     "versions": [
-      7,
+      7
+    ]
+  },
+  "ubuntu": {
+    "distro": [
+      "ubuntu"
+    ],
+    "versions": [
       12
       12
     ]
     ]
   },
   },

+ 3 - 0
ambari-common/src/main/python/resource_management/core/providers/__init__.py

@@ -50,6 +50,9 @@ PROVIDERS = dict(
   ubuntu=dict(
   ubuntu=dict(
     Package="resource_management.core.providers.package.apt.AptProvider",
     Package="resource_management.core.providers.package.apt.AptProvider",
   ),
   ),
+  debian=dict(
+    Package="resource_management.core.providers.package.apt.AptProvider",
+  ),
   winsrv=dict(
   winsrv=dict(
     Service="resource_management.core.providers.windows.service.ServiceProvider",
     Service="resource_management.core.providers.windows.service.ServiceProvider",
     Execute="resource_management.core.providers.windows.system.ExecuteProvider",
     Execute="resource_management.core.providers.windows.system.ExecuteProvider",

+ 1 - 1
ambari-common/src/main/python/resource_management/core/system.py

@@ -94,7 +94,7 @@ class System(object):
     Return values:
     Return values:
     redhat, fedora, centos, oraclelinux, ascendos,
     redhat, fedora, centos, oraclelinux, ascendos,
     amazon, xenserver, oel, ovs, cloudlinux, slc, scientific, psbm,
     amazon, xenserver, oel, ovs, cloudlinux, slc, scientific, psbm,
-    ubuntu, ubuntu, sles, sled, opensuse, suse ... and others
+    debian, ubuntu, sles, sled, opensuse, suse ... and others
     
     
     In case cannot detect raises exception.
     In case cannot detect raises exception.
     """
     """

+ 1 - 0
ambari-common/src/main/python/resource_management/libraries/functions/__init__.py

@@ -39,6 +39,7 @@ from resource_management.libraries.functions.version import *
 from resource_management.libraries.functions.format_jvm_option import *
 from resource_management.libraries.functions.format_jvm_option import *
 from resource_management.libraries.functions.constants import *
 from resource_management.libraries.functions.constants import *
 from resource_management.libraries.functions.get_hdp_version import *
 from resource_management.libraries.functions.get_hdp_version import *
+from resource_management.libraries.functions.get_lzo_packages import *
 
 
 IS_WINDOWS = platform.system() == "Windows"
 IS_WINDOWS = platform.system() == "Windows"
 
 

+ 47 - 0
ambari-common/src/main/python/resource_management/libraries/functions/get_lzo_packages.py

@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Ambari Agent
+
+"""
+__all__ = ["get_lzo_packages"]
+
+from ambari_commons.os_check import OSCheck
+from resource_management.libraries.functions.version import compare_versions, format_hdp_stack_version
+from resource_management.libraries.functions.format import format
+
+def get_lzo_packages(stack_version_unformatted):
+  lzo_packages = ["hadoop-lzo"]
+ 
+  if OSCheck.is_redhat_family() or OSCheck.is_suse_family():
+    lzo_packages += ["lzo", "hadoop-lzo-native"]
+  elif  OSCheck.is_ubuntu_family():
+    lzo_packages += ["liblzo2-2"]
+    
+  underscored_version = stack_version_unformatted.replace('.', '_')
+  dashed_version = stack_version_unformatted.replace('.', '-')
+  hdp_stack_version = format_hdp_stack_version(stack_version_unformatted)
+
+  if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
+    if OSCheck.is_redhat_family() or OSCheck.is_suse_family():
+      lzo_packages += [format("hadooplzo_{underscored_version}_*")]
+    elif OSCheck.is_ubuntu_family():
+      lzo_packages += [format("hadooplzo_{dashed_version}_*")]
+
+  return lzo_packages
+  

+ 6 - 6
ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py

@@ -89,16 +89,16 @@ def allInstalledPackages(allInstalledPackages):
   """
   """
   osType = OSCheck.get_os_family()
   osType = OSCheck.get_os_family()
 
 
-  if osType == OSConst.SUSE_FAMILY:
+  if OSCheck.is_suse_family():
     return _lookUpZypperPackages(
     return _lookUpZypperPackages(
       ["zypper", "search", "--installed-only", "--details"],
       ["zypper", "search", "--installed-only", "--details"],
       allInstalledPackages)
       allInstalledPackages)
-  elif osType == OSConst.REDHAT_FAMILY:
+  elif OSCheck.is_redhat_family():
     return _lookUpYumPackages(
     return _lookUpYumPackages(
       ["yum", "list", "installed"],
       ["yum", "list", "installed"],
       'Installed Packages',
       'Installed Packages',
       allInstalledPackages)
       allInstalledPackages)
-  elif osType == OSConst.UBUNTU_FAMILY:
+  elif OSCheck.is_ubuntu_family():
      return _lookUpAptPackages(
      return _lookUpAptPackages(
       LIST_INSTALLED_PACKAGES_UBUNTU,
       LIST_INSTALLED_PACKAGES_UBUNTU,
       allInstalledPackages)
       allInstalledPackages)
@@ -107,16 +107,16 @@ def allInstalledPackages(allInstalledPackages):
 def allAvailablePackages(allAvailablePackages):
 def allAvailablePackages(allAvailablePackages):
   osType = OSCheck.get_os_family()
   osType = OSCheck.get_os_family()
 
 
-  if osType == OSConst.SUSE_FAMILY:
+  if OSCheck.is_suse_family():
     return _lookUpZypperPackages(
     return _lookUpZypperPackages(
       ["zypper", "search", "--uninstalled-only", "--details"],
       ["zypper", "search", "--uninstalled-only", "--details"],
       allAvailablePackages)
       allAvailablePackages)
-  elif osType == OSConst.REDHAT_FAMILY:
+  elif OSCheck.is_redhat_family():
     return _lookUpYumPackages(
     return _lookUpYumPackages(
       ["yum", "list", "available"],
       ["yum", "list", "available"],
       'Available Packages',
       'Available Packages',
       allAvailablePackages)
       allAvailablePackages)
-  elif osType == OSConst.UBUNTU_FAMILY:
+  elif OSCheck.is_ubuntu_family():
      return _lookUpAptPackages(
      return _lookUpAptPackages(
       LIST_AVAILABLE_PACKAGES_UBUNTU,
       LIST_AVAILABLE_PACKAGES_UBUNTU,
       allAvailablePackages)
       allAvailablePackages)

+ 3 - 0
ambari-common/src/main/python/resource_management/libraries/providers/__init__.py

@@ -30,6 +30,9 @@ PROVIDERS = dict(
   ubuntu=dict(
   ubuntu=dict(
     Repository="resource_management.libraries.providers.repository.UbuntuRepositoryProvider",
     Repository="resource_management.libraries.providers.repository.UbuntuRepositoryProvider",
   ),
   ),
+  debian=dict(
+    Repository="resource_management.libraries.providers.repository.UbuntuRepositoryProvider",
+  ),
   winsrv=dict(
   winsrv=dict(
     Msi="resource_management.libraries.providers.msi.MsiProvider"
     Msi="resource_management.libraries.providers.msi.MsiProvider"
   ),
   ),

+ 2 - 1
ambari-common/src/main/python/resource_management/libraries/providers/monitor_webserver.py

@@ -25,6 +25,7 @@ from resource_management.core.providers import Provider
 from resource_management.libraries.functions.format import format
 from resource_management.libraries.functions.format import format
 from resource_management.core.shell import as_sudo
 from resource_management.core.shell import as_sudo
 from resource_management.core.system import System
 from resource_management.core.system import System
+from ambari_commons.os_check import OSCheck
 
 
 
 
 class MonitorWebserverProvider(Provider):
 class MonitorWebserverProvider(Provider):
@@ -49,7 +50,7 @@ class MonitorWebserverProvider(Provider):
 
 
   def get_serivice_params(self):
   def get_serivice_params(self):
     self.system = System.get_instance()
     self.system = System.get_instance()
-    if self.system.os_family in ["suse","ubuntu"]:
+    if OSCheck.is_suse_family() or OSCheck.is_ubuntu_family():
       self.service_name = "apache2"
       self.service_name = "apache2"
       self.httpd_conf_dir = '/etc/apache2'
       self.httpd_conf_dir = '/etc/apache2'
     else:
     else:

+ 7 - 7
ambari-common/src/main/python/resource_management/libraries/providers/repository.py

@@ -38,7 +38,7 @@ class RhelSuseRepositoryProvider(Provider):
   def action_create(self):
   def action_create(self):
     with Environment.get_instance_copy() as env:
     with Environment.get_instance_copy() as env:
       repo_file_name = self.resource.repo_file_name
       repo_file_name = self.resource.repo_file_name
-      repo_dir = repos_dirs[env.system.os_family]
+      repo_dir = get_repo_dir()
       repo_template = self.resource.repo_template
       repo_template = self.resource.repo_template
       new_content = Template(repo_template, repo_id=self.resource.repo_id, repo_file_name=self.resource.repo_file_name,
       new_content = Template(repo_template, repo_id=self.resource.repo_id, repo_file_name=self.resource.repo_file_name,
                              base_url=self.resource.base_url, mirror_list=self.resource.mirror_list)
                              base_url=self.resource.base_url, mirror_list=self.resource.mirror_list)
@@ -52,17 +52,17 @@ class RhelSuseRepositoryProvider(Provider):
   def action_remove(self):
   def action_remove(self):
     with Environment.get_instance_copy() as env:
     with Environment.get_instance_copy() as env:
       repo_file_name = self.resource.repo_file_name
       repo_file_name = self.resource.repo_file_name
-      repo_dir = repos_dirs[env.system.os_family]
+      repo_dir = get_repo_dir()
 
 
       File(format("{repo_dir}/{repo_file_name}.repo"),
       File(format("{repo_dir}/{repo_file_name}.repo"),
            action = "delete")
            action = "delete")
     
     
   
   
-repos_dirs = {
-  'redhat': '/etc/yum.repos.d',
-  'suse': '/etc/zypp/repos.d'
-}
-
+def get_repo_dir():
+  if OSCheck.is_redhat_family():
+    return '/etc/yum.repos.d'
+  elif OSCheck.is_suse_family():
+    return '/etc/zypp/repos.d'
 
 
 class UbuntuRepositoryProvider(Provider):
 class UbuntuRepositoryProvider(Provider):
   package_type = "deb"
   package_type = "deb"

+ 1 - 2
ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java

@@ -1143,10 +1143,9 @@ public class Configuration {
    * @return a string array of suffixes used to validate repo URLs.
    * @return a string array of suffixes used to validate repo URLs.
    */
    */
   public String[] getRepoValidationSuffixes(String osType) {
   public String[] getRepoValidationSuffixes(String osType) {
-    String osFamily = this.osFamily.find_family(osType);
     String repoSuffixes;
     String repoSuffixes;
 
 
-    if(osFamily.equals(OsFamily.UBUNTU_FAMILY)) {
+    if(osFamily.isUbuntuFamily(osType)) {
       repoSuffixes = properties.getProperty(REPO_SUFFIX_KEY_UBUNTU,
       repoSuffixes = properties.getProperty(REPO_SUFFIX_KEY_UBUNTU,
           REPO_SUFFIX_UBUNTU);
           REPO_SUFFIX_UBUNTU);
     } else {
     } else {

+ 49 - 0
ambari-server/src/main/java/org/apache/ambari/server/state/stack/JsonOsFamilyEntry.java

@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.state.stack;
+
+import java.util.Set;
+
+import com.google.gson.annotations.SerializedName;
+
+class JsonOsFamilyEntry {
+  @SerializedName("extends")
+  private String extendsFamily;
+  private Set<String> distro;
+
+  private Set<String> versions;
+  
+  public String getExtendsFamily() {
+    return extendsFamily;
+  }
+  public void setExtendsFamily(String extendsFamily) {
+    this.extendsFamily = extendsFamily;
+  }
+  public Set<String> getDistro() {
+    return distro;
+  }
+  public void setDistro(Set<String> distro) {
+    this.distro = distro;
+  }
+  public Set<String> getVersions() {
+    return versions;
+  }
+  public void setVersions(Set<String> versions) {
+    this.versions = versions;
+  }
+}

+ 1 - 2
ambari-server/src/main/java/org/apache/ambari/server/state/stack/LatestRepoCallable.java

@@ -108,9 +108,8 @@ public class LatestRepoCallable implements Callable<Void> {
               // Agents do the reverse action (take the base url, and append <name>.repo)
               // Agents do the reverse action (take the base url, and append <name>.repo)
 
 
               String repo_file_format;
               String repo_file_format;
-              String osFamily = os_family.find_family(ri.getOsType());
               
               
-              if(osFamily.equals(OsFamily.UBUNTU_FAMILY)) {
+              if(os_family.isUbuntuFamily(ri.getOsType())) {
                 repo_file_format = "list";
                 repo_file_format = "list";
               } else {
               } else {
                 repo_file_format = "repo";
                 repo_file_format = "repo";

+ 41 - 15
ambari-server/src/main/java/org/apache/ambari/server/state/stack/OsFamily.java

@@ -25,8 +25,8 @@ import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 
 
-
 import com.google.inject.Singleton;
 import com.google.inject.Singleton;
+
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -41,7 +41,9 @@ import org.apache.commons.io.IOUtils;
  */
  */
 @Singleton
 @Singleton
 public class OsFamily {
 public class OsFamily {
-    public final static String UBUNTU_FAMILY = "ubuntu";
+    private final static String OS_FAMILY_UBUNTU = "ubuntu";
+    private final static String OS_FAMILY_SUSE = "suse";
+    private final static String OS_FAMILY_REDHAT = "redhat";
     
     
     private final String os_pattern = "([^\\d]*)([\\d]*)";
     private final String os_pattern = "([^\\d]*)([\\d]*)";
     private final String OS_DISTRO = "distro";
     private final String OS_DISTRO = "distro";
@@ -50,7 +52,7 @@ public class OsFamily {
     private final String FILE_NAME = "os_family.json";
     private final String FILE_NAME = "os_family.json";
     private final Logger LOG = LoggerFactory.getLogger(OsFamily.class);
     private final Logger LOG = LoggerFactory.getLogger(OsFamily.class);
 
 
-    private Map<String, Map<String, Set<String>>> osMap = null;
+    private Map<String, JsonOsFamilyEntry> osMap = null;
 
 
   /**
   /**
    * Initialize object
    * Initialize object
@@ -75,7 +77,7 @@ public class OsFamily {
         if (!f.exists()) throw new Exception();
         if (!f.exists()) throw new Exception();
         inputStream = new FileInputStream(f);
         inputStream = new FileInputStream(f);
 
 
-        Type type = new TypeToken<Map<String, Map<String, Set<String>>>>() {}.getType();
+        Type type = new TypeToken<Map<String, JsonOsFamilyEntry>>() {}.getType();
         Gson gson = new Gson();
         Gson gson = new Gson();
         osMap = gson.fromJson(new InputStreamReader(inputStream), type);
         osMap = gson.fromJson(new InputStreamReader(inputStream), type);
       } catch (Exception e) {
       } catch (Exception e) {
@@ -115,10 +117,10 @@ public class OsFamily {
     public Set<String> findTypes(String os) {
     public Set<String> findTypes(String os) {
       Map<String,String>  pos = parse_os(os);
       Map<String,String>  pos = parse_os(os);
       for ( String family : osMap.keySet()) {
       for ( String family : osMap.keySet()) {
-        Map<String, Set<String>> fam = osMap.get(family);
-        if (fam.get(OS_DISTRO).contains(pos.get(OS_DISTRO)) && fam.get(OS_VERSION).contains(pos.get(OS_VERSION))){
+        JsonOsFamilyEntry fam = osMap.get(family);
+        if (fam.getDistro().contains(pos.get(OS_DISTRO)) && fam.getVersions().contains(pos.get(OS_VERSION))){
           Set<String> data=new HashSet<String>();
           Set<String> data=new HashSet<String>();
-          for (String item: fam.get(OS_DISTRO)) data.add(item + pos.get(OS_VERSION));
+          for (String item: fam.getDistro()) data.add(item + pos.get(OS_VERSION));
             return Collections.unmodifiableSet(data);
             return Collections.unmodifiableSet(data);
         }
         }
       }
       }
@@ -133,8 +135,8 @@ public class OsFamily {
     public String find(String os) {
     public String find(String os) {
       Map<String,String>  pos = parse_os(os);
       Map<String,String>  pos = parse_os(os);
       for ( String family : osMap.keySet()) {
       for ( String family : osMap.keySet()) {
-        Map<String, Set<String>> fam = osMap.get(family);
-        if (fam.get(OS_DISTRO).contains(pos.get(OS_DISTRO)) && fam.get(OS_VERSION).contains(pos.get(OS_VERSION))){
+        JsonOsFamilyEntry fam = osMap.get(family);
+        if (fam.getDistro().contains(pos.get(OS_DISTRO)) && fam.getVersions().contains(pos.get(OS_VERSION))){
           return family + pos.get(OS_VERSION);
           return family + pos.get(OS_VERSION);
         }
         }
       }
       }
@@ -149,14 +151,13 @@ public class OsFamily {
     public String find_family(String os) {
     public String find_family(String os) {
       Map<String,String>  pos = parse_os(os);
       Map<String,String>  pos = parse_os(os);
       for ( String family : osMap.keySet()) {
       for ( String family : osMap.keySet()) {
-        Map<String, Set<String>> fam = osMap.get(family);
-        if (fam.get(OS_DISTRO).contains(pos.get(OS_DISTRO)) && fam.get(OS_VERSION).contains(pos.get(OS_VERSION))){
+        JsonOsFamilyEntry fam = osMap.get(family);
+        if (fam.getDistro().contains(pos.get(OS_DISTRO)) && fam.getVersions().contains(pos.get(OS_VERSION))){
           return family;
           return family;
         }
         }
       }
       }
       return null;
       return null;
     }
     }
-
     /**
     /**
      * Form list of all supported os types
      * Form list of all supported os types
      * @return one dimension list with os types
      * @return one dimension list with os types
@@ -164,13 +165,38 @@ public class OsFamily {
     public Set<String> os_list(){
     public Set<String> os_list(){
       Set<String> r= new HashSet<String>();
       Set<String> r= new HashSet<String>();
       for ( String family : osMap.keySet()) {
       for ( String family : osMap.keySet()) {
-        Map<String, Set<String>> fam = osMap.get(family);
-        for (String version: fam.get(OS_VERSION)){
+        JsonOsFamilyEntry fam = osMap.get(family);
+        for (String version: fam.getVersions()){
           Set<String> data=new HashSet<String>();
           Set<String> data=new HashSet<String>();
-          for (String item: fam.get(OS_DISTRO)) data.add(item + version);
+          for (String item: fam.getDistro()) data.add(item + version);
           r.addAll(data);
           r.addAll(data);
         }
         }
       }
       }
       return r;
       return r;
     }
     }
+    
+    public boolean isUbuntuFamily(String osType) {
+      return isOsInFamily(osType, OS_FAMILY_UBUNTU);
+    }
+    
+    public boolean isSuseFamily(String osType) {
+      return isOsInFamily(osType, OS_FAMILY_SUSE);
+    }
+    
+    public boolean isRedhatFamily(String osType) {
+      return isOsInFamily(osType, OS_FAMILY_REDHAT);
+    }
+
+    public boolean isOsInFamily(String osType, String osFamily) {
+      String familyOfOsType = find_family(osType);
+      return (familyOfOsType != null && isFamilyExtendedByFamily(familyOfOsType, osFamily));
+    }
+
+    private boolean isFamilyExtendedByFamily(String currentFamily, String family) {
+      return (currentFamily.equals(family) || getOsFamilyParent(currentFamily)!=null && isFamilyExtendedByFamily(getOsFamilyParent(currentFamily), family));
+    }
+      
+    private String getOsFamilyParent(String osFamily) {
+      return osMap.get(osFamily).getExtendsFamily();
+    }
 }
 }

+ 4 - 4
ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py

@@ -35,7 +35,7 @@ from ambari_server.dbConfiguration import DBMSConfig, USERNAME_PATTERN, SETUP_DB
     SETUP_DB_CONNECT_TIMEOUT, STORAGE_TYPE_LOCAL, DEFAULT_USERNAME, DEFAULT_PASSWORD
     SETUP_DB_CONNECT_TIMEOUT, STORAGE_TYPE_LOCAL, DEFAULT_USERNAME, DEFAULT_PASSWORD
 from ambari_server.serverConfiguration import encrypt_password, store_password_file, \
 from ambari_server.serverConfiguration import encrypt_password, store_password_file, \
     get_ambari_properties, get_resources_location, get_value_from_properties, configDefaults, \
     get_ambari_properties, get_resources_location, get_value_from_properties, configDefaults, \
-    OS_TYPE, OS_FAMILY, AMBARI_PROPERTIES_FILE, RESOURCES_DIR_PROPERTY, \
+    OS_FAMILY, AMBARI_PROPERTIES_FILE, RESOURCES_DIR_PROPERTY, \
     JDBC_DATABASE_PROPERTY, JDBC_DATABASE_NAME_PROPERTY, JDBC_POSTGRES_SCHEMA_PROPERTY, \
     JDBC_DATABASE_PROPERTY, JDBC_DATABASE_NAME_PROPERTY, JDBC_POSTGRES_SCHEMA_PROPERTY, \
     JDBC_HOSTNAME_PROPERTY, JDBC_PORT_PROPERTY, \
     JDBC_HOSTNAME_PROPERTY, JDBC_PORT_PROPERTY, \
     JDBC_USER_NAME_PROPERTY, JDBC_PASSWORD_PROPERTY, JDBC_PASSWORD_FILENAME, \
     JDBC_USER_NAME_PROPERTY, JDBC_PASSWORD_PROPERTY, JDBC_PASSWORD_FILENAME, \
@@ -347,7 +347,7 @@ class PGConfig(LinuxDBMSConfig):
     self._is_user_changed = False
     self._is_user_changed = False
 
 
     if self.persistence_type == STORAGE_TYPE_LOCAL:
     if self.persistence_type == STORAGE_TYPE_LOCAL:
-      PGConfig.PG_STATUS_RUNNING = get_postgre_running_status(OS_TYPE)
+      PGConfig.PG_STATUS_RUNNING = get_postgre_running_status()
       PGConfig.PG_HBA_DIR = get_postgre_hba_dir(OS_FAMILY)
       PGConfig.PG_HBA_DIR = get_postgre_hba_dir(OS_FAMILY)
 
 
       PGConfig.PG_HBA_CONF_FILE = os.path.join(PGConfig.PG_HBA_DIR, "pg_hba.conf")
       PGConfig.PG_HBA_CONF_FILE = os.path.join(PGConfig.PG_HBA_DIR, "pg_hba.conf")
@@ -537,7 +537,7 @@ class PGConfig(LinuxDBMSConfig):
       return pg_status, 0, out, err
       return pg_status, 0, out, err
     else:
     else:
       # run initdb only on non ubuntu systems as ubuntu does not have initdb cmd.
       # run initdb only on non ubuntu systems as ubuntu does not have initdb cmd.
-      if OS_TYPE != OSConst.OS_UBUNTU:
+      if not OSCheck.is_ubuntu_family():
         print "Running initdb: This may take upto a minute."
         print "Running initdb: This may take upto a minute."
         retcode, out, err = run_os_command(PGConfig.PG_INITDB_CMD)
         retcode, out, err = run_os_command(PGConfig.PG_INITDB_CMD)
         if retcode == 0:
         if retcode == 0:
@@ -549,7 +549,7 @@ class PGConfig(LinuxDBMSConfig):
                                    stdin=subprocess.PIPE,
                                    stdin=subprocess.PIPE,
                                    stderr=subprocess.PIPE
                                    stderr=subprocess.PIPE
         )
         )
-        if OS_TYPE == OSConst.OS_SUSE:
+        if OSCheck.is_suse_family():
           time.sleep(20)
           time.sleep(20)
           result = process.poll()
           result = process.poll()
           print_info_msg("Result of postgres start cmd: " + str(result))
           print_info_msg("Result of postgres start cmd: " + str(result))

+ 21 - 16
ambari-server/src/main/python/ambari_server/utils.py

@@ -30,9 +30,6 @@ from ambari_commons import OSConst,OSCheck
 # PostgreSQL settings
 # PostgreSQL settings
 PG_STATUS_RUNNING_DEFAULT = "running"
 PG_STATUS_RUNNING_DEFAULT = "running"
 PG_HBA_ROOT_DEFAULT = "/var/lib/pgsql/data"
 PG_HBA_ROOT_DEFAULT = "/var/lib/pgsql/data"
-PG_HBA_INIT_FILES = {'ubuntu': '/etc/postgresql',
-                     'redhat': '/etc/rc.d/init.d/postgresql',
-                     'suse': '/etc/init.d/postgresql'}
 
 
 #Environment
 #Environment
 ENV_PATH_DEFAULT = ['/bin', '/usr/bin', '/sbin', '/usr/sbin']  # default search path
 ENV_PATH_DEFAULT = ['/bin', '/usr/bin', '/sbin', '/usr/sbin']  # default search path
@@ -43,6 +40,16 @@ PROC_DIR = '/proc'
 PROC_CMDLINE = 'cmdline'
 PROC_CMDLINE = 'cmdline'
 PROC_EXEC = 'exe'
 PROC_EXEC = 'exe'
 
 
+def get_pg_hba_init_files():
+  if OSCheck.is_ubuntu_family():
+    return '/etc/postgresql'
+  elif OSCheck.is_redhat_family():
+    return '/etc/rc.d/init.d/postgresql'
+  elif OSCheck.is_suse_family():
+    return '/etc/init.d/postgresql'
+  else:
+    raise Exception("Unsupported OS family '{0}'".format(OSCheck.get_os_family()))
+
 
 
   # ToDo: move that function to common-functions
   # ToDo: move that function to common-functions
 def locate_file(filename, default=''):
 def locate_file(filename, default=''):
@@ -189,11 +196,10 @@ def get_ubuntu_pg_version():
   """
   """
   postgre_ver = ""
   postgre_ver = ""
 
 
-  if os.path.isdir(PG_HBA_INIT_FILES[
-    'ubuntu']):  # detect actual installed versions of PG and select a more new one
+  if os.path.isdir(get_pg_hba_init_files()):  # detect actual installed versions of PG and select a more new one
     postgre_ver = sorted(
     postgre_ver = sorted(
-      [fld for fld in os.listdir(PG_HBA_INIT_FILES[OSConst.UBUNTU_FAMILY]) if
-       os.path.isdir(os.path.join(PG_HBA_INIT_FILES[OSConst.UBUNTU_FAMILY], fld))],
+      [fld for fld in os.listdir(get_pg_hba_init_files()) if
+       os.path.isdir(os.path.join(get_pg_hba_init_files(), fld))],
       reverse=True)
       reverse=True)
     if len(postgre_ver) > 0:
     if len(postgre_ver) > 0:
       return postgre_ver[0]
       return postgre_ver[0]
@@ -206,21 +212,20 @@ def get_postgre_hba_dir(OS_FAMILY):
   1) /etc/rc.d/init.d/postgresql --> /etc/rc.d/init.d/postgresql-9.3
   1) /etc/rc.d/init.d/postgresql --> /etc/rc.d/init.d/postgresql-9.3
   2) /etc/init.d/postgresql --> /etc/init.d/postgresql-9.1
   2) /etc/init.d/postgresql --> /etc/init.d/postgresql-9.1
   """
   """
-  if OS_FAMILY == OSConst.UBUNTU_FAMILY:
+  if OSCheck.is_ubuntu_family():
     # Like: /etc/postgresql/9.1/main/
     # Like: /etc/postgresql/9.1/main/
-    return os.path.join(PG_HBA_INIT_FILES[OS_FAMILY], get_ubuntu_pg_version(),
+    return os.path.join(get_pg_hba_init_files(), get_ubuntu_pg_version(),
                         "main")
                         "main")
   elif OSCheck.is_redhat7():
   elif OSCheck.is_redhat7():
     return PG_HBA_ROOT_DEFAULT
     return PG_HBA_ROOT_DEFAULT
   else:
   else:
-    if not os.path.isfile(PG_HBA_INIT_FILES[OS_FAMILY]):
+    if not os.path.isfile(get_pg_hba_init_files()):
       # Link: /etc/init.d/postgresql --> /etc/init.d/postgresql-9.1
       # Link: /etc/init.d/postgresql --> /etc/init.d/postgresql-9.1
-      os.symlink(glob.glob(PG_HBA_INIT_FILES[OS_FAMILY] + '*')[0],
-                 PG_HBA_INIT_FILES[OS_FAMILY])
+      os.symlink(glob.glob(get_pg_hba_init_files() + '*')[0],
+                 get_pg_hba_init_files())
 
 
     # Get postgres_data location (default: /var/lib/pgsql/data)
     # Get postgres_data location (default: /var/lib/pgsql/data)
-    cmd = "alias exit=return; source " + PG_HBA_INIT_FILES[
-      OS_FAMILY] + " status &>/dev/null; echo $PGDATA"
+    cmd = "alias exit=return; source " + get_pg_hba_init_files() + " status &>/dev/null; echo $PGDATA"
     p = subprocess.Popen(cmd,
     p = subprocess.Popen(cmd,
                          stdout=subprocess.PIPE,
                          stdout=subprocess.PIPE,
                          stdin=subprocess.PIPE,
                          stdin=subprocess.PIPE,
@@ -234,9 +239,9 @@ def get_postgre_hba_dir(OS_FAMILY):
       return PG_HBA_ROOT_DEFAULT
       return PG_HBA_ROOT_DEFAULT
 
 
 
 
-def get_postgre_running_status(OS_FAMILY):
+def get_postgre_running_status():
   """Return postgre running status indicator"""
   """Return postgre running status indicator"""
-  if OS_FAMILY == OSConst.UBUNTU_FAMILY:
+  if OSCheck.is_ubuntu_family():
     return os.path.join(get_ubuntu_pg_version(), "main")
     return os.path.join(get_ubuntu_pg_version(), "main")
   else:
   else:
     return PG_STATUS_RUNNING_DEFAULT
     return PG_STATUS_RUNNING_DEFAULT

+ 10 - 24
ambari-server/src/main/python/bootstrap.py

@@ -33,6 +33,7 @@ import traceback
 import re
 import re
 from datetime import datetime
 from datetime import datetime
 from resource_management.core.shell import quote_bash_args
 from resource_management.core.shell import quote_bash_args
+from ambari_commons.os_check import OSCheck
 
 
 AMBARI_PASSPHRASE_VAR_NAME = "AMBARI_PASSPHRASE"
 AMBARI_PASSPHRASE_VAR_NAME = "AMBARI_PASSPHRASE"
 HOST_BOOTSTRAP_TIMEOUT = 300
 HOST_BOOTSTRAP_TIMEOUT = 300
@@ -164,7 +165,7 @@ class Bootstrap(threading.Thread):
     self.host_log = HostLog(log_file)
     self.host_log = HostLog(log_file)
     self.daemon = True
     self.daemon = True
 
 
-    if self.is_ubuntu():
+    if OSCheck.is_ubuntu_family():
       self.AMBARI_REPO_FILENAME = self.AMBARI_REPO_FILENAME + ".list"
       self.AMBARI_REPO_FILENAME = self.AMBARI_REPO_FILENAME + ".list"
     else:
     else:
       self.AMBARI_REPO_FILENAME = self.AMBARI_REPO_FILENAME + ".repo"
       self.AMBARI_REPO_FILENAME = self.AMBARI_REPO_FILENAME + ".repo"
@@ -192,26 +193,16 @@ class Bootstrap(threading.Thread):
     def _call(*args, **kwargs):
     def _call(*args, **kwargs):
       self(obj, *args, **kwargs)
       self(obj, *args, **kwargs)
     return _call
     return _call
-
-  def is_suse(self):
-    if os.path.isfile("/etc/issue"):
-      if "suse" in open("/etc/issue").read().lower():
-        return True
-    return False
-
-  def is_ubuntu(self):
-    if self.getServerFamily()[0] == "ubuntu":
-      return True
-    return False
-
+  
   def getRepoDir(self):
   def getRepoDir(self):
-    """ Ambari repo file for Ambari."""
-    if self.is_suse():
+    if OSCheck.is_redhat_family():
+      return "/etc/yum.repos.d"
+    elif OSCheck.is_suse_family():
       return "/etc/zypp/repos.d"
       return "/etc/zypp/repos.d"
-    elif self.is_ubuntu():
+    elif OSCheck.is_ubuntu_family():
       return "/etc/apt/sources.list.d"
       return "/etc/apt/sources.list.d"
     else:
     else:
-      return "/etc/yum.repos.d"
+      raise Exception("Unsupported OS family '{0}'".format(OSCheck.get_os_family()))
 
 
 
 
   def getRepoFile(self):
   def getRepoFile(self):
@@ -325,7 +316,7 @@ class Bootstrap(threading.Thread):
     self.host_log.write("\n")
     self.host_log.write("\n")
 
 
     # Update repo cache for ubuntu OS
     # Update repo cache for ubuntu OS
-    if self.is_ubuntu():
+    if OSCheck.is_ubuntu_family():
       self.host_log.write("==========================\n")
       self.host_log.write("==========================\n")
       self.host_log.write("Update apt cache of repository...")
       self.host_log.write("Update apt cache of repository...")
       command = self.getAptUpdateCommand()
       command = self.getAptUpdateCommand()
@@ -430,17 +421,12 @@ class Bootstrap(threading.Thread):
       doneFile.write(str(retcode))
       doneFile.write(str(retcode))
       doneFile.close()
       doneFile.close()
 
 
-  def getServerFamily(self):
-    '''Return server OS family and version'''
-    cot = re.search("([^\d]+)([\d]*)", self.shared_state.cluster_os_type)
-    return cot.group(1).lower(),cot.group(2).lower()
-
   def checkSudoPackage(self):
   def checkSudoPackage(self):
     """ Checking 'sudo' package on remote host """
     """ Checking 'sudo' package on remote host """
     self.host_log.write("==========================\n")
     self.host_log.write("==========================\n")
     self.host_log.write("Checking 'sudo' package on remote host...")
     self.host_log.write("Checking 'sudo' package on remote host...")
     params = self.shared_state
     params = self.shared_state
-    if self.getServerFamily()[0] == "ubuntu":
+    if OSCheck.is_ubuntu_family():
       command = "dpkg --get-selections|grep -e '^sudo\s*install'"
       command = "dpkg --get-selections|grep -e '^sudo\s*install'"
     else:
     else:
       command = "rpm -qa | grep -e '^sudo\-'"
       command = "rpm -qa | grep -e '^sudo\-'"

+ 2 - 1
ambari-server/src/main/resources/common-services/GANGLIA/3.5.0/package/scripts/functions.py

@@ -16,10 +16,11 @@
 # under the License.
 # under the License.
 #
 #
 from resource_management import *
 from resource_management import *
+from ambari_commons.os_check import OSCheck
 
 
 
 
 def turn_off_autostart(service):
 def turn_off_autostart(service):
-  if System.get_instance().os_family == "ubuntu":
+  if OSCheck.is_ubuntu_family():
     Execute(('update-rc.d', service, 'disable'),
     Execute(('update-rc.d', service, 'disable'),
             path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
             path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
             sudo = True
             sudo = True

+ 2 - 1
ambari-server/src/main/resources/common-services/GANGLIA/3.5.0/package/scripts/ganglia_server.py

@@ -24,6 +24,7 @@ from ganglia import generate_daemon
 import ganglia
 import ganglia
 import functions
 import functions
 import ganglia_server_service
 import ganglia_server_service
+from ambari_commons.os_check import OSCheck
 
 
 
 
 class GangliaServer(Script):
 class GangliaServer(Script):
@@ -114,7 +115,7 @@ def server_files():
             recursive=True
             recursive=True
   )
   )
   
   
-  if System.get_instance().os_family in ["ubuntu","suse"]:
+  if OSCheck.is_suse_family() or OSCheck.is_ubuntu_family():
     File( params.ganglia_apache_config_file,
     File( params.ganglia_apache_config_file,
       content = Template("ganglia.conf.j2"),
       content = Template("ganglia.conf.j2"),
       mode = 0644
       mode = 0644

+ 5 - 4
ambari-server/src/main/resources/common-services/GANGLIA/3.5.0/package/scripts/params.py

@@ -18,6 +18,7 @@ limitations under the License.
 
 
 from resource_management import *
 from resource_management import *
 from resource_management.core.system import System
 from resource_management.core.system import System
+from ambari_commons.os_check import OSCheck
 import os
 import os
 
 
 config = Script.get_config()
 config = Script.get_config()
@@ -42,7 +43,7 @@ for x in gmond_app_strs:
   a,b = x.strip().split(':')
   a,b = x.strip().split(':')
   gmond_apps.append((a.strip(),b.strip()))
   gmond_apps.append((a.strip(),b.strip()))
 
 
-if System.get_instance().os_family == "ubuntu":
+if OSCheck.is_ubuntu_family():
   gmond_service_name = "ganglia-monitor"
   gmond_service_name = "ganglia-monitor"
   modules_dir = "/usr/lib/ganglia"
   modules_dir = "/usr/lib/ganglia"
 else:
 else:
@@ -145,7 +146,7 @@ if len(gmond_apps) > 0:
 
 
 ganglia_apache_config_file = "/etc/apache2/conf.d/ganglia.conf"
 ganglia_apache_config_file = "/etc/apache2/conf.d/ganglia.conf"
 ganglia_web_path="/var/www/html/ganglia"
 ganglia_web_path="/var/www/html/ganglia"
-if System.get_instance().os_family == "suse":
+if OSCheck.is_suse_family():
   rrd_py_path = '/srv/www/cgi-bin'
   rrd_py_path = '/srv/www/cgi-bin'
   dwoo_path = '/var/lib/ganglia-web/dwoo'
   dwoo_path = '/var/lib/ganglia-web/dwoo'
   web_user = "wwwrun"
   web_user = "wwwrun"
@@ -153,11 +154,11 @@ if System.get_instance().os_family == "suse":
   if not os.path.exists(ganglia_web_path):
   if not os.path.exists(ganglia_web_path):
     ganglia_web_path='/srv/www/htdocs/ganglia'
     ganglia_web_path='/srv/www/htdocs/ganglia'
 
 
-elif  System.get_instance().os_family == "redhat":
+elif OSCheck.is_redhat_family():
   rrd_py_path = '/var/www/cgi-bin'
   rrd_py_path = '/var/www/cgi-bin'
   dwoo_path = '/var/lib/ganglia/dwoo'
   dwoo_path = '/var/lib/ganglia/dwoo'
   web_user = "apache"
   web_user = "apache"
-elif  System.get_instance().os_family == "ubuntu":
+elif OSCheck.is_ubuntu_family():
   rrd_py_path = '/usr/lib/cgi-bin'
   rrd_py_path = '/usr/lib/cgi-bin'
   ganglia_web_path = '/usr/share/ganglia-webfrontend'
   ganglia_web_path = '/usr/share/ganglia-webfrontend'
   dwoo_path = '/var/lib/ganglia/dwoo'
   dwoo_path = '/var/lib/ganglia/dwoo'

+ 2 - 3
ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs.py

@@ -79,6 +79,5 @@ def hdfs(name=None):
        content=Template("slaves.j2")
        content=Template("slaves.j2")
   )
   )
   
   
-  if params.lzo_enabled:
-    if len(params.lzo_packages_for_current_host) > 0:
-      Package(params.lzo_packages_for_current_host)
+  if params.lzo_enabled and len(params.lzo_packages) > 0:
+      Package(params.lzo_packages)

+ 4 - 20
ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params.py

@@ -18,6 +18,7 @@ limitations under the License.
 """
 """
 
 
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
+from ambari_commons.os_check import OSCheck
 from resource_management.libraries.functions.default import default
 from resource_management.libraries.functions.default import default
 from resource_management import *
 from resource_management import *
 import status_params
 import status_params
@@ -269,28 +270,11 @@ HdfsDirectory = functools.partial(
 # The logic for LZO also exists in OOZIE's params.py
 # The logic for LZO also exists in OOZIE's params.py
 io_compression_codecs = default("/configurations/core-site/io.compression.codecs", None)
 io_compression_codecs = default("/configurations/core-site/io.compression.codecs", None)
 lzo_enabled = io_compression_codecs is not None and "com.hadoop.compression.lzo" in io_compression_codecs.lower()
 lzo_enabled = io_compression_codecs is not None and "com.hadoop.compression.lzo" in io_compression_codecs.lower()
-
-# stack_is_hdp22_or_further
-underscored_version = stack_version_unformatted.replace('.', '_')
-dashed_version = stack_version_unformatted.replace('.', '-')
-lzo_packages_to_family = {
-  "any": ["hadoop-lzo", ],
-  "redhat": ["lzo", "hadoop-lzo-native"],
-  "suse": ["lzo", "hadoop-lzo-native"],
-  "ubuntu": ["liblzo2-2", ]
-}
-
-if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
-  lzo_packages_to_family["redhat"] += [format("hadooplzo_{underscored_version}_*")]
-  lzo_packages_to_family["suse"] += [format("hadooplzo_{underscored_version}_*")]
-  lzo_packages_to_family["ubuntu"] += [format("hadooplzo_{dashed_version}_*")]
-
-lzo_packages_for_current_host = lzo_packages_to_family['any'] + lzo_packages_to_family[System.get_instance().os_family]
-all_lzo_packages = set(itertools.chain(*lzo_packages_to_family.values()))
+lzo_packages = get_lzo_packages(stack_version_unformatted)
 
 
 exclude_packages = []
 exclude_packages = []
 if not lzo_enabled:
 if not lzo_enabled:
-  exclude_packages += all_lzo_packages
+  exclude_packages += lzo_packages
   
   
 name_node_params = default("/commandParams/namenode", None)
 name_node_params = default("/commandParams/namenode", None)
 
 
@@ -300,7 +284,7 @@ hadoop_env_sh_template = config['configurations']['hadoop-env']['content']
 #hadoop-env.sh
 #hadoop-env.sh
 java_home = config['hostLevelParams']['java_home']
 java_home = config['hostLevelParams']['java_home']
 
 
-if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.1') < 0 and System.get_instance().os_family != "suse":
+if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.1') < 0 and not OSCheck.is_suse_family():
   # deprecated rhel jsvc_path
   # deprecated rhel jsvc_path
   jsvc_path = "/usr/libexec/bigtop-utils"
   jsvc_path = "/usr/libexec/bigtop-utils"
 else:
 else:

+ 2 - 1
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params.py

@@ -19,6 +19,7 @@ limitations under the License.
 """
 """
 
 
 from ambari_commons.constants import AMBARI_SUDO_BINARY
 from ambari_commons.constants import AMBARI_SUDO_BINARY
+from ambari_commons.os_check import OSCheck
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
 from resource_management.libraries.functions.default import default
 from resource_management.libraries.functions.default import default
 from resource_management import *
 from resource_management import *
@@ -279,7 +280,7 @@ app_dir_files = {tez_local_api_jars:None}
 # Tez libraries
 # Tez libraries
 tez_lib_uris = default("/configurations/tez-site/tez.lib.uris", None)
 tez_lib_uris = default("/configurations/tez-site/tez.lib.uris", None)
 
 
-if System.get_instance().os_family == "ubuntu":
+if OSCheck.is_ubuntu_family():
   mysql_configname = '/etc/mysql/my.cnf'
   mysql_configname = '/etc/mysql/my.cnf'
 else:
 else:
   mysql_configname = '/etc/my.cnf'
   mysql_configname = '/etc/my.cnf'

+ 2 - 1
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/status_params.py

@@ -19,6 +19,7 @@ limitations under the License.
 """
 """
 
 
 from resource_management import *
 from resource_management import *
+from ambari_commons.os_check import OSCheck
 
 
 config = Script.get_config()
 config = Script.get_config()
 
 
@@ -31,7 +32,7 @@ hcat_pid_dir = config['configurations']['hive-env']['hcat_pid_dir'] #hcat_pid_di
 webhcat_pid_file = format('{hcat_pid_dir}/webhcat.pid')
 webhcat_pid_file = format('{hcat_pid_dir}/webhcat.pid')
 
 
 process_name = 'mysqld'
 process_name = 'mysqld'
-if System.get_instance().os_family == "suse" or System.get_instance().os_family == "ubuntu":
+if OSCheck.is_suse_family() or OSCheck.is_ubuntu_family():
   daemon_name = 'mysql'
   daemon_name = 'mysql'
 else:
 else:
   daemon_name = 'mysqld'
   daemon_name = 'mysqld'

+ 7 - 10
ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/kerberos_server.py

@@ -18,6 +18,7 @@ limitations under the License.
 """
 """
 
 
 from kerberos_common import *
 from kerberos_common import *
+from ambari_commons.os_check import OSCheck
 
 
 class KerberosServer(KerberosScript):
 class KerberosServer(KerberosScript):
   @staticmethod
   @staticmethod
@@ -81,18 +82,16 @@ class KerberosServer(KerberosScript):
 
 
 
 
   def start(self, env):
   def start(self, env):
-    os_family = System.get_instance().os_family
-
     # Attempt to reconfigure the service before starting
     # Attempt to reconfigure the service before starting
     self.configure(env)
     self.configure(env)
 
 
     # Create or update the administrator account
     # Create or update the administrator account
     KerberosScript.create_or_update_administrator_identity()
     KerberosScript.create_or_update_administrator_identity()
 
 
-    if os_family == "suse":
+    if OSCheck.is_suse_family():
       Execute('rckadmind start')
       Execute('rckadmind start')
       Execute('rckrb5kdc start')
       Execute('rckrb5kdc start')
-    elif os_family == 'ubuntu':
+    elif OSCheck.is_ubuntu_family():
       Execute('service krb5-kdc start')
       Execute('service krb5-kdc start')
       Execute('service krb5-admin-server start')
       Execute('service krb5-admin-server start')
     else:
     else:
@@ -100,12 +99,10 @@ class KerberosServer(KerberosScript):
       Execute('service kadmin start')
       Execute('service kadmin start')
 
 
   def stop(self, env):
   def stop(self, env):
-    os_family = System.get_instance().os_family
-
-    if os_family == "suse":
+    if OSCheck.is_suse_family():
       Execute('rckadmind stop')
       Execute('rckadmind stop')
       Execute('rckrb5kdc stop')
       Execute('rckrb5kdc stop')
-    elif os_family == 'ubuntu':
+    elif OSCheck.is_ubuntu_family():
       Execute('service krb5-kdc stop')
       Execute('service krb5-kdc stop')
       Execute('service krb5-admin-server stop')
       Execute('service krb5-admin-server stop')
     else:
     else:
@@ -124,14 +121,14 @@ class KerberosServer(KerberosScript):
   def status(self, env):
   def status(self, env):
     import params
     import params
 
 
-    if params.os_family == "suse":
+    if OSCheck.is_suse_family():
       try:
       try:
         Execute('checkproc `which krb5kdc`')
         Execute('checkproc `which krb5kdc`')
         Execute('checkproc `which kadmind`')
         Execute('checkproc `which kadmind`')
       except Fail as ex:
       except Fail as ex:
         raise ComponentIsNotRunning()
         raise ComponentIsNotRunning()
 
 
-    elif params.os_family == 'ubuntu':
+    elif OSCheck.is_ubuntu_family():
       check_process_status(params.kdamin_pid_path)
       check_process_status(params.kdamin_pid_path)
       check_process_status(params.krb5kdc_pid_path)
       check_process_status(params.krb5kdc_pid_path)
 
 

+ 3 - 4
ambari-server/src/main/resources/common-services/KERBEROS/1.10.3-10/package/scripts/params.py

@@ -19,16 +19,15 @@ limitations under the License.
 
 
 from resource_management import *
 from resource_management import *
 from utils import get_property_value, get_unstructured_data
 from utils import get_property_value, get_unstructured_data
-
-os_family = System.get_instance().os_family
+from ambari_commons.os_check import OSCheck
 
 
 krb5_conf_dir = '/etc'
 krb5_conf_dir = '/etc'
 krb5_conf_file = 'krb5.conf'
 krb5_conf_file = 'krb5.conf'
 krb5_conf_path = krb5_conf_dir + '/' + krb5_conf_file
 krb5_conf_path = krb5_conf_dir + '/' + krb5_conf_file
 
 
-if os_family == 'suse':
+if OSCheck.is_suse_family():
   kdc_conf_dir = '/var/lib/kerberos/krb5kdc'
   kdc_conf_dir = '/var/lib/kerberos/krb5kdc'
-elif os_family == 'ubuntu':
+elif OSCheck.is_ubuntu_family():
   kdc_conf_dir = '/etc/krb5kdc'
   kdc_conf_dir = '/etc/krb5kdc'
 else:
 else:
   kdc_conf_dir = '/var/kerberos/krb5kdc'
   kdc_conf_dir = '/var/kerberos/krb5kdc'

+ 2 - 2
ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py

@@ -182,8 +182,8 @@ def oozie_server_specific():
     Execute(format('{sudo} chown {oozie_user}:{user_group} {oozie_libext_dir}/falcon-oozie-el-extension-*.jar'),
     Execute(format('{sudo} chown {oozie_user}:{user_group} {oozie_libext_dir}/falcon-oozie-el-extension-*.jar'),
       not_if  = no_op_test,
       not_if  = no_op_test,
     )
     )
-  if params.lzo_enabled and len(params.lzo_packages_for_current_host) > 0:
-    Package(params.lzo_packages_for_current_host)
+  if params.lzo_enabled and len(params.all_lzo_packages) > 0:
+    Package(params.all_lzo_packages)
     Execute(format('{sudo} cp {hadoop_lib_home}/hadoop-lzo*.jar {oozie_lib_dir}'),
     Execute(format('{sudo} cp {hadoop_lib_home}/hadoop-lzo*.jar {oozie_lib_dir}'),
       not_if  = no_op_test,
       not_if  = no_op_test,
     )
     )

+ 2 - 16
ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py

@@ -19,6 +19,7 @@ limitations under the License.
 """
 """
 
 
 from ambari_commons.constants import AMBARI_SUDO_BINARY
 from ambari_commons.constants import AMBARI_SUDO_BINARY
+from resource_management import *
 from resource_management.core import System
 from resource_management.core import System
 from resource_management.libraries import Script
 from resource_management.libraries import Script
 from resource_management.libraries.functions import default
 from resource_management.libraries.functions import default
@@ -208,20 +209,5 @@ HdfsDirectory = functools.partial(
 # The logic for LZO also exists in HDFS' params.py
 # The logic for LZO also exists in HDFS' params.py
 io_compression_codecs = default("/configurations/core-site/io.compression.codecs", None)
 io_compression_codecs = default("/configurations/core-site/io.compression.codecs", None)
 lzo_enabled = io_compression_codecs is not None and "com.hadoop.compression.lzo" in io_compression_codecs.lower()
 lzo_enabled = io_compression_codecs is not None and "com.hadoop.compression.lzo" in io_compression_codecs.lower()
-# stack_is_hdp22_or_further
-underscored_version = stack_version_unformatted.replace('.', '_')
-dashed_version = stack_version_unformatted.replace('.', '-')
-lzo_packages_to_family = {
-  "any": ["hadoop-lzo", ],
-  "redhat": ["lzo", "hadoop-lzo-native"],
-  "suse": ["lzo", "hadoop-lzo-native"],
-  "ubuntu": ["liblzo2-2", ]
-}
 
 
-if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
-  lzo_packages_to_family["redhat"] += [format("hadooplzo_{underscored_version}_*")]
-  lzo_packages_to_family["suse"] += [format("hadooplzo_{underscored_version}_*")]
-  lzo_packages_to_family["ubuntu"] += [format("hadooplzo_{dashed_version}_*")]
-
-lzo_packages_for_current_host = lzo_packages_to_family['any'] + lzo_packages_to_family[System.get_instance().os_family]
-all_lzo_packages = set(itertools.chain(*lzo_packages_to_family.values()))
+all_lzo_packages = get_lzo_packages(stack_version_unformatted)

+ 2 - 1
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/after-INSTALL/scripts/params.py

@@ -21,6 +21,7 @@ from ambari_commons.constants import AMBARI_SUDO_BINARY
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
 from resource_management import *
 from resource_management import *
 from resource_management.core.system import System
 from resource_management.core.system import System
+from ambari_commons.os_check import OSCheck
 
 
 config = Script.get_config()
 config = Script.get_config()
 sudo = AMBARI_SUDO_BINARY
 sudo = AMBARI_SUDO_BINARY
@@ -48,7 +49,7 @@ hdfs_log_dir_prefix = config['configurations']['hadoop-env']['hdfs_log_dir_prefi
 hadoop_pid_dir_prefix = config['configurations']['hadoop-env']['hadoop_pid_dir_prefix']
 hadoop_pid_dir_prefix = config['configurations']['hadoop-env']['hadoop_pid_dir_prefix']
 hadoop_root_logger = config['configurations']['hadoop-env']['hadoop_root_logger']
 hadoop_root_logger = config['configurations']['hadoop-env']['hadoop_root_logger']
 
 
-if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.1') < 0 and System.get_instance().os_family != "suse":
+if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.1') < 0  and not OSCheck.is_suse_family():
   # deprecated rhel jsvc_path
   # deprecated rhel jsvc_path
   jsvc_path = "/usr/libexec/bigtop-utils"
   jsvc_path = "/usr/libexec/bigtop-utils"
 else:
 else:

+ 2 - 1
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py

@@ -18,6 +18,7 @@ limitations under the License.
 """
 """
 
 
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
+from ambari_commons.os_check import OSCheck
 from resource_management import *
 from resource_management import *
 import collections
 import collections
 import json
 import json
@@ -105,7 +106,7 @@ hdfs_log_dir_prefix = config['configurations']['hadoop-env']['hdfs_log_dir_prefi
 hadoop_pid_dir_prefix = config['configurations']['hadoop-env']['hadoop_pid_dir_prefix']
 hadoop_pid_dir_prefix = config['configurations']['hadoop-env']['hadoop_pid_dir_prefix']
 hadoop_root_logger = config['configurations']['hadoop-env']['hadoop_root_logger']
 hadoop_root_logger = config['configurations']['hadoop-env']['hadoop_root_logger']
 
 
-if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.1') < 0 and System.get_instance().os_family != "suse":
+if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.1') < 0 and not OSCheck.is_suse_family():
   # deprecated rhel jsvc_path
   # deprecated rhel jsvc_path
   jsvc_path = "/usr/libexec/bigtop-utils"
   jsvc_path = "/usr/libexec/bigtop-utils"
 else:
 else:

+ 2 - 1
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-INSTALL/scripts/repo_initialization.py

@@ -17,6 +17,7 @@ limitations under the License.
 
 
 """
 """
 from resource_management import *
 from resource_management import *
+from ambari_commons.os_check import OSCheck
 import json
 import json
 
 
 # components_lits = repoName + postfix
 # components_lits = repoName + postfix
@@ -51,7 +52,7 @@ def _alter_repo(action, repo_string, repo_template):
 
 
 def install_repos():
 def install_repos():
   import params
   import params
-  template = "repo_suse_rhel.j2" if System.get_instance().os_family in ["suse", "redhat"] else "repo_ubuntu.j2"
+  template = "repo_suse_rhel.j2" if OSCheck.is_suse_family() or OSCheck.is_redhat_family() else "repo_ubuntu.j2"
   _alter_repo("create", params.repo_info, template)
   _alter_repo("create", params.repo_info, template)
   if params.service_repo_info:
   if params.service_repo_info:
     _alter_repo("create", params.service_repo_info, template)
     _alter_repo("create", params.service_repo_info, template)

+ 2 - 1
ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/params.py

@@ -18,6 +18,7 @@ limitations under the License.
 """
 """
 
 
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
 from resource_management.libraries.functions.version import format_hdp_stack_version, compare_versions
+from ambari_commons.os_check import OSCheck
 from resource_management import *
 from resource_management import *
 from resource_management.core.system import System
 from resource_management.core.system import System
 import os
 import os
@@ -132,7 +133,7 @@ else:
 #hadoop-env.sh
 #hadoop-env.sh
 java_home = config['hostLevelParams']['java_home']
 java_home = config['hostLevelParams']['java_home']
 
 
-if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.1') < 0 and System.get_instance().os_family != "suse":
+if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.1') < 0 and not OSCheck.is_suse_family():
   # deprecated rhel jsvc_path
   # deprecated rhel jsvc_path
   jsvc_path = "/usr/libexec/bigtop-utils"
   jsvc_path = "/usr/libexec/bigtop-utils"
 else:
 else:

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/repos/repoinfo.xml

@@ -53,7 +53,7 @@
       <reponame>HDP-UTILS</reponame>
       <reponame>HDP-UTILS</reponame>
     </repo>
     </repo>
   </os>
   </os>
-  <os family="ubuntu7">
+  <os family="debian7">
     <repo>
     <repo>
       <baseurl>http://s3.amazonaws.com/dev.hortonworks.com/HDP/debian6/2.x/updates/2.3.0.0</baseurl>
       <baseurl>http://s3.amazonaws.com/dev.hortonworks.com/HDP/debian6/2.x/updates/2.3.0.0</baseurl>
       <repoid>HDP-2.3</repoid>
       <repoid>HDP-2.3</repoid>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/ACCUMULO/metainfo.xml

@@ -31,7 +31,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>accumulo-2-3-.*</name>
               <name>accumulo-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/FALCON/metainfo.xml

@@ -31,7 +31,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>falcon-2-3-.*</name>
               <name>falcon-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/FLUME/metainfo.xml

@@ -32,7 +32,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>flume-2-3-.*</name>
               <name>flume-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/HBASE/metainfo.xml

@@ -35,7 +35,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>hbase-2-3-.*</name>
               <name>hbase-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/HDFS/metainfo.xml

@@ -51,7 +51,7 @@
         </osSpecific>
         </osSpecific>
 
 
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>hadoop-2-3-.*-client</name>
               <name>hadoop-2-3-.*-client</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/HIVE/metainfo.xml

@@ -49,7 +49,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>hive-2-3-.*</name>
               <name>hive-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/KAFKA/metainfo.xml

@@ -31,7 +31,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>kafka-2-3-.*</name>
               <name>kafka-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/KNOX/metainfo.xml

@@ -31,7 +31,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>knox-2-3-.*</name>
               <name>knox-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/OOZIE/metainfo.xml

@@ -48,7 +48,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>oozie-2-3-.*</name>
               <name>oozie-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/metainfo.xml

@@ -39,7 +39,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>pig-2-3-.*</name>
               <name>pig-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/metainfo.xml

@@ -37,7 +37,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>ranger-2-3-.*-admin</name>
               <name>ranger-2-3-.*-admin</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/SLIDER/metainfo.xml

@@ -34,7 +34,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>slider-2-3-.*</name>
               <name>slider-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/SPARK/metainfo.xml

@@ -37,7 +37,7 @@
               </packages>
               </packages>
             </osSpecific>
             </osSpecific>
             <osSpecific>
             <osSpecific>
-              <osFamily>ubuntu7,ubuntu12</osFamily>
+              <osFamily>debian7,ubuntu12</osFamily>
               <packages>
               <packages>
                 <package>
                 <package>
                   <name>spark-2-3-.*</name>
                   <name>spark-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/SQOOP/metainfo.xml

@@ -39,7 +39,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>sqoop-2-3-.*</name>
               <name>sqoop-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/STORM/metainfo.xml

@@ -32,7 +32,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>storm-2-3-.*</name>
               <name>storm-2-3-.*</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/TEZ/metainfo.xml

@@ -32,7 +32,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>tez-2-3-.*</name>
               <name>tez-2-3-.*</name>

+ 2 - 2
ambari-server/src/main/resources/stacks/HDP/2.3/services/YARN/metainfo.xml

@@ -39,7 +39,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>hadoop-2-3-.*-yarn</name>
               <name>hadoop-2-3-.*-yarn</name>
@@ -65,7 +65,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>hadoop-2-3-.*-mapreduce</name>
               <name>hadoop-2-3-.*-mapreduce</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/ZOOKEEPER/metainfo.xml

@@ -31,7 +31,7 @@
           </packages>
           </packages>
         </osSpecific>
         </osSpecific>
         <osSpecific>
         <osSpecific>
-          <osFamily>ubuntu7,ubuntu12</osFamily>
+          <osFamily>debian7,ubuntu12</osFamily>
           <packages>
           <packages>
             <package>
             <package>
               <name>zookeeper-2-3-.*</name>
               <name>zookeeper-2-3-.*</name>

+ 37 - 24
ambari-server/src/test/python/TestBootstrap.py

@@ -25,6 +25,7 @@ import logging
 import tempfile
 import tempfile
 import pprint
 import pprint
 
 
+from ambari_commons.os_check import OSCheck
 from bootstrap import PBootstrap, Bootstrap, SharedState, HostLog, SCP, SSH
 from bootstrap import PBootstrap, Bootstrap, SharedState, HostLog, SCP, SSH
 from unittest import TestCase
 from unittest import TestCase
 from subprocess import Popen
 from subprocess import Popen
@@ -123,31 +124,22 @@ class TestBootstrap(TestCase):
     self.assertTrue(bootstrap_obj.generateRandomFileName(None) == bootstrap_obj.getUtime())
     self.assertTrue(bootstrap_obj.generateRandomFileName(None) == bootstrap_obj.getUtime())
 
 
 
 
-  @patch("os.path.isfile")
-  @patch("__builtin__.open")
-  def test_is_suse(self, open_mock, isfile_mock):
-    shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
-                               "setupAgentFile", "ambariServer", "centos6",
-                               None, "8440", "root")
-    bootstrap_obj = Bootstrap("hostname", shared_state)
-    isfile_mock.return_value = True
-    f = open_mock.return_value
-    f.read.return_value = " suse  "
-    self.assertTrue(bootstrap_obj.is_suse())
 
 
-
-  @patch.object(Bootstrap, "is_suse")
-  def test_getRepoDir(self, is_suse_mock):
+  @patch.object(OSCheck, "is_redhat_family")
+  @patch.object(OSCheck, "is_suse_family")
+  def test_getRepoDir(self, is_suse_family, is_redhat_family):
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                                "setupAgentFile", "ambariServer", "centos6",
                                "setupAgentFile", "ambariServer", "centos6",
                                None, "8440", "root")
                                None, "8440", "root")
     bootstrap_obj = Bootstrap("hostname", shared_state)
     bootstrap_obj = Bootstrap("hostname", shared_state)
     # Suse
     # Suse
-    is_suse_mock.return_value = True
+    is_redhat_family.return_value = False
+    is_suse_family.return_value = True
     res = bootstrap_obj.getRepoDir()
     res = bootstrap_obj.getRepoDir()
     self.assertEquals(res, "/etc/zypp/repos.d")
     self.assertEquals(res, "/etc/zypp/repos.d")
     # non-Suse
     # non-Suse
-    is_suse_mock.return_value = False
+    is_suse_family.return_value = False
+    is_redhat_family.return_value = True
     res = bootstrap_obj.getRepoDir()
     res = bootstrap_obj.getRepoDir()
     self.assertEquals(res, "/etc/yum.repos.d")
     self.assertEquals(res, "/etc/yum.repos.d")
 
 
@@ -389,10 +381,16 @@ class TestBootstrap(TestCase):
 
 
   @patch.object(Bootstrap, "getRemoteName")
   @patch.object(Bootstrap, "getRemoteName")
   @patch.object(Bootstrap, "hasPassword")
   @patch.object(Bootstrap, "hasPassword")
-  def test_getRepoFile(self, hasPassword_mock, getRemoteName_mock):
+  @patch.object(OSCheck, "is_suse_family")
+  @patch.object(OSCheck, "is_ubuntu_family")
+  @patch.object(OSCheck, "is_redhat_family")
+  def test_getRepoFile(self, is_redhat_family, is_ubuntu_family, is_suse_family, hasPassword_mock, getRemoteName_mock):
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                                "setupAgentFile", "ambariServer", "centos6",
                                "setupAgentFile", "ambariServer", "centos6",
                                None, "8440", "root")
                                None, "8440", "root")
+    is_redhat_family.return_value = True
+    is_ubuntu_family.return_value = False
+    is_suse_family.return_value = False
     bootstrap_obj = Bootstrap("hostname", shared_state)
     bootstrap_obj = Bootstrap("hostname", shared_state)
     # Without password
     # Without password
     hasPassword_mock.return_value = False
     hasPassword_mock.return_value = False
@@ -406,6 +404,9 @@ class TestBootstrap(TestCase):
     self.assertEquals(rf, "sudo -S mv RemoteName target/ambari.repo < RemoteName")
     self.assertEquals(rf, "sudo -S mv RemoteName target/ambari.repo < RemoteName")
 
 
 
 
+  @patch.object(OSCheck, "is_suse_family")
+  @patch.object(OSCheck, "is_ubuntu_family")
+  @patch.object(OSCheck, "is_redhat_family")
   @patch.object(Bootstrap, "getMoveRepoFileCommand")
   @patch.object(Bootstrap, "getMoveRepoFileCommand")
   @patch.object(Bootstrap, "getRepoDir")
   @patch.object(Bootstrap, "getRepoDir")
   @patch.object(Bootstrap, "getRepoFile")
   @patch.object(Bootstrap, "getRepoFile")
@@ -418,10 +419,13 @@ class TestBootstrap(TestCase):
   def test_copyNeededFiles(self, write_mock, ssh_run_mock, ssh_init_mock,
   def test_copyNeededFiles(self, write_mock, ssh_run_mock, ssh_init_mock,
                            scp_run_mock, scp_init_mock,
                            scp_run_mock, scp_init_mock,
                            getRemoteName_mock, getRepoFile_mock, getRepoDir,
                            getRemoteName_mock, getRepoFile_mock, getRepoDir,
-                           getMoveRepoFileCommand):
+                           getMoveRepoFileCommand, is_redhat_family, is_ubuntu_family, is_suse_family):
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                                "setupAgentFile", "ambariServer", "centos6",
                                "setupAgentFile", "ambariServer", "centos6",
                                None, "8440", "root")
                                None, "8440", "root")
+    is_redhat_family.return_value = True
+    is_ubuntu_family.return_value = False
+    is_suse_family.return_value = False
     bootstrap_obj = Bootstrap("hostname", shared_state)
     bootstrap_obj = Bootstrap("hostname", shared_state)
     getMoveRepoFileCommand.return_value = "MoveRepoFileCommand"
     getMoveRepoFileCommand.return_value = "MoveRepoFileCommand"
     getRepoDir.return_value  = "RepoDir"
     getRepoDir.return_value  = "RepoDir"
@@ -540,11 +544,13 @@ class TestBootstrap(TestCase):
       self.assertEqual(res, str(expected))
       self.assertEqual(res, str(expected))
     os.unlink(done_file)
     os.unlink(done_file)
 
 
-  @patch.object(Bootstrap, "getServerFamily")
+  @patch.object(OSCheck, "is_suse_family")
+  @patch.object(OSCheck, "is_ubuntu_family")
+  @patch.object(OSCheck, "is_redhat_family")
   @patch.object(SSH, "__init__")
   @patch.object(SSH, "__init__")
   @patch.object(SSH, "run")
   @patch.object(SSH, "run")
   @patch.object(HostLog, "write")
   @patch.object(HostLog, "write")
-  def test_checkSudoPackage(self, write_mock, run_mock, init_mock, server_family_mock):
+  def test_checkSudoPackage(self, write_mock, run_mock, init_mock, is_redhat_family, is_ubuntu_family, is_suse_family):
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                                "setupAgentFile", "ambariServer", "centos6",
                                "setupAgentFile", "ambariServer", "centos6",
                                None, "8440", "root")
                                None, "8440", "root")
@@ -552,25 +558,32 @@ class TestBootstrap(TestCase):
     expected = 42
     expected = 42
     init_mock.return_value = None
     init_mock.return_value = None
     run_mock.return_value = expected
     run_mock.return_value = expected
-    server_family_mock.return_value = ["centos", "6"]
+    is_redhat_family.return_value = True
+    is_ubuntu_family.return_value = False
+    is_suse_family.return_value = False
     res = bootstrap_obj.checkSudoPackage()
     res = bootstrap_obj.checkSudoPackage()
     self.assertEquals(res, expected)
     self.assertEquals(res, expected)
     command = str(init_mock.call_args[0][3])
     command = str(init_mock.call_args[0][3])
     self.assertEqual(command, "rpm -qa | grep -e '^sudo\-'")
     self.assertEqual(command, "rpm -qa | grep -e '^sudo\-'")
 
 
-  @patch.object(Bootstrap, "getServerFamily")
+  @patch.object(OSCheck, "is_suse_family")
+  @patch.object(OSCheck, "is_ubuntu_family")
+  @patch.object(OSCheck, "is_redhat_family")
   @patch.object(SSH, "__init__")
   @patch.object(SSH, "__init__")
   @patch.object(SSH, "run")
   @patch.object(SSH, "run")
   @patch.object(HostLog, "write")
   @patch.object(HostLog, "write")
-  def test_checkSudoPackageUbuntu(self, write_mock, run_mock, init_mock, server_family_mock):
+  def test_checkSudoPackageUbuntu(self, write_mock, run_mock, init_mock,
+                                  is_redhat_family, is_ubuntu_family, is_suse_family):
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
     shared_state = SharedState("root", "sshkey_file", "scriptDir", "bootdir",
                                "setupAgentFile", "ambariServer", "ubuntu12",
                                "setupAgentFile", "ambariServer", "ubuntu12",
                                None, "8440", "root")
                                None, "8440", "root")
+    is_redhat_family.return_value = False
+    is_ubuntu_family.return_value = True
+    is_suse_family.return_value = False
     bootstrap_obj = Bootstrap("hostname", shared_state)
     bootstrap_obj = Bootstrap("hostname", shared_state)
     expected = 42
     expected = 42
     init_mock.return_value = None
     init_mock.return_value = None
     run_mock.return_value = expected
     run_mock.return_value = expected
-    server_family_mock.return_value = ["ubuntu", "12"]
     res = bootstrap_obj.checkSudoPackage()
     res = bootstrap_obj.checkSudoPackage()
     self.assertEquals(res, expected)
     self.assertEquals(res, expected)
     command = str(init_mock.call_args[0][3])
     command = str(init_mock.call_args[0][3])

+ 14 - 44
ambari-server/src/test/python/TestUtils.py

@@ -20,7 +20,7 @@ import StringIO
 import sys
 import sys
 from unittest import TestCase
 from unittest import TestCase
 from mock.mock import patch, MagicMock
 from mock.mock import patch, MagicMock
-
+from ambari_commons.os_check import OSCheck
 
 
 utils = __import__('ambari_server.utils').utils
 utils = __import__('ambari_server.utils').utils
 
 
@@ -33,53 +33,23 @@ class TestUtils(TestCase):
     os_listdir_mock.return_value = ['8.4', '9.1']
     os_listdir_mock.return_value = ['8.4', '9.1']
 
 
     self.assertEqual('9.1', utils.get_ubuntu_pg_version())
     self.assertEqual('9.1', utils.get_ubuntu_pg_version())
-
-  @patch('ambari_server.utils.get_ubuntu_pg_version')
-  @patch('os.path.isfile')
-  @patch("subprocess.Popen")
-  def test_get_postgre_hba_dir(self, popenMock, os_path_is_fine_mock,
-                               get_ubuntu_pg_version_mock):
-    p = MagicMock()
-    utils.PG_HBA_INIT_FILES['ubuntu'] = '/tmp'
-    get_ubuntu_pg_version_mock.return_value = '9.1'
-    self.assertEqual('/tmp/9.1/main', utils.get_postgre_hba_dir('ubuntu'))
-
-    # ## Tests depends on postgres version ###
-    # 1) PGDATA=/var/lib/pgsql/data
-    os_path_is_fine_mock.return_value = True
-    utils.PG_HBA_ROOT_DEFAULT = '/def/dir'
-    p.communicate.return_value = ('/my/new/location\n', None)
-    p.returncode = 0
-    popenMock.return_value = p
-    self.assertEqual('/my/new/location', utils.get_postgre_hba_dir('redhat'))
-
-    # 2) No value set
-    os_path_is_fine_mock.return_value = True
-    utils.PG_HBA_ROOT_DEFAULT = '/def/dir'
-    p.communicate.return_value = ('\n', None)
-    p.returncode = 0
-    popenMock.return_value = p
-    self.assertEqual('/def/dir', utils.get_postgre_hba_dir('redhat'))
-
-    # 3) Value set - check diff systems
-    os_path_is_fine_mock.return_value = True
-    popenMock.reset()
-    p.communicate.return_value = (None, None)
-    utils.get_postgre_hba_dir('redhat')
-    popenMock.assert_called_with('alias exit=return; source /etc/rc.d/init.d/postgresql status &>/dev/null; echo $PGDATA', shell=True, stdin=-1, stderr=-1, stdout=-1)
-
-    popenMock.reset()
-    p.communicate.return_value = (None, None)
-    utils.get_postgre_hba_dir('suse')
-    popenMock.assert_called_with('alias exit=return; source /etc/init.d/postgresql status &>/dev/null; echo $PGDATA', shell=True, stdin=-1, stderr=-1, stdout=-1)
-
+    
+  @patch.object(OSCheck, "is_suse_family")
+  @patch.object(OSCheck, "is_ubuntu_family")
+  @patch.object(OSCheck, "is_redhat_family")
   @patch('ambari_server.utils.get_ubuntu_pg_version')
   @patch('ambari_server.utils.get_ubuntu_pg_version')
-  def test_get_postgre_running_status(self, get_ubuntu_pg_version_mock):
+  def test_get_postgre_running_status(self, get_ubuntu_pg_version_mock, is_redhat_family, is_ubuntu_family, is_suse_family):
+    is_redhat_family.return_value = False
+    is_ubuntu_family.return_value = True
+    is_suse_family.return_value = False
     utils.PG_STATUS_RUNNING_DEFAULT = "red_running"
     utils.PG_STATUS_RUNNING_DEFAULT = "red_running"
     get_ubuntu_pg_version_mock.return_value = '9.1'
     get_ubuntu_pg_version_mock.return_value = '9.1'
 
 
-    self.assertEqual('9.1/main', utils.get_postgre_running_status('ubuntu'))
-    self.assertEqual('red_running', utils.get_postgre_running_status('redhat'))
+    self.assertEqual('9.1/main', utils.get_postgre_running_status())
+    is_redhat_family.return_value = True
+    is_ubuntu_family.return_value = False
+    is_suse_family.return_value = False
+    self.assertEqual('red_running', utils.get_postgre_running_status())
 
 
   @patch('os.path.isfile')
   @patch('os.path.isfile')
   def test_locate_file(self, isfile_mock):
   def test_locate_file(self, isfile_mock):