ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alejan...@apache.org
Subject ambari git commit: Revert. AMBARI-9795. [Monarch] Cluster create failed with timeout on the client side (aonishuk)
Date Thu, 26 Feb 2015 00:17:22 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk a8d791381 -> 418028efa


Revert. AMBARI-9795. [Monarch] Cluster create failed with timeout on the client side (aonishuk)


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

Branch: refs/heads/trunk
Commit: 418028efaa5aaa7ad6077f4bf7ecbab9204c7640
Parents: a8d7913
Author: Alejandro Fernandez <afernandez@hortonworks.com>
Authored: Wed Feb 25 16:16:46 2015 -0800
Committer: Alejandro Fernandez <afernandez@hortonworks.com>
Committed: Wed Feb 25 16:16:46 2015 -0800

----------------------------------------------------------------------
 .../ambari_agent/HostCheckReportFileHandler.py  | 86 ++++++--------------
 .../src/main/python/ambari_agent/HostCleanup.py | 19 +----
 .../src/main/python/ambari_agent/HostInfo.py    | 62 ++++++++++++++
 .../TestHostCheckReportFileHandler.py           | 23 +++---
 .../test/python/ambari_agent/TestHostCleanup.py | 16 ++--
 .../test/python/ambari_agent/TestHostInfo.py    | 30 +++++++
 .../libraries/functions/packages_analyzer.py    | 12 ---
 .../custom_actions/scripts/check_host.py        | 73 +----------------
 .../test/python/custom_actions/TestCheckHost.py |  7 +-
 9 files changed, 143 insertions(+), 185 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-agent/src/main/python/ambari_agent/HostCheckReportFileHandler.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostCheckReportFileHandler.py b/ambari-agent/src/main/python/ambari_agent/HostCheckReportFileHandler.py
index 9c0f1d0..bf24730 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostCheckReportFileHandler.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostCheckReportFileHandler.py
@@ -22,7 +22,6 @@ import datetime
 import os.path
 import logging
 import traceback
-from AmbariConfig import AmbariConfig
 import ConfigParser;
 
 logger = logging.getLogger()
@@ -30,58 +29,12 @@ logger = logging.getLogger()
 class HostCheckReportFileHandler:
 
   HOST_CHECK_FILE = "hostcheck.result"
-  HOST_CHECK_CUSTOM_ACTIONS_FILE = "hostcheck_custom_actions.result"
 
-  def __init__(self, config=None):
+  def __init__(self, config):
     self.hostCheckFilePath = None
-    
-    if config is None:
-      config = self.resolve_ambari_config()
-      
-    hostCheckFileDir = config.get('agent', 'prefix')
-    self.hostCheckFilePath = os.path.join(hostCheckFileDir, self.HOST_CHECK_FILE)
-    self.hostCheckCustomActionsFilePath = os.path.join(hostCheckFileDir, self.HOST_CHECK_CUSTOM_ACTIONS_FILE)
-    
-  def resolve_ambari_config(self):
-    try:
-      config = AmbariConfig()
-      if os.path.exists(AmbariConfig.getConfigFile()):
-        config.read(AmbariConfig.getConfigFile())
-      else:
-        raise Exception("No config found, use default")
-
-    except Exception, err:
-      logger.warn(err)
-    return config
-    
-  def writeHostChecksCustomActionsFile(self, structuredOutput):
-    if self.hostCheckCustomActionsFilePath is None:
-      return
-    
-    try:
-      logger.info("Host check custom action report at " + self.hostCheckCustomActionsFilePath)
-      config = ConfigParser.RawConfigParser()
-      config.add_section('metadata')
-      config.set('metadata', 'created', str(datetime.datetime.now()))
-      
-      if 'installed_packages' in structuredOutput.keys():
-        items = []
-        for itemDetail in structuredOutput['installed_packages']:
-          items.append(itemDetail['name'])
-        config.add_section('packages')
-        config.set('packages', 'pkg_list', ','.join(map(str, items)))
-
-      if 'existing_repos' in structuredOutput.keys():
-        config.add_section('repositories')
-        config.set('repositories', 'repo_list', ','.join(structuredOutput['existing_repos']))
-        
-      self.removeFile(self.hostCheckCustomActionsFilePath)
-      self.touchFile(self.hostCheckCustomActionsFilePath)
-      with open(self.hostCheckCustomActionsFilePath, 'wb') as configfile:
-        config.write(configfile)
-    except Exception, err:
-      logger.error("Can't write host check file at %s :%s " % (self.hostCheckFilePath, err.message))
-      traceback.print_exc()
+    if config is not None:
+      hostCheckFileDir = config.get('agent', 'prefix')
+      self.hostCheckFilePath = os.path.join(hostCheckFileDir, self.HOST_CHECK_FILE)
 
   def writeHostCheckFile(self, hostInfo):
     if self.hostCheckFilePath is None:
