예제 #1
0
  def test_analyze_yum_output(self, subprocessWithTimeout_mock, get_os_family_mock):
    get_os_family_mock.return_value = 'redhat'
    stringToRead = """Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager
                      Updating certificate-based repositories.
                      Installed Packages
                      AMBARI.dev.noarch             1.x-1.el6             installed
                      PyXML.x86_64                  0.8.4-19.el6          @koji-override-0
                      Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch
                              3-7.el6               @koji-override-0
                      hcatalog.noarch               0.11.0.1.3.0.0-107.el6
                                                    @HDP-1.3.0
                      hesiod.x86_64                 3.1.0-19.el6          @koji-override-0/$releasever
                      hive.noarch                   0.11.0.1.3.0.0-107.el6
                                                    @HDP-1.3.0
                      oracle-server-db.x86          1.3.17-2
                                                    @Oracle-11g
                      ambari-log4j.noarch           1.2.5.9-1             @AMBARI.dev-1.x
                      libconfuse.x86_64             2.7-4.el6             @HDP-epel"""
    result = {}
    result['out'] = stringToRead
    result['err'] = ""
    result['retCode'] = 0

    subprocessWithTimeout_mock.return_value = result
    installedPackages = []
    packages_analyzer.allInstalledPackages(installedPackages)
    self.assertEqual(9, len(installedPackages))
    for package in installedPackages:
      self.assertTrue(package[0] in ["AMBARI.dev.noarch", "PyXML.x86_64", "oracle-server-db.x86",
                                 "Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch",
                                 "hcatalog.noarch", "hesiod.x86_64", "hive.noarch", "ambari-log4j.noarch", "libconfuse.x86_64"])
      self.assertTrue(package[1] in ["1.x-1.el6", "0.8.4-19.el6", "3-7.el6", "3.1.0-19.el6",
                                 "0.11.0.1.3.0.0-107.el6", "1.2.5.9-1", "1.3.17-2", "1.2.5.9-1", "2.7-4.el6"])
      self.assertTrue(package[2] in ["installed", "koji-override-0", "HDP-1.3.0",
                                 "koji-override-0/$releasever", "AMBARI.dev-1.x", "Oracle-11g", "HDP-epel"])

    packages = packages_analyzer.getInstalledPkgsByNames(["AMBARI", "Red_Hat_Enterprise", "hesiod", "hive"],
                                                       installedPackages)
    self.assertEqual(4, len(packages))
    expected = ["AMBARI.dev.noarch", "Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch",
                                "hesiod.x86_64", "hive.noarch"]
    for package in expected:
      self.assertTrue(package in packages)

    detailedPackages = packages_analyzer.getPackageDetails(installedPackages, packages)
    self.assertEqual(4, len(detailedPackages))
    for package in detailedPackages:
      self.assertTrue(package['version'] in ["1.x-1.el6", "3-7.el6", "3.1.0-19.el6",
                                            "0.11.0.1.3.0.0-107.el6"])
      self.assertTrue(package['repoName'] in ["installed", "koji-override-0", "HDP-1.3.0",
                                              "koji-override-0/$releasever"])
      self.assertFalse(package['repoName'] in ["AMBARI.dev-1.x"])
