Ejemplo n.º 1
0
 def os_type(self):
     """
 Return values:
 redhat, fedora, centos, oraclelinux, ascendos,
 amazon, xenserver, oel, ovs, cloudlinux, slc, scientific, psbm,
 debian, ubuntu, sles, sled, opensuse, suse ... and others
 
 In case cannot detect raises exception.
 """
     return OSCheck.get_os_type()
Ejemplo n.º 2
0
 def os_type(self):
   """
   Return values:
   redhat, fedora, centos, oraclelinux, ascendos,
   amazon, xenserver, oel, ovs, cloudlinux, slc, scientific, psbm,
   debian, ubuntu, sles, sled, opensuse, suse ... and others
   
   In case cannot detect raises exception.
   """
   return OSCheck.get_os_type()
Ejemplo n.º 3
0
    def test_aliases(self, mock_linux_distribution):
        OSConst.OS_TYPE_ALIASES['qwerty_os123'] = 'aliased_os5'
        OSConst.OS_FAMILY_COLLECTION.append({
            'name': 'aliased_os_family',
            'os_list': ["aliased_os"]
        })

        mock_linux_distribution.return_value = ('qwerty_os', '123.45.67', '')

        self.assertEquals(OSCheck.get_os_type(), 'aliased_os')
        self.assertEquals(OSCheck.get_os_major_version(), '5')
        self.assertEquals(OSCheck.get_os_version(), '5.45.67')
        self.assertEquals(OSCheck.get_os_family(), 'aliased_os_family')
Ejemplo n.º 4
0
 def test_aliases(self, mock_linux_distribution):
   OSConst.OS_TYPE_ALIASES['qwerty_os123'] = 'aliased_os5'
   OSConst.OS_FAMILY_COLLECTION.append({          
         'name': 'aliased_os_family',
         'os_list': ["aliased_os"]
   })
   
   mock_linux_distribution.return_value = ('qwerty_os', '123.45.67', '')
   
   self.assertEquals(OSCheck.get_os_type(), 'aliased_os')
   self.assertEquals(OSCheck.get_os_major_version(), '5')
   self.assertEquals(OSCheck.get_os_version(), '5.45.67')
   self.assertEquals(OSCheck.get_os_family(), 'aliased_os_family')
Ejemplo n.º 5
0
    def test_get_os_type(self, mock_is_oracle_linux, mock_linux_distribution):

        # 1 - Any system
        mock_is_oracle_linux.return_value = False
        mock_linux_distribution.return_value = ('my_os', '2015.09', '')
        result = OSCheck.get_os_type()
        self.assertEquals(result, 'my_os')

        # 2 - Negative case
        mock_linux_distribution.return_value = ('', 'aaaa', 'bbbbb')
        try:
            result = OSCheck.get_os_type()
            self.fail("Should throw exception in OSCheck.get_os_type()")
        except Exception as e:
            # Expected
            self.assertEquals("Cannot detect os type. Exiting...", str(e))
            pass

        # 3 - path exist: '/etc/oracle-release'
        mock_is_oracle_linux.return_value = True
        mock_linux_distribution.return_value = ('some_os', '1234', '')
        result = OSCheck.get_os_type()
        self.assertEquals(result, 'oraclelinux')

        # 4 - Common system
        mock_is_oracle_linux.return_value = False
        mock_linux_distribution.return_value = ('CenToS', '4.56', '')
        result = OSCheck.get_os_type()
        self.assertEquals(result, 'centos')

        # 5 - Red Hat Enterprise Linux
        mock_is_oracle_linux.return_value = False
        # Red Hat Enterprise Linux Server release 6.5 (Santiago)
        mock_linux_distribution.return_value = (
            'Red Hat Enterprise Linux Server', '6.5', 'Santiago')
        result = OSCheck.get_os_type()
        self.assertEquals(result, 'redhat')

        # Red Hat Enterprise Linux Workstation release 6.4 (Santiago)
        mock_linux_distribution.return_value = (
            'Red Hat Enterprise Linux Workstation', '6.4', 'Santiago')
        result = OSCheck.get_os_type()
        self.assertEquals(result, 'redhat')

        # Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
        mock_linux_distribution.return_value = ('Red Hat Enterprise Linux AS',
                                                '4', 'Nahant Update 3')
        result = OSCheck.get_os_type()
        self.assertEquals(result, 'redhat')
Ejemplo n.º 6
0
  def test_get_os_type(self, mock_exists, mock_linux_distribution):

    # 1 - Any system
    mock_exists.return_value = False
    mock_linux_distribution.return_value = ('my_os', '', '')
    result = OSCheck.get_os_type()
    self.assertEquals(result, 'my_os')

    # 2 - Negative case
    mock_linux_distribution.return_value = ('', 'aaaa', 'bbbbb')
    try:
      result = OSCheck.get_os_type()
      self.fail("Should throw exception in OSCheck.get_os_type()")
    except Exception as e:
      # Expected
      self.assertEquals("Cannot detect os type. Exiting...", str(e))
      pass

    # 3 - path exist: '/etc/oracle-release'
    mock_exists.return_value = True
    mock_linux_distribution.return_value = ('some_os', '', '')
    result = OSCheck.get_os_type()
    self.assertEquals(result, 'oraclelinux')

    # 4 - Common system
    mock_exists.return_value = False
    mock_linux_distribution.return_value = ('CenToS', '', '')
    result = OSCheck.get_os_type()
    self.assertEquals(result, 'centos')

    # 5 - Red Hat Enterprise Linux
    mock_exists.return_value = False
    # Red Hat Enterprise Linux Server release 6.5 (Santiago)
    mock_linux_distribution.return_value = ('Red Hat Enterprise Linux Server', '6.5', 'Santiago')
    result = OSCheck.get_os_type()
    self.assertEquals(result, 'redhat')

    # Red Hat Enterprise Linux Workstation release 6.4 (Santiago)
    mock_linux_distribution.return_value = ('Red Hat Enterprise Linux Workstation', '6.4', 'Santiago')
    result = OSCheck.get_os_type()
    self.assertEquals(result, 'redhat')

    # Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
    mock_linux_distribution.return_value = ('Red Hat Enterprise Linux AS', '4', 'Nahant Update 3')
    result = OSCheck.get_os_type()
    self.assertEquals(result, 'redhat')