@@ -128,22 +81,33 @@ class HostCheckReportFileHandler:
           config.add_section('processes')
           config.set('processes', 'proc_list', ','.join(map(str, items)))
 
-      self.removeFile(self.hostCheckFilePath)
-      self.touchFile(self.hostCheckFilePath)
+      if 'installedPackages' in hostInfo.keys():
+        items = []
+        for itemDetail in hostInfo['installedPackages']:
+          items.append(itemDetail['name'])
+        config.add_section('packages')
+        config.set('packages', 'pkg_list', ','.join(map(str, items)))
+
+      if 'existingRepos' in hostInfo.keys():
+        config.add_section('repositories')
+        config.set('repositories', 'repo_list', ','.join(hostInfo['existingRepos']))
+
+      self.removeFile()
+      self.touchFile()
       with open(self.hostCheckFilePath, 'wb') as configfile:
         config.write(configfile)
     except Exception, err:
       logger.error("Can't write host check file at %s :%s " % (self.hostCheckFilePath, err.message))
       traceback.print_exc()
 
-  def removeFile(self, path):
-    if os.path.isfile(path):
-      logger.info("Removing old host check file at %s" % path)
-      os.remove(path)
+  def removeFile(self):
+    if os.path.isfile(self.hostCheckFilePath):
+      logger.info("Removing old host check file at %s" % self.hostCheckFilePath)
+      os.remove(self.hostCheckFilePath)
 
-  def touchFile(self, path):
-    if not os.path.isfile(path):
-      logger.info("Creating host check file at %s" % path)
-      open(path, 'w').close()
+  def touchFile(self):
+    if not os.path.isfile(self.hostCheckFilePath):
+      logger.info("Creating host check file at %s" % self.hostCheckFilePath)
+      open(self.hostCheckFilePath, 'w').close()
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-agent/src/main/python/ambari_agent/HostCleanup.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostCleanup.py b/ambari-agent/src/main/python/ambari_agent/HostCleanup.py
index e4a4754..398502e 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostCleanup.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostCleanup.py
@@ -55,9 +55,7 @@ ALT_ERASE_CMD = "alternatives --remove {0} {1}"
 REPO_PATH_RHEL = "/etc/yum.repos.d"
 REPO_PATH_SUSE = "/etc/zypp/repos.d/"
 SKIP_LIST = []
-TMP_HOST_CHECK_FILE_NAME = "tmp_hostcheck.result"
 HOST_CHECK_FILE_NAME = "hostcheck.result"
-HOST_CHECK_CUSTOM_ACTIONS_FILE = "hostcheck_custom_actions.result"
 OUTPUT_FILE_NAME = "hostcleanup.result"
 
 PACKAGE_SECTION = "packages"
@@ -525,15 +523,13 @@ def main():
   config = h.resolve_ambari_config()
   hostCheckFileDir = config.get('agent', 'prefix')
   hostCheckFilePath = os.path.join(hostCheckFileDir, HOST_CHECK_FILE_NAME)
-  hostCheckCustomActionsFilePath = os.path.join(hostCheckFileDir, HOST_CHECK_CUSTOM_ACTIONS_FILE)
-  hostCheckFilesPaths = hostCheckFilePath + "," + hostCheckCustomActionsFilePath
   hostCheckResultPath = os.path.join(hostCheckFileDir, OUTPUT_FILE_NAME)
 
   parser = optparse.OptionParser()
   parser.add_option("-v", "--verbose", dest="verbose", action="store_false",
                     default=False, help="output verbosity.")
