You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by fb...@apache.org on 2015/03/12 18:37:57 UTC

ambari git commit: AMBARI-9525 Enable refresh-stack-hash command on windows

Repository: ambari
Updated Branches:
  refs/heads/trunk 4530322bd -> 190bd0b04


AMBARI-9525 Enable refresh-stack-hash command on windows

Added the refresh-stask-hash command to the main script and to the batch file. Fixed stacks directory retrieval. Fixed resources directory retrieval inconsistencies. Updated unit tests.


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

Branch: refs/heads/trunk
Commit: 190bd0b0433923fa0db9c9d91900aa0d5f59a18b
Parents: 4530322
Author: Florian Barca <fb...@hortonworks.com>
Authored: Thu Mar 12 10:37:43 2015 -0700
Committer: Florian Barca <fb...@hortonworks.com>
Committed: Thu Mar 12 10:37:43 2015 -0700

----------------------------------------------------------------------
 .../src/main/python/ambari_commons/os_check.py  | 15 ++-
 ambari-server/src/main/python/ambari-server.py  |  3 +-
 .../python/ambari_server/dbConfiguration.py     | 14 +--
 .../ambari_server/dbConfiguration_linux.py      | 11 +--
 .../python/ambari_server/resourceFilesKeeper.py | 96 ++++++++++----------
 .../python/ambari_server/serverConfiguration.py | 21 ++++-
 .../main/python/ambari_server/serverSetup.py    | 57 +++++-------
 .../main/python/ambari_server/serverUtils.py    |  9 +-
 .../src/main/python/ambari_server_main.py       | 14 +--
 .../src/main/windows/ambari-server.ps1          | 10 +-
 .../src/test/python/TestAmbariServer.py         | 71 +++++++++++----
 ambari-server/src/test/python/TestOSCheck.py    | 12 +--
 .../src/test/python/TestResourceFilesKeeper.py  | 32 ++++---
 .../python/host_scripts/TestAlertDiskSpace.py   |  9 ++
 14 files changed, 213 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-common/src/main/python/ambari_commons/os_check.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/ambari_commons/os_check.py b/ambari-common/src/main/python/ambari_commons/os_check.py
index 39d8202..4e93feb 100644
--- a/ambari-common/src/main/python/ambari_commons/os_check.py
+++ b/ambari-common/src/main/python/ambari_commons/os_check.py
@@ -70,6 +70,17 @@ VER_NT_WORKSTATION = 1
 VER_NT_DOMAIN_CONTROLLER = 2
 VER_NT_SERVER = 3
 
+# Linux specific releases, caching them since they are execution invariants
+_IS_ORACLE_LINUX = os.path.exists('/etc/oracle-release')
+_IS_REDHAT_LINUX = os.path.exists('/etc/redhat-release')
+
+def _is_oracle_linux():
+  return _IS_ORACLE_LINUX
+
+def _is_redhat_linux():
+  return _IS_REDHAT_LINUX
+
+
 class OS_CONST_TYPE(type):
 
   # Declare here os type mapping
@@ -148,7 +159,7 @@ class OSCheck:
 
       if PYTHON_VER < 26:
         distribution = platform.dist()
-      elif os.path.exists('/etc/redhat-release'):
+      elif _is_redhat_linux():
         distribution = platform.dist()
       else:
         distribution = platform.linux_distribution()
@@ -171,7 +182,7 @@ class OSCheck:
     operatingSystem = dist[0].lower()
 
     # special cases
-    if os.path.exists('/etc/oracle-release'):
+    if _is_oracle_linux():
       return 'oraclelinux'
     elif operatingSystem.startswith('suse linux enterprise server'):
       return 'sles'

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/python/ambari-server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py
index 22ab70f..9114abe 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -307,7 +307,7 @@ def init_parser_options(parser):
 
 @OsFamilyFuncImpl(OsFamilyImpl.DEFAULT)
 def init_parser_options(parser):
-  optparse.Option('-f', '--init-script-file',
+  parser.add_option('-f', '--init-script-file',
                     default='/var/lib/ambari-server/'
                             'resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql',
                     help="File with setup script")
@@ -484,6 +484,7 @@ def create_user_action_map(args, options):
     UPGRADE_ACTION: UserAction(upgrade, options),
     LDAP_SETUP_ACTION: UserAction(setup_ldap),
     SETUP_SECURITY_ACTION: UserActionRestart(setup_security, options),
+    REFRESH_STACK_HASH_ACTION: UserAction(refresh_stack_hash_action),
   }
   return action_map
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/python/ambari_server/dbConfiguration.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/dbConfiguration.py b/ambari-server/src/main/python/ambari_server/dbConfiguration.py
index 9962a5d..2913e3f 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration.py
@@ -25,10 +25,9 @@ from ambari_commons.exceptions import FatalException
 from ambari_commons.logging_utils import get_silent, print_error_msg, print_info_msg, print_warning_msg, set_silent
 from ambari_commons.os_family_impl import OsFamilyImpl
 from ambari_commons.str_utils import cbool
-from ambari_server.serverConfiguration import decrypt_password_for_alias, get_value_from_properties, get_is_secure, \
-  is_alias_string, \
-  JDBC_PASSWORD_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, PRESS_ENTER_MSG, get_ambari_properties, update_properties, \
-  RESOURCES_DIR_PROPERTY, JDBC_PATTERNS, configDefaults
+from ambari_server.serverConfiguration import decrypt_password_for_alias, get_ambari_properties, get_is_secure, \
+  get_resources_location, get_value_from_properties, is_alias_string, \
+  JDBC_PASSWORD_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, PRESS_ENTER_MSG
 from ambari_server.userInput import get_validated_string_input
 
 
@@ -454,13 +453,8 @@ def check_jdbc_drivers(args):
     err = "Error getting ambari properties"
     print_error_msg(err)
     raise FatalException(-1, err)
-  conf_file = properties.fileName
 
-  try:
-    resources_dir = properties[RESOURCES_DIR_PROPERTY]
-  except (KeyError), e:
-    err = 'Property ' + str(e) + ' is not defined at ' + conf_file
-    raise FatalException(1, err)
+  resources_dir = get_resources_location(properties)
 
   try:
     db_idx_orig = args.database_index

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
index c92fd9c..735336c 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
@@ -33,7 +33,8 @@ from ambari_commons.exceptions import NonFatalException, FatalException
 from ambari_commons.os_utils import copy_files, find_in_path, is_root, remove_file, run_os_command
 from ambari_server.dbConfiguration import DBMSConfig, USERNAME_PATTERN, SETUP_DB_CONNECT_ATTEMPTS, \
     SETUP_DB_CONNECT_TIMEOUT, STORAGE_TYPE_LOCAL, DEFAULT_USERNAME, DEFAULT_PASSWORD