Ejemplo n.º 7
0
    def test_get_os_type(self, mock_exists, mock_linux_distribution):

        # 1 - Any system
        mock_exists.return_value = False
        mock_linux_distribution.return_value = ("my_os", "", "")
        result = OSCheck.get_os_type()
        self.assertEquals(result, "my_os")

        # 2 - Negative case
        mock_linux_distribution.return_value = ("", "aaaa", "bbbbb")
        try:
            result = OSCheck.get_os_type()
            self.fail("Should throw exception in OSCheck.get_os_type()")
        except Exception as e:
            # Expected
            self.assertEquals("Cannot detect os type. Exiting...", str(e))
            pass

        # 3 - path exist: '/etc/oracle-release'
        mock_exists.return_value = True
        mock_linux_distribution.return_value = ("some_os", "", "")
        result = OSCheck.get_os_type()
        self.assertEquals(result, "oraclelinux")

        # 4 - Common system
        mock_exists.return_value = False
        mock_linux_distribution.return_value = ("CenToS", "", "")
        result = OSCheck.get_os_type()
        self.assertEquals(result, "centos")

        # 5 - Red Hat Enterprise Linux
        mock_exists.return_value = False
        # Red Hat Enterprise Linux Server release 6.5 (Santiago)
        mock_linux_distribution.return_value = ("Red Hat Enterprise Linux Server", "6.5", "Santiago")
        result = OSCheck.get_os_type()
        self.assertEquals(result, "redhat")

        # Red Hat Enterprise Linux Workstation release 6.4 (Santiago)
        mock_linux_distribution.return_value = ("Red Hat Enterprise Linux Workstation", "6.4", "Santiago")
        result = OSCheck.get_os_type()
        self.assertEquals(result, "redhat")

        # Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
        mock_linux_distribution.return_value = ("Red Hat Enterprise Linux AS", "4", "Nahant Update 3")
        result = OSCheck.get_os_type()
        self.assertEquals(result, "redhat")
Ejemplo n.º 8
0
 def getOperatingSystem(self):
   return OSCheck.get_os_type()
Ejemplo n.º 9
0
 def __init__(self):
     # OS info
     self.OS_VERSION = OSCheck().get_os_major_version()
     self.OS_TYPE = OSCheck.get_os_type()
     self.OS_FAMILY = OSCheck.get_os_family()
Ejemplo n.º 10
0
import time
import subprocess
import threading
import shlex
import platform
from PackagesAnalyzer import PackagesAnalyzer
from HostCheckReportFileHandler import HostCheckReportFileHandler
from Hardware import Hardware
from ambari_commons import OSCheck, OSConst
import socket

logger = logging.getLogger()

# OS info
OS_VERSION = OSCheck().get_os_major_version()
OS_TYPE = OSCheck.get_os_type()
OS_FAMILY = OSCheck.get_os_family()

# service cmd
SERVICE_CMD = "/sbin/service"

# on ubuntu iptables service is called ufw
if OS_FAMILY == OSConst.DEBIAN_FAMILY:
    SERVICE_CMD = "/usr/sbin/service"


class HostInfo:
    # List of project names to be used to find alternatives folders etc.
    DEFAULT_PROJECT_NAMES = [
        "hadoop*", "hadoop", "hbase", "hcatalog", "hive", "ganglia", "nagios",
        "oozie", "sqoop", "hue", "zookeeper", "mapred", "hdfs", "flume",
Ejemplo n.º 11
0
 def getOperatingSystem(self):
   return OSCheck.get_os_type()
Ejemplo n.º 12
0
 def __init__(self):
   # OS info
   self.OS_VERSION = OSCheck().get_os_major_version()
   self.OS_TYPE = OSCheck.get_os_type()
   self.OS_FAMILY = OSCheck.get_os_family()
Ejemplo n.º 13
0
import time
import subprocess
import threading
import shlex
import platform
from PackagesAnalyzer import PackagesAnalyzer
from HostCheckReportFileHandler import HostCheckReportFileHandler
from Hardware import Hardware
from ambari_commons import OSCheck, OSConst
import socket

logger = logging.getLogger()

# OS info
OS_VERSION = OSCheck().get_os_major_version()
OS_TYPE = OSCheck.get_os_type()
OS_FAMILY = OSCheck.get_os_family()

# service cmd
SERVICE_CMD = "/sbin/service"

# on ubuntu iptables service is called ufw
if OS_FAMILY == OSConst.DEBIAN_FAMILY:
  SERVICE_CMD = "/usr/sbin/service"


class HostInfo:
  # List of project names to be used to find alternatives folders etc.
  DEFAULT_PROJECT_NAMES = [
    "hadoop*", "hadoop", "hbase", "hcatalog", "hive", "ganglia", "nagios",
    "oozie", "sqoop", "hue", "zookeeper", "mapred", "hdfs", "flume",