-  parser.add_option("-f", "--file", dest="inputfiles",
-                    default=hostCheckFilesPaths,
+  parser.add_option("-f", "--file", dest="inputfile",
+                    default=hostCheckFilePath,
                     help="host check result file to read.", metavar="FILE")
   parser.add_option("-o", "--out", dest="outputfile",
                     default=hostCheckResultPath,
@@ -579,15 +575,8 @@ def main():
         print 'Exiting. Use option --skip="users" to skip deleting users'
         sys.exit(1)
 
-  hostcheckfile, hostcheckfileca  = options.inputfiles.split(",")
-  
-  with open(TMP_HOST_CHECK_FILE_NAME, "wb") as tmp_f:
-    with open(hostcheckfile, "rb") as f1:
-      with open(hostcheckfileca, "rb") as f2:
-        tmp_f.write(f1.read())
-        tmp_f.write(f2.read())
-  
-  propMap = h.read_host_check_file(TMP_HOST_CHECK_FILE_NAME)
+  hostcheckfile = options.inputfile
+  propMap = h.read_host_check_file(hostcheckfile)
 
   if propMap:
     h.do_cleanup(propMap)

http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-agent/src/main/python/ambari_agent/HostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 516221d..dc0834a 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -147,6 +147,33 @@ class HostInfoLinux(HostInfo):
     "/hadoop", "/usr/hdp"
   ]
 
+  # Packages that are used to find repos (then repos are used to find other packages)
+  PACKAGES = [
+    "hadoop_2_2_*", "hadoop-2-2-.*", "zookeeper_2_2_*", "zookeeper-2-2-.*",
+    "hadoop", "zookeeper", "webhcat", "*-manager-server-db", "*-manager-daemons"
+  ]
+
+  # Additional packages to look for (search packages that start with these)
+  ADDITIONAL_PACKAGES = [
+    "rrdtool", "rrdtool-python", "ganglia", "gmond", "gweb", "libconfuse",
+    "ambari-log4j", "hadoop", "zookeeper", "oozie", "webhcat"
+  ]
+
+  # ignore packages from repos whose names start with these strings
+  IGNORE_PACKAGES_FROM_REPOS = [
+    "ambari", "installed"
+  ]
+
+  # ignore required packages
+  IGNORE_PACKAGES = [
+    "epel-release"
+  ]
+
+  # ignore repos from the list of repos to be cleaned
+  IGNORE_REPOS = [
+    "ambari", "HDP-UTILS"
+  ]
+
   DEFAULT_SERVICE_NAME = "ntpd"
   SERVICE_STATUS_CMD = "%s %s status" % (SERVICE_CMD, DEFAULT_SERVICE_NAME)
 
@@ -175,6 +202,8 @@ class HostInfoLinux(HostInfo):
         result['name'] = fields[0]
         result['homeDir'] = fields[5]
         result['status'] = "Available"
+        if not os.path.exists(homeDir):
+          result['status'] = "Invalid home directory"
         results.append(result)
 
   def checkFolders(self, basePaths, projectNames, existingUsers, dirs):
@@ -219,6 +248,18 @@ class HostInfoLinux(HostInfo):
       pass
     pass
 
+  def getReposToRemove(self, repos, ignoreList):
+    reposToRemove = []
+    for repo in repos:
+      addToRemoveList = True
+      for ignoreRepo in ignoreList:
+        if packages_analyzer.nameMatch(ignoreRepo, repo):
+          addToRemoveList = False
+          continue
+      if addToRemoveList:
+        reposToRemove.append(repo)
+    return reposToRemove
+
   def getTransparentHugePage(self):
     # This file exist only on redhat 6
     thp_regex = "\[(.+)\]"
@@ -282,6 +323,8 @@ class HostInfoLinux(HostInfo):
     # If commands are in progress or components are already mapped to this host
     # Then do not perform certain expensive host checks
     if componentsMapped or commandsInProgress:
+      dict['existingRepos'] = [self.RESULT_UNAVAILABLE]
+      dict['installedPackages'] = []
       dict['alternatives'] = []
       dict['stackFoldersAndFiles'] = []
       dict['existingUsers'] = []
@@ -299,6 +342,23 @@ class HostInfoLinux(HostInfo):
       self.checkFolders(self.DEFAULT_DIRS, self.DEFAULT_PROJECT_NAMES, existingUsers, dirs)
       dict['stackFoldersAndFiles'] = dirs
 
+      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))
+      dict['installedPackages'] = packages_analyzer.getPackageDetails(installedPackages,
allPackages)
+
+      repos = self.getReposToRemove(repos, self.IGNORE_REPOS)
+      dict['existingRepos'] = repos
+
       self.reportFileHandler.writeHostCheckFile(dict)
       pass
 