예제 #2
0
  def test_analyze_yum_output(self, subprocessWithTimeout_mock, get_os_family_mock):
    get_os_family_mock.return_value = 'redhat'
    stringToRead = """Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager
                      Updating certificate-based repositories.
                      Installed Packages
                      AMBARI.dev.noarch             1.x-1.el6             installed
                      PyXML.x86_64                  0.8.4-19.el6          @koji-override-0
                      Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch
                              3-7.el6               @koji-override-0
                      hcatalog.noarch               0.11.0.1.3.0.0-107.el6
                                                    @HDP-1.3.0
                      hesiod.x86_64                 3.1.0-19.el6          @koji-override-0/$releasever
                      hive.noarch                   0.11.0.1.3.0.0-107.el6
                                                    @HDP-1.3.0
                      oracle-server-db.x86          1.3.17-2
                                                    @Oracle-11g
                      ambari-log4j.noarch           1.2.5.9-1             @AMBARI.dev-1.x
                      libconfuse.x86_64             2.7-4.el6             @HDP-epel"""
    result = {}
    result['out'] = stringToRead
    result['err'] = ""
    result['retCode'] = 0

    subprocessWithTimeout_mock.return_value = result
    installedPackages = []
    packages_analyzer.allInstalledPackages(installedPackages)
    self.assertEqual(9, len(installedPackages))
    for package in installedPackages:
      self.assertTrue(package[0] in ["AMBARI.dev.noarch", "PyXML.x86_64", "oracle-server-db.x86",
                                 "Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch",
                                 "hcatalog.noarch", "hesiod.x86_64", "hive.noarch", "ambari-log4j.noarch", "libconfuse.x86_64"])
      self.assertTrue(package[1] in ["1.x-1.el6", "0.8.4-19.el6", "3-7.el6", "3.1.0-19.el6",
                                 "0.11.0.1.3.0.0-107.el6", "1.2.5.9-1", "1.3.17-2", "1.2.5.9-1", "2.7-4.el6"])
      self.assertTrue(package[2] in ["installed", "koji-override-0", "HDP-1.3.0",
                                 "koji-override-0/$releasever", "AMBARI.dev-1.x", "Oracle-11g", "HDP-epel"])

    packages = packages_analyzer.getInstalledPkgsByNames(["AMBARI", "Red_Hat_Enterprise", "hesiod", "hive"],
                                                       installedPackages)
    self.assertEqual(4, len(packages))
    expected = ["AMBARI.dev.noarch", "Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch",
                                "hesiod.x86_64", "hive.noarch"]
    for package in expected:
      self.assertTrue(package in packages)

    detailedPackages = packages_analyzer.getPackageDetails(installedPackages, packages)
    self.assertEqual(4, len(detailedPackages))
    for package in detailedPackages:
      self.assertTrue(package['version'] in ["1.x-1.el6", "3-7.el6", "3.1.0-19.el6",
                                            "0.11.0.1.3.0.0-107.el6"])
      self.assertTrue(package['repoName'] in ["installed", "koji-override-0", "HDP-1.3.0",
                                              "koji-override-0/$releasever"])
      self.assertFalse(package['repoName'] in ["AMBARI.dev-1.x"])
예제 #3
0
파일: check_host.py 프로젝트: soener/ambari
  def execute_existing_repos_and_installed_packages_check(self, config):
      installedPackages = []
      availablePackages = []
      packages_analyzer.allInstalledPackages(installedPackages)
      packages_analyzer.allAvailablePackages(availablePackages)

      repos = []
      packages_analyzer.getInstalledRepos(self.PACKAGES, installedPackages + availablePackages,
                                      self.IGNORE_PACKAGES_FROM_REPOS, repos)
      packagesInstalled = packages_analyzer.getInstalledPkgsByRepo(repos, self.IGNORE_PACKAGES, installedPackages)
      additionalPkgsInstalled = packages_analyzer.getInstalledPkgsByNames(
        self.ADDITIONAL_PACKAGES, installedPackages)
      allPackages = list(set(packagesInstalled + additionalPkgsInstalled))
      
      installedPackages = packages_analyzer.getPackageDetails(installedPackages, allPackages)
      repos = packages_analyzer.getReposToRemove(repos, self.IGNORE_REPOS)

      return installedPackages, repos
예제 #4
0
  def execute_existing_repos_and_installed_packages_check(self, config):
      installedPackages = []
      availablePackages = []
      packages_analyzer.allInstalledPackages(installedPackages)
      packages_analyzer.allAvailablePackages(availablePackages)

      repos = []
      packages_analyzer.getInstalledRepos(self.PACKAGES, installedPackages + availablePackages,
                                      self.IGNORE_PACKAGES_FROM_REPOS, repos)
      packagesInstalled = packages_analyzer.getInstalledPkgsByRepo(repos, self.IGNORE_PACKAGES, installedPackages)
      additionalPkgsInstalled = packages_analyzer.getInstalledPkgsByNames(
        self.ADDITIONAL_PACKAGES, installedPackages)
      allPackages = list(set(packagesInstalled + additionalPkgsInstalled))
      
      installedPackages = packages_analyzer.getPackageDetails(installedPackages, allPackages)
      repos = packages_analyzer.getReposToRemove(repos, self.IGNORE_REPOS)

      return installedPackages, repos