-from ambari_server.serverConfiguration import get_ambari_properties, get_value_from_properties, configDefaults, \
+from ambari_server.serverConfiguration import encrypt_password, store_password_file, \
+    get_ambari_properties, get_resources_location, get_value_from_properties, configDefaults, \
     OS_TYPE, OS_FAMILY, AMBARI_PROPERTIES_FILE, RESOURCES_DIR_PROPERTY, \
     JDBC_DATABASE_PROPERTY, JDBC_DATABASE_NAME_PROPERTY, JDBC_POSTGRES_SCHEMA_PROPERTY, \
     JDBC_HOSTNAME_PROPERTY, JDBC_PORT_PROPERTY, \
@@ -41,7 +42,7 @@ from ambari_server.serverConfiguration import get_ambari_properties, get_value_f
     JDBC_DRIVER_PROPERTY, JDBC_URL_PROPERTY, \
     JDBC_RCA_USER_NAME_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, JDBC_RCA_PASSWORD_FILE_PROPERTY, \
     JDBC_RCA_DRIVER_PROPERTY, JDBC_RCA_URL_PROPERTY, \
-    PERSISTENCE_TYPE_PROPERTY, encrypt_password, store_password_file
+    PERSISTENCE_TYPE_PROPERTY
 from ambari_server.userInput import get_YN_input, get_validated_string_input, read_password
 from ambari_server.utils import get_postgre_hba_dir, get_postgre_running_status
 
@@ -153,11 +154,7 @@ class LinuxDBMSConfig(DBMSConfig):
   def _install_jdbc_driver(self, properties, files_list):
     if type(files_list) is not int:
       print 'Copying JDBC drivers to server resources...'
-      try:
-        resources_dir = properties[RESOURCES_DIR_PROPERTY]
-      except KeyError:
-        print_error_msg("There is no value for " + RESOURCES_DIR_PROPERTY + "in " + AMBARI_PROPERTIES_FILE)
-        return False
+      resources_dir = get_resources_location(properties)
 
       db_name = self.dbms_full_name.lower()
       symlink_name = db_name + "-jdbc-driver.jar"

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py b/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py
index 2d3996e..5d01e3e 100644
--- a/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py
+++ b/ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py
@@ -23,7 +23,6 @@ import os, sys
 import zipfile
 import glob
 import pprint
-from xml.dom import minidom
 
 
 class KeeperException(Exception):
@@ -55,11 +54,12 @@ class ResourceFilesKeeper():
   # Change that to True to see debug output at stderr
   DEBUG=False
 
-  def __init__(self, resources_dir, verbose=False, nozip=False):
+  def __init__(self, resources_dir, stacks_dir, verbose=False, nozip=False):
     """
       nozip = create only hash files and skip creating zip archives
     """
     self.resources_dir = resources_dir
+    self.stacks_root = stacks_dir
     self.verbose = verbose
     self.nozip = nozip
 
@@ -72,21 +72,31 @@ class ResourceFilesKeeper():
     # probably, later we will need some additional operations
 
 
+  def _iter_update_directory_archive(self, subdirs_list):
+    for subdir in subdirs_list:
+      for root, dirs, _ in os.walk(subdir):
+        for d in dirs:
+          if d in self.ARCHIVABLE_DIRS:
+            full_path = os.path.abspath(os.path.join(root, d))
+            self.update_directory_archive(full_path)
+
+  def _update_resources_subdir_archive(self, subdir):
+    archive_root = os.path.join(self.resources_dir, subdir)
+    self.dbg_out("Updating archive for {0} dir at {1}...".format(subdir, archive_root))
+
+    # update the directories so that the .hash is generated
+    self.update_directory_archive(archive_root)
+
   def update_directory_archieves(self):
     """
     Please see AMBARI-4481 for more details
     """
-    stacks_root = os.path.join(self.resources_dir, self.STACKS_DIR)
-    self.dbg_out("Updating archives for stack dirs at {0}...".format(stacks_root))
-    valid_stacks = self.list_stacks(stacks_root)
+    # archive stacks
+    self.dbg_out("Updating archives for stack dirs at {0}...".format(self.stacks_root))
+    valid_stacks = self.list_stacks(self.stacks_root)
     self.dbg_out("Stacks: {0}".format(pprint.pformat(valid_stacks)))
     # Iterate over stack directories
-    for stack_dir in valid_stacks:
-      for root, dirs, _ in os.walk(stack_dir):
-        for d in dirs:
-          if d in self.ARCHIVABLE_DIRS:
-            full_path = os.path.abspath(os.path.join(root, d))
-            self.update_directory_archive(full_path)
+    self._iter_update_directory_archive(valid_stacks)
 
     # archive common services
     common_services_root = os.path.join(self.resources_dir, self.COMMON_SERVICES_DIR)
@@ -94,58 +104,40 @@ class ResourceFilesKeeper():
     valid_common_services = self.list_common_services(common_services_root)
     self.dbg_out("Common Services: {0}".format(pprint.pformat(valid_common_services)))
     # Iterate over common services directories
-    for common_service_dir in valid_common_services:
-      for root, dirs, _ in os.walk(common_service_dir):
-        for d in dirs:
-          if d in self.ARCHIVABLE_DIRS:
-            full_path = os.path.abspath(os.path.join(root, d))
-            self.update_directory_archive(full_path)
-
+    self._iter_update_directory_archive(valid_common_services)
 
     # custom actions
-    custom_actions_root = os.path.join(self.resources_dir,self.CUSTOM_ACTIONS_DIR)        
-    self.dbg_out("Updating archive for {0} dir at {1}...".format(self.CUSTOM_ACTIONS_DIR, 
-        custom_actions_root))
-        
+    self._update_resources_subdir_archive(self.CUSTOM_ACTIONS_DIR)
+
     # agent host scripts
-    host_scripts_root = os.path.join(self.resources_dir,self.HOST_SCRIPTS_DIR)    
-    self.dbg_out("Updating archive for {0} dir at {1}...".format(self.HOST_SCRIPTS_DIR, 
-        host_scripts_root))
-    
-    # update the directories so that the .hash is generated
-    self.update_directory_archive(custom_actions_root)
-    self.update_directory_archive(host_scripts_root)
+    self._update_resources_subdir_archive(self.HOST_SCRIPTS_DIR)
+
 