@@ -409,6 +469,8 @@ class HostInfoWindows(HostInfo):
     # If commands are in progress or components are already mapped to this host
     # Then do not perform certain expensive host checks
     if componentsMapped or commandsInProgress:
+      dict['existingRepos'] = [self.RESULT_UNAVAILABLE]
+      dict['installedPackages'] = []
       dict['alternatives'] = []
       dict['stackFoldersAndFiles'] = []
       dict['existingUsers'] = []

http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py b/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py
index d56ad8f..eb7efb2 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py
@@ -84,6 +84,12 @@ class TestHostCheckReportFileHandler(TestCase):
     procs = configValidator.get('processes', 'proc_list')
     self.assertEquals(procs, '')
 
+    pkgs = configValidator.get('packages', 'pkg_list')
+    self.assertEquals(pkgs, '')
+
+    repos = configValidator.get('repositories', 'repo_list')
+    self.assertEquals(repos, '')
+
     time = configValidator.get('metadata', 'created')
     self.assertTrue(time != None)
 
@@ -108,6 +114,11 @@ class TestHostCheckReportFileHandler(TestCase):
       {'pid':355,'hadoop':True,'command':'some command','user':'root'},
       {'pid':455,'hadoop':True,'command':'some command','user':'hdfs'}
     ]
+    dict['installedPackages'] = [
+      {'name':'hadoop','version':'3.2.3','repoName':'HDP'},
+      {'name':'hadoop-lib','version':'3.2.3','repoName':'HDP'}
+    ]
+    dict['existingRepos'] = ['HDP', 'HDP-epel']
     handler.writeHostCheckFile(dict)
 
     configValidator = ConfigParser.RawConfigParser()
@@ -129,18 +140,6 @@ class TestHostCheckReportFileHandler(TestCase):
     procs = configValidator.get('processes', 'proc_list')
     self.chkItemsEqual(procs, ['455', '355'])
 
-
-    dict['installed_packages'] = [
-      {'name':'hadoop','version':'3.2.3','repoName':'HDP'},
-      {'name':'hadoop-lib','version':'3.2.3','repoName':'HDP'}
-    ]
-    dict['existing_repos'] = ['HDP', 'HDP-epel']
-    
-    handler.writeHostChecksCustomActionsFile(dict)
-    configValidator = ConfigParser.RawConfigParser()
-    configPath_ca = os.path.join(os.path.dirname(tmpfile), HostCheckReportFileHandler.HOST_CHECK_CUSTOM_ACTIONS_FILE)
-    configValidator.read(configPath_ca)
-    
     pkgs = configValidator.get('packages', 'pkg_list')
     self.chkItemsEqual(pkgs, ['hadoop', 'hadoop-lib'])
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-agent/src/test/python/ambari_agent/TestHostCleanup.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHostCleanup.py b/ambari-agent/src/test/python/ambari_agent/TestHostCleanup.py
index 734db5d..f43784c 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostCleanup.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostCleanup.py
@@ -112,9 +112,9 @@ class TestHostCleanup(TestCase):
     sys.stdout = sys.__stdout__
 
   class HostCleanupOptions:
-    def __init__(self, outputfile, inputfiles, skip, verbose, silent, java_home):
+    def __init__(self, outputfile, inputfile, skip, verbose, silent, java_home):
       self.outputfile = outputfile
-      self.inputfiles = inputfiles
+      self.inputfile = inputfile
       self.skip = skip
       self.verbose = verbose
       self.silent = silent
@@ -131,9 +131,7 @@ class TestHostCleanup(TestCase):
   @patch.object(optparse.OptionParser, 'parse_args')
   def test_options(self, parser_mock, file_handler_mock, logging_mock, read_host_check_file_mock,
                    set_formatter_mock, user_root_mock, do_cleanup_mock, get_yn_input_mock,
clear_cache_mock):
-    open('/tmp/someinputfile1', 'a').close()
-    open('/tmp/someinputfile2', 'a').close()
-    parser_mock.return_value = (TestHostCleanup.HostCleanupOptions('/someoutputfile', '/tmp/someinputfile1,/tmp/someinputfile2',
'', False,
+    parser_mock.return_value = (TestHostCleanup.HostCleanupOptions('/someoutputfile', '/someinputfile',
'', False,
                                                                    False, 'java_home'), [])
     file_handler_mock.return_value = logging.FileHandler('') # disable creating real file
     user_root_mock.return_value = True
@@ -147,7 +145,7 @@ class TestHostCleanup(TestCase):
     #test --verbose
     logging_mock.assert_called_with(level=logging.INFO)
     # test --in
-    read_host_check_file_mock.assert_called_with('tmp_hostcheck.result')
+    read_host_check_file_mock.assert_called_with('/someinputfile')
     self.assertTrue(get_yn_input_mock.called)
 
   @patch.object(HostCleanup.HostCleanup, 'get_files_in_dir')
@@ -181,9 +179,7 @@ class TestHostCleanup(TestCase):
   @patch.object(optparse.OptionParser, 'parse_args')
   def test_options_silent(self, parser_mock, file_handler_mock, logging_mock, read_host_check_file_mock,
                    set_formatter_mock, user_root_mock, do_cleanup_mock, get_yn_input_mock,
clear_cache_mock):
-    open('/tmp/someinputfile1', 'a').close()
-    open('/tmp/someinputfile2', 'a').close()
-    parser_mock.return_value = (TestHostCleanup.HostCleanupOptions('/someoutputfile', '/tmp/someinputfile1,/tmp/someinputfile2',
'', False,
+    parser_mock.return_value = (TestHostCleanup.HostCleanupOptions('/someoutputfile', '/someinputfile',
'', False,
                                                                    True, 'java_home'), [])
     file_handler_mock.return_value = logging.FileHandler('') # disable creating real file
     user_root_mock.return_value = True
@@ -197,7 +193,7 @@ class TestHostCleanup(TestCase):
     #test --verbose
     logging_mock.assert_called_with(level=logging.INFO)
     # test --in
-    read_host_check_file_mock.assert_called_with('tmp_hostcheck.result')
+    read_host_check_file_mock.assert_called_with('/someinputfile')
     self.assertFalse(get_yn_input_mock.called)
 
   @patch.object(HostCleanup.HostCleanup, 'do_clear_cache')

http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
index fcab6b8..c1b93d6 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostInfo.py
@@ -83,6 +83,20 @@ class TestHostInfo(TestCase):
     self.assertTrue(installedPackages[6][1], "11-38.13.9")
 
   @not_for_platform(PLATFORM_WINDOWS)
+  def test_getReposToRemove(self):
+    l1 = ["Hortonworks Data Platform Utils Version - HDP-UTILS-1.1.0.15", "Ambari 1.x", "HDP"]
+    l2 = ["Ambari", "HDP-UTIL"]
+    hostInfo = HostInfoLinux()
+    l3 = hostInfo.getReposToRemove(l1, l2)
+    self.assertTrue(1, len(l3))
+    self.assertEqual(l3[0], "HDP")
+
+    l1 = ["AMBARI.dev-1.x", "HDP-1.3.0"]
+    l3 = hostInfo.getReposToRemove(l1, l2)
+    self.assertTrue(1, len(l3))
+    self.assertEqual(l3[0], "HDP-1.3.0")
+
+  @not_for_platform(PLATFORM_WINDOWS)
   def test_perform_package_analysis(self):
     installedPackages = [
       ["hadoop-a", "2.3", "HDP"], ["zk", "3.1", "HDP"], ["webhcat", "3.1", "HDP"],
@@ -272,9 +286,14 @@ class TestHostInfo(TestCase):
     dict = {}
     hostInfo.register(dict, False, False)
     self.assertTrue(cit_mock.called)
+    self.assertTrue(gir_mock.called)
+    self.assertTrue(gpd_mock.called)
+    self.assertTrue(aip_mock.called)
+    self.assertTrue(aap_mock.called)
     self.assertTrue(os_umask_mock.called)
     self.assertTrue(whcf_mock.called)
 
+    self.assertTrue(0 < len(dict['installedPackages']))
     self.assertTrue('agentTimeStampAtReporting' in dict['hostHealth'])
 
   @not_for_platform(PLATFORM_WINDOWS)
@@ -323,14 +342,25 @@ class TestHostInfo(TestCase):
     hostInfo = HostInfoLinux()
     dict = {}
     hostInfo.register(dict, False, False)
+    self.assertTrue(gir_mock.called)
+    self.assertTrue(gpd_mock.called)
+    self.assertTrue(aip_mock.called)
     self.assertTrue(cit_mock.called)
     self.assertEqual(1, cit_mock.call_count)
 
+    for existingPkg in ["pkg1", "pkg2"]:
+      self.assertTrue(existingPkg in dict['installedPackages'])
+    args, kwargs = gpd_mock.call_args_list[0]
+    for existingPkg in ["pkg1", "pkg2"]:
+      self.assertTrue(existingPkg in args[1])
+
   def verifyReturnedValues(self, dict):
     hostInfo = HostInfoLinux()
     self.assertEqual(dict['alternatives'], [])
     self.assertEqual(dict['stackFoldersAndFiles'], [])
     self.assertEqual(dict['existingUsers'], [])
+    self.assertEqual(dict['existingRepos'][0], hostInfo.RESULT_UNAVAILABLE)
+    self.assertEqual(dict['installedPackages'], [])
     self.assertTrue(dict['iptablesIsRunning'])
 
   @patch("os.path.exists")

http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
b/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
index 55c1eb8..888387c 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/packages_analyzer.py
@@ -261,15 +261,3 @@ def getPackageDetails(installedPackages, foundPackages):
         pkgDetail['repoName'] = installedPackage[2]
     packageDetails.append(pkgDetail)
   return packageDetails
-
-def getReposToRemove(repos, ignoreList):
-  reposToRemove = []
-  for repo in repos:
-    addToRemoveList = True
-    for ignoreRepo in ignoreList:
-      if nameMatch(ignoreRepo, repo):
-        addToRemoveList = False
-        continue
-    if addToRemoveList:
-      reposToRemove.append(repo)
-  return reposToRemove

http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/check_host.py b/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
index b0fcfb6..ff2eabd 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/check_host.py
@@ -24,20 +24,16 @@ import os
 import subprocess
 import socket
 
-from resource_management.libraries.functions import packages_analyzer
 from ambari_commons import os_utils
 from ambari_commons.os_check import OSCheck, OSConst
 from ambari_commons.inet_utils import download_file
 from resource_management import Script, Execute, format
 from ambari_agent.HostInfo import HostInfo
-from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler
 
 CHECK_JAVA_HOME = "java_home_check"
 CHECK_DB_CONNECTION = "db_connection_check"
 CHECK_HOST_RESOLUTION = "host_resolution_check"
 CHECK_LAST_AGENT_ENV = "last_agent_env_check"
-CHECK_INSTALLED_PACKAGES = "installed_packages"
-CHECK_EXISTING_REPOS = "existing_repos"
 
 DB_MYSQL = "mysql"
 DB_ORACLE = "oracle"
@@ -56,42 +52,9 @@ JDBC_DRIVER_SYMLINK_MSSQL = "sqljdbc4.jar"
 JDBC_AUTH_SYMLINK_MSSQL = "sqljdbc_auth.dll"
 
 class CheckHost(Script):
-  # Packages that are used to find repos (then repos are used to find other packages)
-  PACKAGES = [
-    "hadoop_2_2_*", "hadoop-2-2-.*", "zookeeper_2_2_*", "zookeeper-2-2-.*",
-    "hadoop", "zookeeper", "webhcat", "*-manager-server-db", "*-manager-daemons"
-  ]
-  
-
-  # ignore packages from repos whose names start with these strings
-  IGNORE_PACKAGES_FROM_REPOS = [
-    "ambari", "installed"
-  ]
-  
-
-  # ignore required packages
-  IGNORE_PACKAGES = [
-    "epel-release"
-  ]
-  
-  # Additional packages to look for (search packages that start with these)
-  ADDITIONAL_PACKAGES = [
-    "rrdtool", "rrdtool-python", "ganglia", "gmond", "gweb", "libconfuse",
-    "ambari-log4j", "hadoop", "zookeeper", "oozie", "webhcat"
-  ]
-  
-  # ignore repos from the list of repos to be cleaned
-  IGNORE_REPOS = [
-    "ambari", "HDP-UTILS"
-  ]
-  
-  def __init__(self):
-    self.reportFileHandler = HostCheckReportFileHandler()
-  
   def actionexecute(self, env):
     config = Script.get_config()
     tmp_dir = Script.get_tmp_dir()
-    report_file_handler_dict = {}
 
     #print "CONFIG: " + str(config)
 
@@ -130,42 +93,8 @@ class CheckHost(Script):
       except Exception, exception :
         print "There was an unknown error while checking last host environment details: "
+ str(exception)
         structured_output[CHECK_LAST_AGENT_ENV] = {"exit_code" : 1, "message": str(exception)}
-        
-    # CHECK_INSTALLED_PACKAGES and CHECK_EXISTING_REPOS required to run together for
-    # reasons of not doing the same common work twice for them as it takes some time, especially
on Ubuntu.
-    if CHECK_INSTALLED_PACKAGES in check_execute_list and CHECK_EXISTING_REPOS in check_execute_list:
-      try :
-        installed_packages, repos = self.execute_existing_repos_and_installed_packages_check(config)
-        structured_output[CHECK_INSTALLED_PACKAGES] = installed_packages
-        structured_output[CHECK_EXISTING_REPOS] = repos
-      except Exception, exception :
-        print "There was an unknown error while checking installed packages and existing
repositories: " + str(exception)
-        structured_output[CHECK_INSTALLED_PACKAGES] = {"exit_code" : 1, "message": str(exception)}
-        structured_output[CHECK_EXISTING_REPOS] = {"exit_code" : 1, "message": str(exception)}
-        
-    # this is necessary for HostCleanup to know later what were the results.
-    self.reportFileHandler.writeHostChecksCustomActionsFile(structured_output)
-    
-    self.put_structured_out(structured_output)
 
-  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
+    self.put_structured_out(structured_output)
 
 
   def execute_java_home_available_check(self, config):

http://git-wip-us.apache.org/repos/asf/ambari/blob/418028ef/ambari-server/src/test/python/custom_actions/TestCheckHost.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestCheckHost.py b/ambari-server/src/test/python/custom_actions/TestCheckHost.py
index 2cd5c7a..105a0b0 100644
--- a/ambari-server/src/test/python/custom_actions/TestCheckHost.py
+++ b/ambari-server/src/test/python/custom_actions/TestCheckHost.py
@@ -55,8 +55,7 @@ class TestCheckHost(TestCase):
     checkHost = CheckHost()
     checkHost.actionexecute(None)
 
-    print os_isfile_mock.call_args
-    self.assertEquals(os_isfile_mock.call_args[0][0], '/tmp/ambari-agent/hostcheck_custom_actions.result')
+    self.assertEquals(os_isfile_mock.call_args[0][0], 'test_java_home/bin/java')
     self.assertEquals(structured_out_mock.call_args[0][0], {'java_home_check': {'message':
'Java home exists!',
                                                                                 'exit_code':
0}})
     # test, java home doesn't exist
@@ -65,7 +64,7 @@ class TestCheckHost(TestCase):
 
     checkHost.actionexecute(None)
 
-    self.assertEquals(os_isfile_mock.call_args[0][0], '/tmp/ambari-agent/hostcheck_custom_actions.result')
+    self.assertEquals(os_isfile_mock.call_args[0][0], 'test_java_home/bin/java')
     self.assertEquals(structured_out_mock.call_args[0][0], {'java_home_check': {"message":
"Java home doesn't exist!",
                                                                                 "exit_code"
: 1}})
 
@@ -283,6 +282,8 @@ class TestCheckHost(TestCase):
     self.assertTrue('alternatives' in last_agent_env_check_result['last_agent_env_check'])
     self.assertTrue('umask' in last_agent_env_check_result['last_agent_env_check'])
     self.assertTrue('stackFoldersAndFiles' in last_agent_env_check_result['last_agent_env_check'])
+    self.assertTrue('existingRepos' in last_agent_env_check_result['last_agent_env_check'])
+    self.assertTrue('installedPackages' in last_agent_env_check_result['last_agent_env_check'])
     self.assertTrue('existingUsers' in last_agent_env_check_result['last_agent_env_check'])
 
     # try it now with errors


Mime
View raw message