+  def _list_metainfo_dirs(self, root_dir):
+    valid_items = []  # Format: <stack_dir, ignore(True|False)>
+    glob_pattern = "{0}/*/*".format(root_dir)
+    dirs = glob.glob(glob_pattern)
+    for directory in dirs:
+      metainfo_file = os.path.join(directory, self.METAINFO_XML)
+      if os.path.exists(metainfo_file):
+        valid_items.append(directory)
+    return valid_items
 
-  def list_stacks(self, stacks_root):
+  def list_stacks(self, root_dir):
     """
     Builds a list of stack directories
     """
-    valid_stacks = [] # Format: <stack_dir, ignore(True|False)>
-    glob_pattern = "{0}/*/*".format(stacks_root)
     try:
-      stack_dirs = glob.glob(glob_pattern)
-      for directory in stack_dirs:
-        metainfo_file = os.path.join(directory, self.METAINFO_XML)
-        if os.path.exists(metainfo_file):
-          valid_stacks.append(directory)
-      return valid_stacks
+      return self._list_metainfo_dirs(root_dir)
     except Exception, err:
       raise KeeperException("Can not list stacks: {0}".format(str(err)))
 
-  def list_common_services(self, common_services_root):
+  def list_common_services(self, root_dir):
     """
     Builds a list of common services directories
     """
-    valid_common_services = []
-    glob_pattern = "{0}/*/*".format(common_services_root)
     try:
-      common_services_dirs = glob.glob(glob_pattern)
-      for directory in common_services_dirs:
-        metainfo_file = os.path.join(directory, self.METAINFO_XML)
-        if os.path.exists(metainfo_file):
-          valid_common_services.append(directory)
-      return valid_common_services
+      return self._list_metainfo_dirs(root_dir)
     except Exception, err:
       raise KeeperException("Can not list common services: {0}".format(str(err)))
 
@@ -269,8 +261,14 @@ def main(argv=None):
   Params:
     1: Path to resources root directory
   """
-  path = argv[1]
-  resource_files_keeper = ResourceFilesKeeper(path, nozip=True)
+  res_path = argv[1]
+
+  if len(argv) >= 3:
+    stacks_path = argv[2]
+  else:
+    stacks_path = os.path.join(res_path, ResourceFilesKeeper.STACKS_DIR)
+
+  resource_files_keeper = ResourceFilesKeeper(res_path, stacks_path, nozip=True)
   resource_files_keeper.perform_housekeeping()
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/python/ambari_server/serverConfiguration.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverConfiguration.py b/ambari-server/src/main/python/ambari_server/serverConfiguration.py
index f73e75c..a00be1b 100644
--- a/ambari-server/src/main/python/ambari_server/serverConfiguration.py
+++ b/ambari-server/src/main/python/ambari_server/serverConfiguration.py
@@ -137,7 +137,6 @@ SERVICE_PASSWORD_KEY = "TMP_AMBARI_PASSWORD"
 
 # resources repo configuration
 RESOURCES_DIR_PROPERTY = "resources.dir"
-RESOURCES_DIR_DEFAULT = "resources"
 
 # stack repo upgrade
 STACK_LOCATION_KEY = 'metadata.path'
@@ -1102,9 +1101,27 @@ def get_java_exe_path():
 
 
 #
-# Stack upgrade
+# Server resource files location
 #
+def get_resources_location(properties):
+  err = 'Invalid directory'
+  try:
+    resources_dir = properties[RESOURCES_DIR_PROPERTY]
+    if not resources_dir:
+      resources_dir = configDefaults.SERVER_RESOURCES_DIR
+  except (KeyError), e:
+    err = 'Property ' + str(e) + ' is not defined at ' + properties.fileName
+    resources_dir = configDefaults.SERVER_RESOURCES_DIR
+
+  if not os.path.exists(os.path.abspath(resources_dir)):
+    msg = 'Resources dir ' + resources_dir + ' is incorrectly configured: ' + err
+    raise FatalException(1, msg)
+
+  return resources_dir
 
+#
+# Stack upgrade
+#
 def get_stack_location(properties):
   stack_location = properties[STACK_LOCATION_KEY]
   if stack_location is None:

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/python/ambari_server/serverSetup.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverSetup.py b/ambari-server/src/main/python/ambari_server/serverSetup.py
index 42b7d24..2b4e06b 100644
--- a/ambari-server/src/main/python/ambari_server/serverSetup.py
+++ b/ambari-server/src/main/python/ambari_server/serverSetup.py
@@ -34,20 +34,17 @@ from ambari_commons.os_utils import copy_files, run_os_command, is_root
 from ambari_commons.str_utils import compress_backslashes
 from ambari_server.dbConfiguration import DBMSConfigFactory, check_jdbc_drivers
 from ambari_server.serverConfiguration import configDefaults, JDKRelease, \
-  get_ambari_properties, get_full_ambari_classpath, get_java_exe_path, get_JAVA_HOME, get_value_from_properties, \
-  read_ambari_user, update_properties, validate_jdk, write_property, \
+  get_ambari_properties, get_full_ambari_classpath, get_is_secure, get_is_persisted, get_java_exe_path, get_JAVA_HOME, \
+  get_resources_location, get_value_from_properties, read_ambari_user, update_properties, validate_jdk, write_property, \
   JAVA_HOME, JAVA_HOME_PROPERTY, JCE_NAME_PROPERTY, JDBC_RCA_URL_PROPERTY, JDBC_URL_PROPERTY, \
   JDK_NAME_PROPERTY, JDK_RELEASES, NR_USER_PROPERTY, OS_FAMILY, OS_FAMILY_PROPERTY, OS_TYPE, OS_TYPE_PROPERTY, OS_VERSION, \
-  RESOURCES_DIR_PROPERTY, SERVICE_PASSWORD_KEY, SERVICE_USERNAME_KEY, VIEWS_DIR_PROPERTY, get_is_secure, \
-  get_is_persisted
+  SERVICE_PASSWORD_KEY, SERVICE_USERNAME_KEY, VIEWS_DIR_PROPERTY
 from ambari_server.serverUtils import is_server_runing
 from ambari_server.setupSecurity import adjust_directory_permissions
 from ambari_server.userInput import get_YN_input, get_validated_string_input
 from ambari_server.utils import locate_file
 
 
-
-
 # selinux commands
 GET_SE_LINUX_ST_CMD = locate_file('sestatus', '/usr/sbin')
 SE_SETENFORCE_CMD = "setenforce 0"
@@ -407,11 +404,7 @@ class JDKSetup(object):
 
     jdk_cfg = self.jdks[self.jdk_index]
 
-    try:
-      resources_dir = properties[RESOURCES_DIR_PROPERTY]
-    except (KeyError), e:
-      err = 'Property ' + str(e) + ' is not defined at ' + conf_file
-      raise FatalException(1, err)
+    resources_dir = get_resources_location(properties)
 
     dest_file = os.path.abspath(os.path.join(resources_dir, jdk_cfg.dest_file))
     if os.path.exists(dest_file):
@@ -472,16 +465,10 @@ class JDKSetup(object):
     self._ensure_java_home_env_var_is_set(java_home_dir)
 
   def download_and_unpack_jce_policy(self, properties):
-    conf_file = properties.fileName
-
     err_msg_stdout = "JCE Policy files are required for secure HDP setup. Please ensure " \
               " all hosts have the JCE unlimited strength policy 6, files."
 
-    try:
-      resources_dir = properties[RESOURCES_DIR_PROPERTY]
-    except (KeyError), e:
-      err = 'Property ' + str(e) + ' is not defined at ' + conf_file
-      raise FatalException(1, err)
+    resources_dir = get_resources_location(properties)
 
     jdk_cfg = self.jdks[self.jdk_index]
 
@@ -782,13 +769,8 @@ def _cache_jdbc_driver(args):
   if properties == -1:
     err = "Error getting ambari properties"
     raise FatalException(-1, err)
-  conf_file = properties.fileName
 
-  try:
-    resources_dir = properties[RESOURCES_DIR_PROPERTY]
-  except (KeyError), e:
-    err = 'Property ' + str(e) + ' is not defined at ' + conf_file
-    raise FatalException(1, err)
+  resources_dir = get_resources_location(properties)
 
   symlink_name = args.jdbc_db + "-jdbc-driver.jar"
   jdbc_symlink = os.path.join(resources_dir, symlink_name)
@@ -1023,22 +1005,29 @@ def setup(options):
 # Setup the JCE policy for Ambari Server.
 #
 def setup_jce_policy(args):
-  if os.path.exists(args[1]):
-    if not os.path.split(args[1])[0] == configDefaults.SERVER_RESOURCES_DIR:
-      try:
-        shutil.copy(args[1], configDefaults.SERVER_RESOURCES_DIR)
-      except Exception as e:
-        err = "Fail while trying to copy {0} to {1}. {2}".format(args[1], configDefaults.SERVER_RESOURCES_DIR, e)
-        raise FatalException(1, err)
-  else:
+  if not os.path.exists(args[1]):
     err = "Can not run 'setup-jce'. Invalid path {0}.".format(args[1])
     raise FatalException(1, err)
 
   properties = get_ambari_properties()
+  resources_dir = get_resources_location(properties)
+
+  zip_path = os.path.split(args[1])
+  zip_dir = zip_path[0]
+
+  if not zip_dir == resources_dir:
+    try:
+      shutil.copy(args[1], resources_dir)
+    except Exception as e:
+      err = "Fail while trying to copy {0} to {1}. {2}".format(args[1], resources_dir, e)
+      raise FatalException(1, err)
+
   jdk_path = properties.get_property(JAVA_HOME_PROPERTY)
-  resources_dir = properties.get_property(RESOURCES_DIR_PROPERTY)
+  if not jdk_path or not os.path.exists(jdk_path):
+    err = "JDK not installed, you need to run 'ambari-server setup' before attempting to install the JCE policy."
+    raise FatalException(1, err)
 
-  zip_name = os.path.split(args[1])[1]
+  zip_name = zip_path[1]
   properties.process_pair(JCE_NAME_PROPERTY, zip_name)
 
   print 'Installing JCE policy...'

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/python/ambari_server/serverUtils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverUtils.py b/ambari-server/src/main/python/ambari_server/serverUtils.py
index 199fada..7d76162 100644
--- a/ambari-server/src/main/python/ambari_server/serverUtils.py
+++ b/ambari-server/src/main/python/ambari_server/serverUtils.py
@@ -25,7 +25,7 @@ from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons.os_check import OSConst
 from ambari_commons.os_utils import run_os_command
 from ambari_server.resourceFilesKeeper import ResourceFilesKeeper, KeeperException
-from ambari_server.serverConfiguration import configDefaults, PID_NAME, get_ambari_properties, get_stack_location, \
+from ambari_server.serverConfiguration import configDefaults, PID_NAME, get_resources_location, get_stack_location, \
   CLIENT_API_PORT, SSL_API, DEFAULT_SSL_API_PORT, SSL_API_PORT
 
 
@@ -83,10 +83,9 @@ def is_server_runing():
 # Performs HDP stack housekeeping
 #
 def refresh_stack_hash(properties):
-  stack_location = get_stack_location(properties)
-  # Hack: we determine resource dir as a parent dir for stack_location
-  resources_location = os.path.dirname(stack_location)
-  resource_files_keeper = ResourceFilesKeeper(resources_location)
+  resources_location = get_resources_location(properties)
+  stacks_location = get_stack_location(properties)
+  resource_files_keeper = ResourceFilesKeeper(resources_location, stacks_location)
 
   try:
     print "Organizing resource files at {0}...".format(resources_location,

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/python/ambari_server_main.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server_main.py b/ambari-server/src/main/python/ambari_server_main.py
index d20a9cd..09dfc96 100644
--- a/ambari-server/src/main/python/ambari_server_main.py
+++ b/ambari-server/src/main/python/ambari_server_main.py
@@ -18,7 +18,6 @@ See the License for the specific language governing permissions and
 limitations under the License.
 '''
 import getpass
-
 import os
 import stat
 import subprocess
@@ -26,7 +25,7 @@ import tempfile
 import sys
 
 from ambari_commons.exceptions import FatalException
-from ambari_commons.logging_utils import get_debug_mode, get_verbose, print_warning_msg, print_info_msg, \
+from ambari_commons.logging_utils import get_debug_mode, print_warning_msg, print_info_msg, \
   set_debug_mode_from_options
 from ambari_commons.os_check import OSConst
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
@@ -34,9 +33,9 @@ from ambari_commons.os_utils import is_root
 from ambari_server.dbConfiguration import ensure_dbms_is_running, ensure_jdbc_driver_is_installed
 from ambari_server.serverConfiguration import configDefaults, find_jdk, get_ambari_classpath, get_ambari_properties, \
   get_conf_dir, get_is_persisted, get_is_secure, get_java_exe_path, get_original_master_key, read_ambari_user, \
-  PID_NAME, RESOURCES_DIR_DEFAULT, RESOURCES_DIR_PROPERTY, SECURITY_KEY_ENV_VAR_NAME, SECURITY_MASTER_KEY_LOCATION, \
+  PID_NAME, SECURITY_KEY_ENV_VAR_NAME, SECURITY_MASTER_KEY_LOCATION, \
   SETUP_OR_UPGRADE_MSG, check_database_name_property, parse_properties_file
-from ambari_server.serverUtils import is_server_runing, refresh_stack_hash
+from ambari_server.serverUtils import refresh_stack_hash
 from ambari_server.setupHttps import get_fqdn
 from ambari_server.setupSecurity import save_master_key
 from ambari_server.utils import check_reverse_lookup, save_pid, locate_file, looking_for_pid, wait_for_pid, \
@@ -106,13 +105,6 @@ ULIMIT_OPEN_FILES_KEY = 'ulimit.open.files'
 ULIMIT_OPEN_FILES_DEFAULT = 10000
 
 
-def get_resources_location(properties):
-  res_location = properties[RESOURCES_DIR_PROPERTY]
-  if res_location is None:
-    res_location = RESOURCES_DIR_DEFAULT
-  return res_location
-
-
 @OsFamilyFuncImpl(OSConst.WINSRV_FAMILY)
 def ensure_can_start_under_current_user(ambari_user):
   #Ignore the requirement to run as root. In Windows, by default the child process inherits the security context

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/main/windows/ambari-server.ps1
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/windows/ambari-server.ps1 b/ambari-server/src/main/windows/ambari-server.ps1
index 92f5186..690b1a9 100644
--- a/ambari-server/src/main/windows/ambari-server.ps1
+++ b/ambari-server/src/main/windows/ambari-server.ps1
@@ -262,7 +262,7 @@ switch ($($args[0])){
   }
   "upgrade"
   {
-    echo "Upgrade Ambari Server"
+    echo "Upgrading Ambari Server"
     _upgrade $args
     echo "Ambari Server Upgrade finished"
   }
@@ -291,9 +291,15 @@ switch ($($args[0])){
     _pstart $args
     echo "Ambari Server security setup finished"
   }
+  "refresh-stack-hash"
+  {
+    echo "Refreshing stack hash"
+    _pstart $args
+    echo "Refreshing stack hash finished"
+  }
   default
   {
-    echo "Usage: ambari-server {start|stop|restart|setup|upgrade|status|upgradestack|setup-ldap|setup-security} [options]"
+    echo "Usage: ambari-server {start|stop|restart|setup|upgrade|status|upgradestack|setup-ldap|setup-security|refresh-stack-hash} [options]"
     echo "Use ambari-server <action> --help to get details on options available."
     echo "Or, simply invoke ambari-server.py --help to print the options."
     $retcode=1

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index dcea3c6..cae847d 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -73,7 +73,8 @@ with patch("platform.linux_distribution", return_value = os_distro_value):
           LDAP_MGR_PASSWORD_PROPERTY, LDAP_MGR_PASSWORD_ALIAS, JDBC_PASSWORD_FILENAME, NR_USER_PROPERTY, SECURITY_KEY_IS_PERSISTED, \
           SSL_TRUSTSTORE_PASSWORD_PROPERTY, SECURITY_IS_ENCRYPTION_ENABLED, SSL_TRUSTSTORE_PASSWORD_ALIAS, \
           SECURITY_MASTER_KEY_LOCATION, SECURITY_KEYS_DIR, LDAP_PRIMARY_URL_PROPERTY, store_password_file, \
-          get_pass_file_path, GET_FQDN_SERVICE_URL, JDBC_USE_INTEGRATED_AUTH_PROPERTY, SECURITY_KEY_ENV_VAR_NAME
+          get_pass_file_path, GET_FQDN_SERVICE_URL, JDBC_USE_INTEGRATED_AUTH_PROPERTY, SECURITY_KEY_ENV_VAR_NAME, \
+          JAVA_HOME_PROPERTY
         from ambari_server.serverUtils import is_server_runing, refresh_stack_hash
         from ambari_server.serverSetup import check_selinux, check_ambari_user, proceedJDBCProperties, SE_STATUS_DISABLED, SE_MODE_ENFORCING, configure_os_settings, \
           download_and_install_jdk, prompt_db_properties, setup, \
@@ -2161,17 +2162,24 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     # Successful JDK download
     args.java_home = None
     validate_jdk_mock.return_value = False
+    path_existsMock.reset_mock()
+    path_existsMock.side_effect = [True, False, True, False]
     path_isfileMock.return_value = False
     args.jdk_location = None
     run_os_command_mock.return_value = (0, "Creating jdk1/jre" , None)
     statResult = MagicMock()
     statResult.st_size = 32000
     statMock.return_value = statResult
-    rcode = download_and_install_jdk(args)
+    try:
+      rcode = download_and_install_jdk(args)
+    except Exception, e:
+      raise
     self.assertEqual(0, rcode)
 
     # Test case: not accept the license"
     get_YN_input_mock.return_value = False
+    path_existsMock.reset_mock()
+    path_existsMock.side_effect = [True, False, True, False]
     download_and_install_jdk(args)
     self.assertTrue(exit_mock.called)
 
@@ -2180,7 +2188,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     get_JAVA_HOME_mock.return_value = "some_jdk"
     validate_jdk_mock.return_value = True
     get_YN_input_mock.return_value = False
-    path_existsMock.return_value = False
+    path_existsMock.reset_mock()
+    path_existsMock.side_effect = [True, False, True, False]
     force_download_file_mock.reset_mock()
     with patch("ambari_server.serverSetup.JDKSetup._download_jce_policy") as download_jce_policy_mock:
       rcode = download_and_install_jdk(args)
@@ -2191,7 +2200,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     update_properties_mock.reset_mock()
     args.java_home = "somewhere"
     validate_jdk_mock.return_value = True
-    path_existsMock.return_value = False
+    path_existsMock.reset_mock()
+    path_existsMock.side_effect = [True, False, True, False]
     get_JAVA_HOME_mock.return_value = "some_jdk"
     path_isfileMock.return_value = True
     download_and_install_jdk(args)
@@ -2216,7 +2226,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     args.jdk_location = None
     validate_jdk_mock.return_value = False
     update_properties_mock.reset_mock()
-    path_existsMock.side_effect = [False, True]
+    path_existsMock.reset_mock()
+    path_existsMock.side_effect = [True, True, True, True]
     get_validated_string_input_mock.return_value = "2"
     get_JAVA_HOME_mock.return_value = None
     rcode = download_and_install_jdk(args)
@@ -2226,8 +2237,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     # Test case: Setup ambari-server first time, Custom JDK selected, JDK not exists
     update_properties_mock.reset_mock()
     validate_jdk_mock.return_value = False
-    path_existsMock.side_effect = None
-    path_existsMock.return_value = False
+    path_existsMock.reset_mock()
+    path_existsMock.side_effect = [True, False, True, False]
     get_validated_string_input_mock.return_value = "2"
     get_JAVA_HOME_mock.return_value = None
     try:
@@ -2242,7 +2253,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     validate_jdk_mock.return_value = False
     path_isfileMock.return_value = False
     update_properties_mock.reset_mock()
-    path_existsMock.return_value = False
+    path_existsMock.reset_mock()
+    path_existsMock.side_effect = [True, False, True, False]
     get_validated_string_input_mock.return_value = "2"
     get_JAVA_HOME_mock.return_value = None
     flag = False
@@ -2258,7 +2270,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     #Test case: Setup ambari-server with java home passed. Path to java home doesn't exist
     args.java_home = "somewhere"
     validate_jdk_mock.return_value = False
-    path_existsMock.return_value = False
+    path_existsMock.reset_mock()
+    path_existsMock.side_effect = [True, False, True, False]
     try:
       download_and_install_jdk(args)
       self.fail("Should throw exception")
@@ -2759,7 +2772,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   def test_setup_jce_policy(self, open_mock, search_file_mock, get_ambari_properties_mock, unpack_jce_policy_mock,
                             update_properties_mock, path_split_mock, shutil_copy_mock, exists_mock):
     exists_mock.return_value = True
-    properties = MagicMock()
+    properties = Properties()
+    properties.process_pair(JAVA_HOME_PROPERTY, "/java_home")
     unpack_jce_policy_mock.return_value = 0
     get_ambari_properties_mock.return_value = properties
     conf_file = 'etc/ambari-server/conf/ambari.properties'
@@ -2814,6 +2828,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
       setup_jce_policy(args)
     except FatalException:
       self.assertTrue(True)
+    pass
 
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
   @patch("ambari_commons.firewall.run_os_command")
@@ -3256,7 +3271,6 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch("ambari_server.serverConfiguration.get_validated_string_input")
   @patch("os.environ")
   @patch("ambari_server.setupSecurity.get_ambari_properties")
-  @patch("ambari_server.serverUtils.get_ambari_properties")
   @patch("ambari_server.serverSetup.get_ambari_properties")
   @patch("ambari_server.serverConfiguration.get_ambari_properties")
   @patch("ambari_server_main.get_ambari_properties")
@@ -3282,7 +3296,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
                  find_jdk_mock, check_database_name_property_mock, search_file_mock,
                  popenMock, openMock, pexistsMock,
                  get_ambari_properties_mock, get_ambari_properties_2_mock, get_ambari_properties_3_mock,
-                 get_ambari_properties_4_mock, get_ambari_properties_5_mock, os_environ_mock,
+                 get_ambari_properties_4_mock, os_environ_mock,
                  get_validated_string_input_method, write_property_method,
                  os_chmod_method, get_is_secure_mock, get_is_persisted_mock,
                  save_master_key_method, get_master_key_location_method,
@@ -3291,6 +3305,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
                  wait_for_pid_mock, looking_for_pid_mock, stdout_write_mock, stdout_flush_mock):
 
     def reset_mocks():
+      pexistsMock.reset_mock()
+
       args = MagicMock()
       del args.dbms
       del args.database_index
@@ -3325,7 +3341,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     p = Properties()
     p.process_pair(SECURITY_IS_ENCRYPTION_ENABLED, 'False')
 
-    get_ambari_properties_5_mock.return_value = get_ambari_properties_4_mock.return_value = \
+    get_ambari_properties_4_mock.return_value = \
       get_ambari_properties_3_mock.return_value = get_ambari_properties_2_mock.return_value = \
       get_ambari_properties_mock.return_value = p
     get_is_secure_mock.return_value = False
@@ -3433,12 +3449,16 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     # Test exception handling on resource files housekeeping
     perform_housekeeping_mock.reset_mock()
     perform_housekeeping_mock.side_effect = KeeperException("some_reason")
+
+    pexistsMock.return_value = True
+
     try:
       _ambari_server_.start(args)
       self.fail("Should fail with exception")
     except FatalException as e:
       self.assertTrue('some_reason' in e.reason)
     self.assertTrue(perform_housekeeping_mock.called)
+
     perform_housekeeping_mock.side_effect = lambda *v, **kv : None
     perform_housekeeping_mock.reset_mock()
 
@@ -3827,11 +3847,12 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
   @patch("os.path.isfile")
   @patch("ambari_server.serverSetup.get_ambari_properties")
+  @patch("os.path.exists")
   @patch("os.path.lexists")
   @patch("os.remove")
   @patch("os.symlink")
   @patch("shutil.copy")
-  def test_proceedJDBCProperties(self, copy_mock, os_symlink_mock, os_remove_mock, lexists_mock,
+  def test_proceedJDBCProperties(self, copy_mock, os_symlink_mock, os_remove_mock, lexists_mock, exists_mock,
                                  get_ambari_properties_mock, isfile_mock):
     args = MagicMock()
 
@@ -3876,6 +3897,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     p = MagicMock()
     get_ambari_properties_mock.return_value = p
     p.__getitem__.side_effect = KeyError("test exception")
+    exists_mock.return_value = False
     fail = False
 
     try:
@@ -3889,6 +3911,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     args.jdbc_db = "postgres"
     get_ambari_properties_mock.return_value = MagicMock()
     isfile_mock.side_effect = [True, False]
+    exists_mock.return_value = True
     fail = False
 
     def side_effect():
@@ -3927,6 +3950,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch("__builtin__.open")
   @patch("os.path.isfile")
   @patch("os.path.lexists")
+  @patch("os.path.exists")
   @patch("os.remove")
   @patch("os.symlink")
   @patch.object(Properties, "store")
@@ -3950,7 +3974,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
                             is_root_mock, update_ambari_properties_mock, find_properties_file_mock, run_os_command_mock,
                             run_schema_upgrade_mock, read_ambari_user_mock, print_warning_msg_mock,
                             adjust_directory_permissions_mock, properties_store_mock,
-                            os_symlink_mock, os_remove_mock, lexists_mock, isfile_mock, open_mock):
+                            os_symlink_mock, os_remove_mock, exists_mock, lexists_mock, isfile_mock, open_mock):
 
     def reset_mocks():
       run_os_command_mock.reset_mock()
@@ -4043,6 +4067,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     get_ambari_properties_mock.return_value = properties
     get_ambari_properties_3_mock.side_effect = get_ambari_properties_2_mock.side_effect = [properties, properties2, properties2]
 
+    exists_mock.return_value = True
+
     try:
       upgrade(args)
     except FatalException as fe:
@@ -4102,8 +4128,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
       self.assertTrue(write_property_mock.called)
       self.assertFalse(move_user_custom_actions_mock.called)
       self.assertTrue(os_symlink_mock.called)
-      self.assertTrue(os_symlink_mock.call_args_list[0][0][0] == "mysql-connector-java.jar")
-      self.assertTrue(os_symlink_mock.call_args_list[0][0][1] == "mysql-jdbc-driver.jar")
+      self.assertTrue(os_symlink_mock.call_args_list[0][0][0] == "/var/lib/ambari-server/resources/mysql-connector-java.jar")
+      self.assertTrue(os_symlink_mock.call_args_list[0][0][1] == "/var/lib/ambari-server/resources/mysql-jdbc-driver.jar")
 
     args = reset_mocks()
 
@@ -4131,6 +4157,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
   @patch("__builtin__.open")
   @patch("os.path.isfile")
+  @patch("os.path.exists")
   @patch("os.path.lexists")
   @patch("os.remove")
   @patch("os.symlink")
@@ -4159,7 +4186,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
                    read_ambari_user_mock, print_warning_msg_mock,
                    adjust_directory_permissions_mock,
                    find_properties_file_mock, change_db_files_owner_mock, properties_store_mock,
-                   os_symlink_mock, os_remove_mock, lexists_mock, isfile_mock, open_mock):
+                   os_symlink_mock, os_remove_mock, lexists_mock, exists_mock, isfile_mock, open_mock):
 
     def reset_mocks():
       isfile_mock.reset_mock()
@@ -4210,6 +4237,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     read_ambari_user_mock.return_value = None
     run_schema_upgrade_mock.return_value = 0
     change_db_files_owner_mock.return_value = 0
+    exists_mock.return_value = True
     upgrade(args)
     self.assertTrue(print_warning_msg_mock.called)
     warning_args = print_warning_msg_mock.call_args[0][0]
@@ -4276,6 +4304,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     get_ambari_properties_3_mock.return_value = get_ambari_properties_2_mock.return_value = \
       get_ambari_properties_mock.return_value = p
     p.__getitem__.side_effect = ["something", "something", "something", KeyError("test exception")]
+    exists_mock.return_value = False
     fail = False
 
     try:
@@ -4293,6 +4322,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
 
     get_ambari_properties_3_mock.return_value = get_ambari_properties_2_mock.return_value = \
       get_ambari_properties_mock.return_value = props
+    exists_mock.return_value = True
     lexists_mock.return_value = True
     isfile_mock.side_effect = [True, False]
 
@@ -6543,9 +6573,12 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     run_metainfo_upgrade_mock.assert_called_with({})
     pass
 
+  @patch("os.path.exists")
   @patch.object(ResourceFilesKeeper, "perform_housekeeping")
   def test_refresh_stack_hash(self,
-    perform_housekeeping_mock):
+    perform_housekeeping_mock, path_exists_mock):
+
+    path_exists_mock.return_value = True
 
     properties = Properties()
     refresh_stack_hash(properties)

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/test/python/TestOSCheck.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestOSCheck.py b/ambari-server/src/test/python/TestOSCheck.py
index d030c52..ebef706 100644
--- a/ambari-server/src/test/python/TestOSCheck.py
+++ b/ambari-server/src/test/python/TestOSCheck.py
@@ -43,11 +43,11 @@ with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
 
 class TestOSCheck(TestCase):
   @patch.object(OSCheck, "os_distribution")
-  @patch("os.path.exists")
-  def test_get_os_type(self, mock_exists, mock_linux_distribution):
+  @patch("ambari_commons.os_check._is_oracle_linux")
+  def test_get_os_type(self, mock_is_oracle_linux, mock_linux_distribution):
 
     # 1 - Any system
-    mock_exists.return_value = False
+    mock_is_oracle_linux.return_value = False
     mock_linux_distribution.return_value = ('my_os', '', '')
     result = OSCheck.get_os_type()
     self.assertEquals(result, 'my_os')
@@ -63,19 +63,19 @@ class TestOSCheck(TestCase):
       pass
 
     # 3 - path exist: '/etc/oracle-release'
-    mock_exists.return_value = True
+    mock_is_oracle_linux.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_is_oracle_linux.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
+    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()

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/test/python/TestResourceFilesKeeper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestResourceFilesKeeper.py b/ambari-server/src/test/python/TestResourceFilesKeeper.py
index 88cf137..3a9e20f 100644
--- a/ambari-server/src/test/python/TestResourceFilesKeeper.py
+++ b/ambari-server/src/test/python/TestResourceFilesKeeper.py
@@ -34,6 +34,7 @@ from ambari_server.resourceFilesKeeper import ResourceFilesKeeper, KeeperExcepti
 
 class TestResourceFilesKeeper(TestCase):
 
+  TEST_RESOURCES_DIR = "../resources"
   TEST_STACKS_DIR="../resources/stacks"
 
   # Stack that is not expected to change
@@ -66,9 +67,10 @@ class TestResourceFilesKeeper(TestCase):
 
   @patch.object(ResourceFilesKeeper, "update_directory_archieves")
   def test_perform_housekeeping(self, update_directory_archieves_mock):
-    resource_files_keeper = ResourceFilesKeeper("/dummy-path")
+    resource_files_keeper = ResourceFilesKeeper("/dummy-resources", "/dummy-path")
     resource_files_keeper.perform_housekeeping()
     update_directory_archieves_mock.assertCalled()
+    pass
 
 
   @patch.object(ResourceFilesKeeper, "update_directory_archive")
@@ -85,7 +87,7 @@ class TestResourceFilesKeeper(TestCase):
     list_common_services_mock.return_value = [self.DUMMY_UNCHANGEABLE_COMMON_SERVICES,
                                               self.DUMMY_UNCHANGEABLE_COMMON_SERVICES]
     abspath_mock.side_effect = lambda s : s
-    resource_files_keeper = ResourceFilesKeeper(self.TEST_STACKS_DIR)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.TEST_STACKS_DIR)
     resource_files_keeper.update_directory_archieves()
     self.assertEquals(pprint.pformat(
       update_directory_archive_mock.call_args_list),
@@ -99,14 +101,15 @@ class TestResourceFilesKeeper(TestCase):
             "dummy_common_services/HIVE/0.11.0.2.0.5.0/package'),\n "
             "call('../resources/TestAmbaryServer.samples/"
             "dummy_common_services/HIVE/0.11.0.2.0.5.0/package'),\n "
-            "call('../resources/stacks/custom_actions'),\n "
-            "call('../resources/stacks/host_scripts')]")
+            "call('../resources/custom_actions'),\n "
+            "call('../resources/host_scripts')]")
+    pass
 
 
   @patch("glob.glob")
   @patch("os.path.exists")
   def test_list_stacks(self, exists_mock, glob_mock):
-    resource_files_keeper = ResourceFilesKeeper(self.SOME_PATH)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.SOME_PATH)
     # Test normal execution flow
     glob_mock.return_value = ["stack1", "stack2", "stack3"]
     exists_mock.side_effect = [True, False, True]
@@ -127,7 +130,7 @@ class TestResourceFilesKeeper(TestCase):
   @patch("glob.glob")
   @patch("os.path.exists")
   def test_list_common_services(self, exists_mock, glob_mock):
-    resource_files_keeper = ResourceFilesKeeper(self.SOME_PATH)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.SOME_PATH)
     # Test normal execution flow
     glob_mock.return_value = ["common_service1", "common_service2", "common_service3"]
     exists_mock.side_effect = [True, False, True]
@@ -154,7 +157,7 @@ class TestResourceFilesKeeper(TestCase):
     # Test situation when there is no saved directory hash
     read_hash_sum_mock.return_value = None
     count_hash_sum_mock.return_value = self.YA_HASH
-    resource_files_keeper = ResourceFilesKeeper(self.SOME_PATH)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.SOME_PATH)
     resource_files_keeper.update_directory_archive(self.SOME_PATH)
     self.assertTrue(read_hash_sum_mock.called)
     self.assertTrue(count_hash_sum_mock.called)
@@ -218,17 +221,18 @@ class TestResourceFilesKeeper(TestCase):
     # Test nozip option
     read_hash_sum_mock.return_value = None
     count_hash_sum_mock.return_value = self.YA_HASH
-    resource_files_keeper = ResourceFilesKeeper(self.SOME_PATH, nozip=True)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.SOME_PATH, nozip=True)
     resource_files_keeper.update_directory_archive(self.SOME_PATH)
     self.assertTrue(read_hash_sum_mock.called)
     self.assertTrue(count_hash_sum_mock.called)
     self.assertFalse(zip_directory_mock.called)
     self.assertTrue(write_hash_sum_mock.called)
+    pass
 
 
   def test_count_hash_sum(self):
     # Test normal flow
-    resource_files_keeper = ResourceFilesKeeper(self.DUMMY_UNCHANGEABLE_PACKAGE)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.DUMMY_UNCHANGEABLE_PACKAGE)
     test_dir = os.path.join(self.DUMMY_UNCHANGEABLE_PACKAGE)
     hash_sum = resource_files_keeper.count_hash_sum(test_dir)
     self.assertEquals(hash_sum, self.DUMMY_UNCHANGEABLE_PACKAGE_HASH)
@@ -246,7 +250,7 @@ class TestResourceFilesKeeper(TestCase):
 
 
   def test_read_hash_sum(self):
-    resource_files_keeper = ResourceFilesKeeper(self.DUMMY_UNCHANGEABLE_PACKAGE)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.DUMMY_UNCHANGEABLE_PACKAGE)
     hash_sum = resource_files_keeper.read_hash_sum(self.DUMMY_UNCHANGEABLE_PACKAGE)
     self.assertEquals(hash_sum, "dummy_hash")
 
@@ -272,11 +276,12 @@ class TestResourceFilesKeeper(TestCase):
         open_mock.side_effect = self.exc_side_effect
         res = resource_files_keeper.read_hash_sum("path-to-directory")
         self.assertEqual(res, None)
+    pass
 
 
   def test_write_hash_sum(self):
     NEW_HASH = "new_hash"
-    resource_files_keeper = ResourceFilesKeeper(self.DUMMY_UNCHANGEABLE_PACKAGE)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.DUMMY_UNCHANGEABLE_PACKAGE)
     resource_files_keeper.write_hash_sum(
       self.DUMMY_UNCHANGEABLE_PACKAGE, NEW_HASH)
     hash_sum = resource_files_keeper.read_hash_sum(self.DUMMY_UNCHANGEABLE_PACKAGE)
@@ -302,7 +307,7 @@ class TestResourceFilesKeeper(TestCase):
 
   def test_zip_directory(self):
     # Test normal flow
-    resource_files_keeper = ResourceFilesKeeper(self.DUMMY_UNCHANGEABLE_PACKAGE)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.DUMMY_UNCHANGEABLE_PACKAGE)
     resource_files_keeper.zip_directory(self.DUMMY_UNCHANGEABLE_PACKAGE)
     arc_file = os.path.join(self.DUMMY_UNCHANGEABLE_PACKAGE,
                             ResourceFilesKeeper.ARCHIVE_NAME)
@@ -328,12 +333,13 @@ class TestResourceFilesKeeper(TestCase):
 
 
   def test_is_ignored(self):
-    resource_files_keeper = ResourceFilesKeeper(self.DUMMY_UNCHANGEABLE_PACKAGE)
+    resource_files_keeper = ResourceFilesKeeper(self.TEST_RESOURCES_DIR, self.DUMMY_UNCHANGEABLE_PACKAGE)
     self.assertTrue(resource_files_keeper.is_ignored(".hash"))
     self.assertTrue(resource_files_keeper.is_ignored("archive.zip"))
     self.assertTrue(resource_files_keeper.is_ignored("dummy.pyc"))
     self.assertFalse(resource_files_keeper.is_ignored("dummy.py"))
     self.assertFalse(resource_files_keeper.is_ignored("1.sh"))
+    pass
 
 
   def exc_side_effect(self, *a):

http://git-wip-us.apache.org/repos/asf/ambari/blob/190bd0b0/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py b/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
index 8194bba..58e9a31 100644
--- a/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
+++ b/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
@@ -22,8 +22,17 @@ from mock.mock import patch, MagicMock
 from ambari_commons.os_check import OSCheck
 from stacks.utils.RMFTestCase import *
 
+from only_for_platform import get_platform, not_for_platform, only_for_platform, PLATFORM_LINUX, PLATFORM_WINDOWS
+
+if get_platform() != PLATFORM_WINDOWS:
+  os_distro_value = ('Suse','11','Final')
+  from pwd import getpwnam
+else:
+  #No Windows tests for now, but start getting prepared
+  os_distro_value = ('win2012serverr2','6.3','WindowsServer')
 
 class TestAlertDiskSpace(RMFTestCase):
+  @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
   @patch('alert_disk_space._get_disk_usage')
   @patch("os.path.isdir")
   @patch.object(OSCheck, "get_os_family", new = MagicMock(return_value = 'redhat'))