ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fba...@apache.org
Subject ambari git commit: AMBARI-10747 [WinTP2] Ambari server: HDPWIN stack - Ensure the specific hadoop users can be domain users
Date Fri, 01 May 2015 17:37:12 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 99d96d15c -> 77e4d50c8


AMBARI-10747 [WinTP2] Ambari server: HDPWIN stack - Ensure the specific hadoop users can be domain users

Taking corrective action to switch the hadoop user to <domain>\hadoop for each active service after installation.


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

Branch: refs/heads/trunk
Commit: 77e4d50c8c4c73ee446f01b05ea1d1d17567197b
Parents: 99d96d1
Author: Florian Barca <fbarca@hortonworks.com>
Authored: Fri May 1 10:37:04 2015 -0700
Committer: Florian Barca <fbarca@hortonworks.com>
Committed: Fri May 1 10:37:04 2015 -0700

----------------------------------------------------------------------
 .../core/providers/__init__.py                  |   2 +
 .../core/providers/service.py                   |   3 +
 .../core/providers/windows/service.py           | 211 ++++++++++++++++---
 .../core/resources/service.py                   |  15 +-
 .../libraries/functions/install_hdp_msi.py      |  16 +-
 .../functions/windows_service_utils.py          |  38 ++--
 .../libraries/script/script.py                  |   3 +-
 .../ambari_server/dbConfiguration_windows.py    |   3 -
 .../main/python/ambari_server/serverSetup.py    |   4 +-
 .../Ambari-DDL-SQLServer-CREATELOCAL.sql        |   1 +
 .../AMBARI_METRICS/0.1.0/package/scripts/ams.py |  17 +-
 .../0.1.0/package/scripts/params_windows.py     |   4 +
 .../FALCON/0.5.0.2.1/package/scripts/falcon.py  |   4 +
 .../0.5.0.2.1/package/scripts/status_params.py  |   2 +
 .../FLUME/1.4.0.2.0/package/scripts/flume.py    |   7 +
 .../1.4.0.2.0/package/scripts/params_windows.py |   6 +-
 .../HBASE/0.96.0.2.0/package/scripts/hbase.py   |   8 +
 .../package/scripts/params_windows.py           |  10 +-
 .../HDFS/2.1.0.2.0/package/scripts/hdfs.py      |   7 +
 .../2.1.0.2.0/package/scripts/journalnode.py    |   2 +-
 .../HDFS/2.1.0.2.0/package/scripts/namenode.py  |   6 +-
 .../2.1.0.2.0/package/scripts/params_windows.py |  11 +-
 .../2.1.0.2.0/package/scripts/status_params.py  |   1 +
 .../2.1.0.2.0/package/scripts/zkfc_slave.py     |   2 +-
 .../HIVE/0.12.0.2.0/package/scripts/hive.py     |   8 +
 .../package/scripts/params_windows.py           |  15 +-
 .../HIVE/0.12.0.2.0/package/scripts/webhcat.py  |   5 +
 .../KNOX/0.5.0.2.2/package/scripts/knox.py      |   9 +-
 .../KNOX/0.5.0.2.2/package/scripts/knox_ldap.py |  21 +-
 .../0.5.0.2.2/package/scripts/params_windows.py |   5 +-
 .../OOZIE/4.0.0.2.0/package/scripts/oozie.py    |  22 +-
 .../4.0.0.2.0/package/scripts/params_windows.py |   3 +-
 .../package/scripts/params_windows.py           |   5 +-
 .../package/scripts/params_windows.py           |   5 +-
 .../STORM/0.9.1.2.1/package/scripts/nimbus.py   |   3 +-
 .../0.9.1.2.1/package/scripts/params_windows.py |   9 +-
 .../STORM/0.9.1.2.1/package/scripts/storm.py    |  20 +-
 .../0.9.1.2.1/package/scripts/supervisor.py     |   2 +-
 .../0.9.1.2.1/package/scripts/ui_server.py      |   2 +-
 .../0.4.0.2.1/package/scripts/params_windows.py |   3 +-
 .../2.1.0.2.0/package/scripts/params_windows.py |   9 +-
 .../YARN/2.1.0.2.0/package/scripts/service.py   |   3 +-
 .../2.1.0.2.0/package/scripts/status_params.py  |  12 +-
 .../YARN/2.1.0.2.0/package/scripts/yarn.py      |   8 +
 .../3.4.5.2.0/package/scripts/params_windows.py |   3 +-
 .../3.4.5.2.0/package/scripts/zookeeper.py      |   6 +
 .../2.1/hooks/after-INSTALL/scripts/params.py   |   3 +-
 .../2.1/hooks/before-START/scripts/params.py    |   2 +-
 .../ambari/server/upgrade/UpgradeTest.java      |  12 +-
 .../hooks/before-START/test_before_start.py     |   1 +
 50 files changed, 463 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-common/src/main/python/resource_management/core/providers/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/__init__.py b/ambari-common/src/main/python/resource_management/core/providers/__init__.py
index b7f94e5..0cefd12 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/__init__.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/__init__.py
@@ -55,6 +55,7 @@ PROVIDERS = dict(
   ),
   winsrv=dict(
     Service="resource_management.core.providers.windows.service.ServiceProvider",
+    ServiceConfig="resource_management.core.providers.windows.service.ServiceConfigProvider",
     Execute="resource_management.core.providers.windows.system.ExecuteProvider",
     File="resource_management.core.providers.windows.system.FileProvider",
     Directory="resource_management.core.providers.windows.system.DirectoryProvider"
@@ -69,6 +70,7 @@ PROVIDERS = dict(
     User="resource_management.core.providers.accounts.UserProvider",
     Group="resource_management.core.providers.accounts.GroupProvider",
     Service="resource_management.core.providers.service.ServiceProvider",
+    ServiceConfig="resource_management.core.providers.service.ServiceConfigProvider",
   ),
 )
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-common/src/main/python/resource_management/core/providers/service.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/service.py b/ambari-common/src/main/python/resource_management/core/providers/service.py
index 23b1b3a..50167f1 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/service.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/service.py
@@ -94,3 +94,6 @@ class ServiceProvider(Provider):
       self.__upstart = os.path.exists("/sbin/start") \
         and os.path.exists("/etc/init/%s.conf" % self.resource.service_name)
     return self.__upstart
+
+class ServiceConfigProvider(Provider):
+  pass

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-common/src/main/python/resource_management/core/providers/windows/service.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/windows/service.py b/ambari-common/src/main/python/resource_management/core/providers/windows/service.py
index ba08899..174acea 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/windows/service.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/windows/service.py
@@ -18,34 +18,47 @@ limitations under the License.
 Ambari Agent
 
 """
-from resource_management.core.providers import Provider
-from resource_management.core.base import Fail
-import win32service
 import time
+import win32api
+import win32service
+import win32serviceutil
+import winerror
+
+from ambari_commons.os_windows import WinServiceController
+
+from resource_management.core.base import Fail
+from resource_management.core.providers import Provider
 
 
-_schSCManager = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS)
+def safe_open_scmanager():
+  try:
+    _schSCManager = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS)
+  except win32api.error, details:
+    raise Fail("Error opening Service Control Manager on the local machine: {0}".format(details.winerror))
 
+  return _schSCManager
+
+def safe_open_service(hSCM, service_name):
+  try:
+    hSvc = win32serviceutil.SmartOpenService(hSCM, service_name,
+                                             win32service.SERVICE_ALL_ACCESS)
+  except win32api.error, details:
+    if details.winerror == winerror.ERROR_SERVICE_DOES_NOT_EXIST:
+      err_msg = "Invalid service name: {0}".format(service_name)
+    else:
+      err_msg = "Error configuring service {0}: {1}".format(service_name, details.winerror)
+    raise Fail(err_msg)
+
+  return hSvc
 
 class ServiceProvider(Provider):
   def action_start(self):
-    self._service_handle = self._service_handle if hasattr(self, "_service_handle") else \
-      win32service.OpenService(_schSCManager, self.resource.service_name, win32service.SERVICE_ALL_ACCESS)
-    if not self.status():
-      self.enable()
-      win32service.StartService(self._service_handle, None)
-      self.wait_status(win32service.SERVICE_RUNNING)
+    WinServiceController.Start(self.resource.service_name, 5)
 
   def action_stop(self):
-    self._service_handle = self._service_handle if hasattr(self, "_service_handle") else \
-      win32service.OpenService(_schSCManager, self.resource.service_name, win32service.SERVICE_ALL_ACCESS)
-    if self.status():
-      win32service.ControlService(self._service_handle, win32service.SERVICE_CONTROL_STOP)
-      self.wait_status(win32service.SERVICE_STOPPED)
+    WinServiceController.Stop(self.resource.service_name, 5)
 
   def action_restart(self):
-    self._service_handle = win32service.OpenService(_schSCManager, self.resource.service_name,
-                                                    win32service.SERVICE_ALL_ACCESS)
     self.action_stop()
     self.action_start()
 
@@ -53,23 +66,34 @@ class ServiceProvider(Provider):
     raise Fail("Reload for Service resource not supported on windows")
 
   def status(self):
-    if win32service.QueryServiceStatusEx(self._service_handle)["CurrentState"] == win32service.SERVICE_RUNNING:
+    svcStatus = WinServiceController.QueryStatus(self.resource.service_name)
+    if svcStatus == win32service.SERVICE_RUNNING:
       return True
     return False
 
   def enable(self):
-    if win32service.QueryServiceConfig(self._service_handle)[1] == win32service.SERVICE_DISABLED:
-      win32service.ChangeServiceConfig(self._service_handle,
-                                       win32service.SERVICE_NO_CHANGE,
-                                       win32service.SERVICE_DEMAND_START,
-                                       win32service.SERVICE_NO_CHANGE,
-                                       None,
-                                       None,
-                                       0,
-                                       None,
-                                       None,
-                                       None,
-                                       None)
+    hSCM = safe_open_scmanager()
+
+    try:
+      hSvc = safe_open_service(hSCM, self.resource.service_name)
+
+      if win32service.QueryServiceConfig(hSvc)[1] == win32service.SERVICE_DISABLED:
+        win32service.ChangeServiceConfig(hSvc,
+                                         win32service.SERVICE_NO_CHANGE,
+                                         win32service.SERVICE_DEMAND_START,
+                                         win32service.SERVICE_NO_CHANGE,
+                                         None,
+                                         None,
+                                         0,
+                                         None,
+                                         None,
+                                         None,
+                                         None)
+      win32service.CloseServiceHandle(hSvc)
+    except win32api.error, details:
+      raise Fail("Error enabling service {0}: {1}".format(self.resource.service_name, details.winerror))
+    finally:
+      win32service.CloseServiceHandle(hSCM)
 
   def get_current_status(self):
     return win32service.QueryServiceStatusEx(self._service_handle)["CurrentState"]
@@ -77,4 +101,129 @@ class ServiceProvider(Provider):
   def wait_status(self, status, timeout=5):
     begin = time.time()
     while self.get_current_status() != status and (timeout == 0 or time.time() - begin < timeout):
-      time.sleep(1)
\ No newline at end of file
+      time.sleep(1)
+
+
+class ServiceConfigProvider(Provider):
+  def action_install(self):
+    hSCM = safe_open_scmanager()
+
+    self._fix_system_user_name()
+
+    try:
+      hSvc = win32service.CreateService(hSCM,
+                                        self.resource.service_name,
+                                        self.resource.display_name,
+                                        win32service.SERVICE_ALL_ACCESS,         # desired access
+                                        win32service.SERVICE_WIN32_OWN_PROCESS,  # service type
+                                        self.resource.start_type,
+                                        win32service.SERVICE_ERROR_NORMAL,       # error control type
+                                        self.resource.exe_path,
+                                        None,
+                                        0,
+                                        None,
+                                        self.resource.userName,
+                                        self.resource.password)
+      if self.resource.description:
+        try:
+          win32service.ChangeServiceConfig2(hSvc, win32service.SERVICE_CONFIG_DESCRIPTION, self.description)
+        except NotImplementedError:
+          pass    ## ChangeServiceConfig2 and description do not exist on NT
+
+      win32service.CloseServiceHandle(hSvc)
+    except win32api.error, details:
+      raise Fail("Error creating service {0}: {1}".format(self.resource.service_name, details.winerror))
+    finally:
+      win32service.CloseServiceHandle(hSCM)
+
+  def action_configure(self):
+    hSCM = safe_open_scmanager()
+
+    try:
+      hSvc = safe_open_service(hSCM, self.resource.service_name)
+
+      self._fix_system_user_name()
+
+      try:
+        win32service.ChangeServiceConfig(hSvc,
+                                         win32service.SERVICE_NO_CHANGE,
+                                         self.resource.startType,
+                                         win32service.SERVICE_NO_CHANGE,
+                                         None,
+                                         None,
+                                         0,
+                                         None,
+                                         self.resource.username,
+                                         self.resource.password,
+                                         self.resource.displayName)
+        if self.resource.description:
+          try:
+            win32service.ChangeServiceConfig2(hSvc, win32service.SERVICE_CONFIG_DESCRIPTION, self.resource.description)
+          except NotImplementedError:
+            pass    ## ChangeServiceConfig2 and description do not exist on NT
+      except win32api.error, details:
+        raise Fail("Error configuring service {0}: {1}".format(self.resource.service_name, details.winerror))
+      finally:
+        win32service.CloseServiceHandle(hSvc)
+    finally:
+      win32service.CloseServiceHandle(hSCM)
+
+  def action_change_user(self):
+    hSCM = safe_open_scmanager()
+
+    try:
+      hSvc = safe_open_service(hSCM, self.resource.service_name)
+
+      self._fix_system_user_name()
+
+      try:
+        win32service.ChangeServiceConfig(hSvc,
+                                         win32service.SERVICE_NO_CHANGE,
+                                         win32service.SERVICE_NO_CHANGE,
+                                         win32service.SERVICE_NO_CHANGE,
+                                         None,
+                                         None,
+                                         0,
+                                         None,
+                                         self.resource.username,
+                                         self.resource.password,
+                                         None)
+      except win32api.error, details:
+        raise Fail("Error changing user for service {0}: {1}".format(self.resource.service_name, details.winerror))
+      finally:
+        win32service.CloseServiceHandle(hSvc)
+    finally:
+      win32service.CloseServiceHandle(hSCM)
+
+  def action_uninstall(self):
+    hSCM = safe_open_scmanager()
+
+    try:
+      try:
+        hSvc = win32serviceutil.SmartOpenService(hSCM, self.resource.service_name,
+                                                 win32service.SERVICE_ALL_ACCESS)
+      except win32api.error, details:
+        if details.winerror == winerror.ERROR_SERVICE_DOES_NOT_EXIST:
+          # Nothing to do
+          return
+        else:
+          raise Fail("Error removing service {0}: {1}".format(self.resource.service_name, details.winerror))
+
+      try:
+        win32service.DeleteService(hSvc)
+      except win32api.error:
+        # Error mostly means the service is running and its removal is delayed until the next opportunity
+        pass
+      finally:
+        win32service.CloseServiceHandle(hSvc)
+    finally:
+      win32service.CloseServiceHandle(hSCM)
+
+  def _fix_system_user_name(self):
+    if self.resource.username.upper() == "NT AUTHORITY\\SYSTEM":
+      self.resource.username = None
+
+  def _is_system_user(self):
+    if self.resource.username in ["NT AUTHORITY\\SYSTEM", "NT AUTHORITY\\NetworkService", "NT AUTHORITY\\LocalService"]:
+      return True
+    return False
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-common/src/main/python/resource_management/core/resources/service.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/resources/service.py b/ambari-common/src/main/python/resource_management/core/resources/service.py
index 20d5c1b..cb202cf 100644
--- a/ambari-common/src/main/python/resource_management/core/resources/service.py
+++ b/ambari-common/src/main/python/resource_management/core/resources/service.py
@@ -20,7 +20,7 @@ Ambari Agent
 
 """
 
-__all__ = ["Service"]
+__all__ = ["Service", "ServiceConfig"]
 
 from resource_management.core.base import Resource, ResourceArgument, ForcedListArgument
 
@@ -36,3 +36,16 @@ class Service(Resource):
   status_command = ResourceArgument()
 
   actions = ["nothing", "start", "stop", "restart", "reload"]
+
+class ServiceConfig(Resource):
+  action = ForcedListArgument(default="install")
+  service_name = ResourceArgument(default=lambda obj: obj.name)
+  display_name = ResourceArgument()
+  description = ResourceArgument()
+  start_type = ResourceArgument()
+  #exe_path = ResourceArgument()
+  #arguments = ResourceArgument()
+  username = ResourceArgument()
+  password = ResourceArgument()
+
+  actions = ["nothing", "install", "configure", "change_user", "uninstall"]

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-common/src/main/python/resource_management/libraries/functions/install_hdp_msi.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/install_hdp_msi.py b/ambari-common/src/main/python/resource_management/libraries/functions/install_hdp_msi.py
index ddb99e1..12ccc51 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/install_hdp_msi.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/install_hdp_msi.py
@@ -93,24 +93,24 @@ OOZIE_DB_PASSWORD=oozie
 """
 
 INSTALL_MSI_CMD = 'cmd /C start /wait msiexec /qn /i  {hdp_msi_path} /lv {hdp_log_path} MSIUSEREALADMINDETECTION=1 ' \
-                  'HDP_LAYOUT={hdp_layout_path} DESTROY_DATA=yes HDP_USER_PASSWORD={hadoop_password_arg} HDP=yes ' \
+                  'HDP_LAYOUT={hdp_layout_path} DESTROY_DATA=yes HDP_USER={hadoop_user} HDP_USER_PASSWORD={hadoop_password_arg} HDP=yes ' \
                   'KNOX=yes KNOX_MASTER_SECRET="AmbariHDP2Windows" FALCON=yes STORM=yes HBase=yes STORM=yes FLUME=yes SLIDER=yes PHOENIX=yes RANGER=no'
 CREATE_SERVICE_SCRIPT = os.path.abspath("sbin\createservice.ps1")
-CREATE_SERVICE_CMD = 'cmd /C powershell -File "{script}" -username hadoop -password "{password}" -servicename ' \
+CREATE_SERVICE_CMD = 'cmd /C powershell -File "{script}" -username {username} -password "{password}" -servicename ' \
                      '{servicename} -hdpresourcesdir "{resourcedir}" -servicecmdpath "{servicecmd}"'
 INSTALL_MARKER_OK = "msi.installed"
 INSTALL_MARKER_FAILED = "msi.failed"
 _working_dir = None
 
 
-def _ensure_services_created(hadoop_password):
+def _ensure_services_created(hadoop_user, hadoop_password):
   resource_dir_hdfs = os.path.join(os.environ["HADOOP_HDFS_HOME"], "bin")
   service_cmd_hdfs = os.path.join(os.environ["HADOOP_HDFS_HOME"], "bin", "hdfs.cmd")
   if not check_windows_service_exists("journalnode"):
-    Execute(CREATE_SERVICE_CMD.format(script=CREATE_SERVICE_SCRIPT, password=hadoop_password, servicename="journalnode",
+    Execute(CREATE_SERVICE_CMD.format(script=CREATE_SERVICE_SCRIPT, username=hadoop_user, password=hadoop_password, servicename="journalnode",
                                       resourcedir=resource_dir_hdfs, servicecmd=service_cmd_hdfs), logoutput=True)
   if not check_windows_service_exists("zkfc"):
-    Execute(CREATE_SERVICE_CMD.format(script=CREATE_SERVICE_SCRIPT, password=hadoop_password, servicename="zkfc",
+    Execute(CREATE_SERVICE_CMD.format(script=CREATE_SERVICE_SCRIPT, username=hadoop_user, password=hadoop_password, servicename="zkfc",
                                       resourcedir=resource_dir_hdfs, servicecmd=service_cmd_hdfs), logoutput=True)
 
 
@@ -155,7 +155,7 @@ def _write_marker():
     open(os.path.join(_working_dir, INSTALL_MARKER_FAILED), "w").close()
 
 
-def install_windows_msi(msi_url, save_dir, save_file, hadoop_password, stack_version):
+def install_windows_msi(msi_url, save_dir, save_file, hadoop_user, hadoop_password, stack_version):
   global _working_dir
   _working_dir = save_dir
   save_dir = os.path.abspath(save_dir)
@@ -194,10 +194,10 @@ def install_windows_msi(msi_url, save_dir, save_file, hadoop_password, stack_ver
 
     Execute(
       INSTALL_MSI_CMD.format(hdp_msi_path=hdp_msi_path, hdp_log_path=hdp_log_path, hdp_layout_path=hdp_layout_path,
-                             hadoop_password_arg=hadoop_password_arg))
+                             hadoop_user=hadoop_user, hadoop_password_arg=hadoop_password_arg))
     reload_windows_env()
     # create additional services manually due to hdp.msi limitaitons
-    _ensure_services_created(hadoop_password)
+    _ensure_services_created(hadoop_user, hadoop_password)
     _create_symlinks(stack_version)
     # finalizing install
     _write_marker()

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-common/src/main/python/resource_management/libraries/functions/windows_service_utils.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/windows_service_utils.py b/ambari-common/src/main/python/resource_management/libraries/functions/windows_service_utils.py
index 7d994b7..019a326 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/windows_service_utils.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/windows_service_utils.py
@@ -20,23 +20,35 @@ Ambari Agent
 """
 
 from resource_management.core.exceptions import ComponentIsNotRunning
-from resource_management.core.logger import Logger
+from resource_management.core.providers.windows.service import safe_open_scmanager, safe_open_service
+
 __all__ = ['check_windows_service_status', 'check_windows_service_exists']
 
 import win32service
 
-_schSCManager = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS)
-
 def check_windows_service_status(service_name):
-  _service_handle = win32service.OpenService(_schSCManager, service_name, win32service.SERVICE_ALL_ACCESS)
-  if win32service.QueryServiceStatusEx(_service_handle)["CurrentState"] == win32service.SERVICE_STOPPED:
-      raise ComponentIsNotRunning()
+  _schSCManager = safe_open_scmanager()
+
+  try:
+    _service_handle = safe_open_service(_schSCManager, service_name)
+    try:
+      if win32service.QueryServiceStatusEx(_service_handle)["CurrentState"] == win32service.SERVICE_STOPPED:
+        raise ComponentIsNotRunning()
+    finally:
+      win32service.CloseServiceHandle(_service_handle)
+  finally:
+    win32service.CloseServiceHandle(_schSCManager)
 
 def check_windows_service_exists(service_name):
-  typeFilter = win32service.SERVICE_WIN32
-  stateFilter = win32service.SERVICE_STATE_ALL
-  statuses = win32service.EnumServicesStatus(_schSCManager, typeFilter, stateFilter)
-  for (short_name, desc, status) in statuses:
-    if short_name == service_name:
-      return True
-  return False
+  _schSCManager = safe_open_scmanager()
+
+  try:
+    typeFilter = win32service.SERVICE_WIN32
+    stateFilter = win32service.SERVICE_STATE_ALL
+    statuses = win32service.EnumServicesStatus(_schSCManager, typeFilter, stateFilter)
+    for (short_name, desc, status) in statuses:
+      if short_name == service_name:
+        return True
+    return False
+  finally:
+    win32service.CloseServiceHandle(_schSCManager)

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-common/src/main/python/resource_management/libraries/script/script.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index 6ef4bb5..a4ddc7c 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -298,8 +298,9 @@ class Script(object):
 
     if OSCheck.is_windows_family():
       #TODO hacky install of windows msi, remove it or move to old(2.1) stack definition when component based install will be implemented
+      hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
       install_windows_msi(os.path.join(config['hostLevelParams']['jdk_location'], "hdp.msi"),
-                          config["hostLevelParams"]["agentCacheDir"], "hdp.msi", self.get_password("hadoop"),
+                          config["hostLevelParams"]["agentCacheDir"], "hdp.msi", hadoop_user, self.get_password(hadoop_user),
                           str(config['hostLevelParams']['stack_version']))
       reload_windows_env()
     pass

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/python/ambari_server/dbConfiguration_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/dbConfiguration_windows.py b/ambari-server/src/main/python/ambari_server/dbConfiguration_windows.py
index 04db2af..96cd823 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration_windows.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration_windows.py
@@ -93,7 +93,6 @@ class MSSQLConfig(DBMSConfig):
 
     self.env_var_db_name = ""
     self.env_var_db_log_name = ""
-    self.env_var_db_owner = ""
 
     self.init_script_file = ""
     self.drop_tables_script_file = ""
@@ -284,7 +283,6 @@ class MSSQLConfig(DBMSConfig):
     # Setup DB
     os.environ[self.env_var_db_name] = self.database_name
     os.environ[self.env_var_db_log_name] = self.database_name + '_log'
-    os.environ[self.env_var_db_owner] = 'hadoop'
 
     # Don't create the database, assume it already exists. Just clear out the known tables structure
     MSSQLConfig._execute_db_script(self.database_host, self.drop_tables_script_file)
@@ -333,7 +331,6 @@ class MSSQLAmbariDBConfig(MSSQLConfig):
 
     self.env_var_db_name ='AMBARIDBNAME'
     self.env_var_db_log_name = 'AMBARIDBLOGNAME'
-    self.env_var_db_owner = 'AMBARIDBOWNER'
 
     # The values from options supersede the values from properties
     self.init_script_file = compress_backslashes(DBMSConfig._init_member_with_default(options, "init_db_script_file",

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/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 89e3afd..9986422 100644
--- a/ambari-server/src/main/python/ambari_server/serverSetup.py
+++ b/ambari-server/src/main/python/ambari_server/serverSetup.py
@@ -321,7 +321,9 @@ def check_ambari_user(options):
 def service_setup(register_service, svc_user, svc_password):
   from ambari_windows_service import svcsetup
 
-  result = svcsetup(register_service, svc_user, svc_password)
+  svc_user_setup = svc_user if svc_user.upper() != "NT AUTHORITY\\SYSTEM" else None
+
+  result = svcsetup(register_service, svc_user_setup, svc_password)
   if result == 0:
     write_property(NR_USER_PROPERTY, svc_user)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATELOCAL.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATELOCAL.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATELOCAL.sql
index 87e7a40..380b0a0 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATELOCAL.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATELOCAL.sql
@@ -118,6 +118,7 @@ GO
 ALTER authorization on DATABASE::$(AMBARIDBNAME) to [NT AUTHORITY\SYSTEM]
 GO
 
+--set AMBARIDBOWNER=hadoop
 if exists (select 1 from master.sys.syslogins where name='$(AMBARIDBOWNER)')
 BEGIN
     CREATE USER [$(AMBARIDBOWNER)] FOR LOGIN [$(AMBARIDBOWNER)]

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams.py b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams.py
index 8cbbed2..c7de4f3 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/ams.py
@@ -72,7 +72,11 @@ def ams(name=None):
          owner=params.ams_user,
          content=InlineTemplate(params.ams_env_sh_template)
     )
-    pass
+
+    ServiceConfig(params.ams_collector_win_service_name,
+                  action="change_user",
+                  username = params.ams_user,
+                  password = Script.get_password(params.ams_user))
 
     if params.is_hbase_distributed:
       # Configuration needed to support NN HA
@@ -93,6 +97,11 @@ def ams(name=None):
                 group=params.user_group,
                 mode=0644
       )
+    else:
+      ServiceConfig(params.ams_embedded_hbase_win_service_name,
+                    action="change_user",
+                    username = params.ams_user,
+                    password = Script.get_password(params.ams_user))
     pass
 
   elif name == 'monitor':
@@ -131,6 +140,12 @@ def ams(name=None):
       template_tag=None
     )
 
+    ServiceConfig(params.ams_monitor_win_service_name,
+                  action="change_user",
+                  username = params.ams_user,
+                  password = Script.get_password(params.ams_user))
+
+
 @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
 def ams(name=None):
   import params

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params_windows.py
index 1b3509e..85a65e6 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params_windows.py
@@ -33,3 +33,7 @@ hadoop_bin_dir = os.path.join(os.environ["HADOOP_HOME"], "bin")
 hbase_cmd = os.path.join(os.environ["COLLECTOR_HOME"], "hbase", "bin", "hbase.cmd")
 hadoop_conf_dir = os.path.join(os.environ["HADOOP_HOME"], "conf")
 hbase_conf_dir = os.path.join(os.environ["COLLECTOR_HOME"], "hbase", "conf")
+
+ams_collector_win_service_name = "AmbariMetricsCollector"
+ams_monitor_win_service_name = "AmbariMetricsCollector"
+ams_embedded_hbase_win_service_name = "ams_hbase_master"

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
index 05bae60..62fb1dd 100644
--- a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
+++ b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
@@ -169,6 +169,10 @@ def falcon(type, action = None):
     )
 
   if type == 'server':
+    ServiceConfig(params.falcon_win_service_name,
+                  action="change_user",
+                  username=params.falcon_user,
+                  password = Script.get_password(params.falcon_user))
     if action == 'start':
       Service(params.falcon_win_service_name, action="start")
     if action == 'stop':

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/status_params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/status_params.py b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/status_params.py
index 0556ec1..c5478e5 100644
--- a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/status_params.py
+++ b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/status_params.py
@@ -24,6 +24,8 @@ config = Script.get_config()
 
 if OSCheck.is_windows_family():
   falcon_win_service_name = "falcon"
+  hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+  falcon_user = hadoop_user
 else:
   falcon_pid_dir = config['configurations']['falcon-env']['falcon_pid_dir']
   server_pid_file = format('{falcon_pid_dir}/falcon.pid')

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py
index 11cae75..18055d5 100644
--- a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py
+++ b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/flume.py
@@ -31,7 +31,14 @@ from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 def flume(action = None):
   import params
 
+  from service_mapping import flume_win_service_name
+
   if action == 'config':
+    ServiceConfig(flume_win_service_name,
+                  action="change_user",
+                  username=params.flume_user,
+                  password = Script.get_password(params.flume_user))
+
     # remove previously defined meta's
     for n in find_expected_agent_names(params.flume_conf_dir):
       os.unlink(os.path.join(params.flume_conf_dir, n, 'ambari-meta.json'))

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/params_windows.py
index 87b9640..17177ec 100644
--- a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/package/scripts/params_windows.py
@@ -24,8 +24,10 @@ import os
 # server configurations
 config = Script.get_config()
 
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+
 hdp_root = os.path.abspath(os.path.join(os.environ["HADOOP_HOME"],".."))
 flume_home = os.environ['FLUME_HOME']
 flume_conf_dir = os.path.join(flume_home, 'conf')
-flume_user = 'hadoop'
-hdfs_user = "hadoop"
+flume_user = hadoop_user
+hdfs_user = hadoop_user

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase.py
index 2ddd137..8ce244a 100644
--- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase.py
+++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/hbase.py
@@ -33,6 +33,14 @@ def hbase(name=None):
             configuration_attributes=params.config['configuration_attributes']['hbase-site']
   )
 
+  if params.service_map.has_key(name):
+    # Manually overriding service logon user & password set by the installation package
+    service_name = params.service_map[name]
+    ServiceConfig(service_name,
+                  action="change_user",
+                  username = params.hbase_user,
+                  password = Script.get_password(params.hbase_user))
+
 # name is 'master' or 'regionserver' or 'queryserver' or 'client'
 @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
 def hbase(name=None):

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_windows.py
index 571b93c..c132503 100644
--- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/package/scripts/params_windows.py
@@ -28,10 +28,16 @@ hbase_conf_dir = os.environ["HBASE_CONF_DIR"]
 hbase_bin_dir = os.path.join(os.environ["HBASE_HOME"],'bin')
 hbase_executable = os.path.join(hbase_bin_dir,"hbase.cmd")
 hdp_root = os.path.abspath(os.path.join(os.environ["HADOOP_HOME"],".."))
-hbase_user = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+hbase_user = hadoop_user
 
 #decomm params
 region_drainer = os.path.join(hbase_bin_dir,"draining_servers.rb")
 region_mover = os.path.join(hbase_bin_dir,"region_mover.rb")
 hbase_excluded_hosts = config['commandParams']['excluded_hosts']
-hbase_drain_only = config['commandParams']['mark_draining_only']
\ No newline at end of file
+hbase_drain_only = config['commandParams']['mark_draining_only']
+
+service_map = {
+  'master' : status_params.hbase_master_win_service_name,
+  'regionserver' : status_params.hbase_regionserver_win_service_name
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs.py
index a15a486..a615c27 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs.py
@@ -117,6 +117,13 @@ def hdfs(component=None):
          owner=params.hdfs_user,
          mode="f",
          )
+  if params.service_map.has_key(component):
+    service_name = params.service_map[component]
+    ServiceConfig(service_name,
+                  action="change_user",
+                  username=params.hdfs_user,
+                  password=Script.get_password(params.hdfs_user))
+
   if "hadoop-policy" in params.config['configurations']:
     XmlConfig("hadoop-policy.xml",
               conf_dir=params.hadoop_conf_dir,

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/journalnode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/journalnode.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/journalnode.py
index e8cc06c..8ec1fe9 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/journalnode.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/journalnode.py
@@ -174,7 +174,7 @@ class JournalNodeWindows(JournalNode):
   def configure(self, env):
     import params
     env.set_params(params)
-    hdfs()
+    hdfs("journalnode")
     pass
 
   def status(self, env):

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
index 2b6e6f8..dd439d7 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode.py
@@ -249,11 +249,11 @@ class NameNodeDefault(NameNode):
 class NameNodeWindows(NameNode):
 
   def rebalancehdfs(self, env):
-    from ambari_commons.os_windows import run_os_command_impersonated
+    from ambari_commons.os_windows import UserHelper, run_os_command_impersonated
     import params
     env.set_params(params)
 
-    hdfs_user = params.hdfs_user
+    hdfs_username, hdfs_domain = UserHelper.parse_user_name(params.hdfs_user, ".")
 
     name_node_parameters = json.loads( params.name_node_params )
     threshold = name_node_parameters['threshold']
@@ -272,7 +272,7 @@ class NameNodeWindows(NameNode):
     _print("Executing command %s\n" % command)
 
     parser = hdfs_rebalance.HdfsParser()
-    returncode, stdout, err = run_os_command_impersonated(' '.join(command), hdfs_user, Script.get_password(hdfs_user))
+    returncode, stdout, err = run_os_command_impersonated(' '.join(command), hdfs_username, Script.get_password(params.hdfs_user), hdfs_domain)
 
     for line in stdout.split('\n'):
       _print('[balancer] %s %s' % (str(datetime.now()), line ))

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_windows.py
index c14e6ca..c3ee304 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/params_windows.py
@@ -58,9 +58,18 @@ if dfs_ha_enabled:
       namenode_id = nn_id
       namenode_rpc = nn_host
 
-hdfs_user = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+hdfs_user = hadoop_user
 
 grep_exe = "findstr"
 
 name_node_params = default("/commandParams/namenode", None)
 exclude_packages = []
+
+service_map = {
+  "datanode" : datanode_win_service_name,
+  "journalnode" : journalnode_win_service_name,
+  "namenode" : namenode_win_service_name,
+  "secondarynamenode" : snamenode_win_service_name,
+  "zkfc_slave": zkfc_win_service_name
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/status_params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/status_params.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/status_params.py
index debb914..3e4cfe4 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/status_params.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/status_params.py
@@ -27,6 +27,7 @@ if OSCheck.is_windows_family():
   datanode_win_service_name = "datanode"
   snamenode_win_service_name = "secondarynamenode"
   journalnode_win_service_name = "journalnode"
+  zkfc_win_service_name = "zkfc"
 else:
   hadoop_pid_dir_prefix = config['configurations']['hadoop-env']['hadoop_pid_dir_prefix']
   hdfs_user = config['configurations']['hadoop-env']['hdfs_user']

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/zkfc_slave.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/zkfc_slave.py b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/zkfc_slave.py
index 28cd434..14de094 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/zkfc_slave.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/zkfc_slave.py
@@ -36,7 +36,7 @@ class ZkfcSlave(Script):
   def configure(self, env):
     import params
     env.set_params(params)
-    hdfs()
+    hdfs("zkfc_slave")
     pass
 
 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
index 9de92c6..4df6014 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
@@ -29,13 +29,21 @@ from ambari_commons import OSConst
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
 def hive(name=None):
   import params
+
   XmlConfig("hive-site.xml",
             conf_dir = params.hive_conf_dir,
             configurations = params.config['configurations']['hive-site'],
             owner=params.hive_user,
             configuration_attributes=params.config['configuration_attributes']['hive-site']
   )
+
   if name in ["hiveserver2","metastore"]:
+    # Manually overriding service logon user & password set by the installation package
+    service_name = params.service_map[name]
+    ServiceConfig(service_name,
+                  action="change_user",
+                  username = params.hive_user,
+                  password = Script.get_password(params.hive_user))
     Execute(format("cmd /c hadoop fs -mkdir -p {hive_warehouse_dir}"), logoutput=True, user=params.hadoop_user)
 
   if name == 'metastore':

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_windows.py
index d84b226..329fe0c 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_windows.py
@@ -39,9 +39,9 @@ hcat_config_dir = os.environ["WEBHCAT_CONF_DIR"]
 
 hive_env_sh_template = config['configurations']['hive-env']['content']
 hive_warehouse_dir = config['configurations']['hive-site']['hive.metastore.warehouse.dir']
-hive_user = "hadoop"
-hadoop_user = "hadoop"
-hcat_user = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+hive_user = hadoop_user
+hcat_user = hadoop_user
 
 hive_bin = os.path.join(hive_home, "bin")
 hive_metastore_db_type = config['configurations']['hive-env']['hive_database_type']
@@ -51,4 +51,11 @@ hive_metastore_user_passwd = config['configurations']['hive-site']['javax.jdo.op
 hive_exclude_packages = []
 
 ######## Metastore Schema
-init_metastore_schema = not config['configurations']['hive-site']['datanucleus.autoCreateSchema']
\ No newline at end of file
+init_metastore_schema = not config['configurations']['hive-site']['datanucleus.autoCreateSchema']
+
+service_map = {
+  "metastore" : hive_metastore_win_service_name,
+  "client" : hive_client_win_service_name,
+  "hiveserver2" : hive_server_win_service_name,
+  "templeton" : webhcat_server_win_service_name
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat.py
index d396f11..733ab0a 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/webhcat.py
@@ -35,6 +35,11 @@ def webhcat():
             conf_dir=params.hcat_config_dir,
             configurations=params.config['configurations']['webhcat-site']
   )
+  # Manually overriding service logon user & password set by the installation package
+  ServiceConfig(params.webhcat_server_win_service_name,
+                action="change_user",
+                username = params.hcat_user,
+                password = Script.get_password(params.hcat_user))
 
 
 @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py
index ab25187..f3040ee 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py
@@ -25,6 +25,7 @@ from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
 def knox():
   import params
+  from service_mapping import knox_geteway_win_service_name
 
   XmlConfig("gateway-site.xml",
             conf_dir=params.knox_conf_dir,
@@ -33,6 +34,12 @@ def knox():
             owner=params.knox_user
   )
 
+  # Manually overriding service logon user & password set by the installation package
+  ServiceConfig(knox_geteway_win_service_name,
+                action="change_user",
+                username = params.knox_user,
+                password = Script.get_password(params.knox_user))
+
   File(os.path.join(params.knox_conf_dir, "gateway-log4j.properties"),
        owner=params.knox_user,
        content=params.gateway_log4j
@@ -45,7 +52,7 @@ def knox():
   )
 
   if params.security_enabled:
-    TemplateConfig( os.path.join(knox_conf_dir, "krb5JAASLogin.conf"),
+    TemplateConfig( os.path.join(params.knox_conf_dir, "krb5JAASLogin.conf"),
         owner = params.knox_user,
         template_tag = None
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py
index 08e28f5..c96605e 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py
@@ -20,7 +20,10 @@ limitations under the License.
 import os
 from resource_management import *
 
-def ldap():
+from ambari_commons import OSConst
+from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+
+def _ldap_common():
     import params
 
     File(os.path.join(params.knox_conf_dir, 'ldap-log4j.properties'),
@@ -37,3 +40,19 @@ def ldap():
          content=params.users_ldif
     )
 
+@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
+def ldap():
+  import params
+  from service_mapping import knox_ldap_win_service_name
+
+  # Manually overriding service logon user & password set by the installation package
+  ServiceConfig(knox_ldap_win_service_name,
+                action="change_user",
+                username = params.knox_user,
+                password = Script.get_password(params.knox_user))
+
+  _ldap_common()
+
+@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
+def ldap():
+  _ldap_common()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py
index 3d72735..652094a 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py
@@ -36,7 +36,8 @@ knox_data_dir = os.path.join(knox_home, 'data')
 knox_master_secret_path = os.path.join(knox_data_dir, 'security', 'master')
 knox_cert_store_path = os.path.join(knox_data_dir, 'security', 'keystores', 'gateway.jks')
 
-knox_user = 'hadoop'
-hdfs_user = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+knox_user = hadoop_user
+hdfs_user = hadoop_user
 knox_group = None
 mode = None

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py
index 76e01ff..21ba06b 100644
--- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py
+++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py
@@ -19,15 +19,15 @@ limitations under the License.
 """
 import os
 
-from resource_management.core.resources import Directory
-from resource_management.core.resources import File
-from resource_management.core.resources.system import Execute
+from resource_management.core.resources.service import ServiceConfig
+from resource_management.core.resources.system import Directory, Execute, File
 from resource_management.core.source import DownloadSource
 from resource_management.core.source import InlineTemplate
 from resource_management.core.source import Template
-from resource_management.libraries.functions import format
-from resource_management.libraries.functions import compare_versions
+from resource_management.libraries.functions.format import format
+from resource_management.libraries.functions.version import compare_versions
 from resource_management.libraries.resources.xml_config import XmlConfig
+from resource_management.libraries.script.script import Script
 from resource_management.core.resources.packaging import Package
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
@@ -37,6 +37,8 @@ from ambari_commons.inet_utils import download_file
 def oozie(is_server=False):
   import params
 
+  from status_params import oozie_server_win_service_name
+
   XmlConfig("oozie-site.xml",
             conf_dir=params.oozie_conf_dir,
             configurations=params.config['configurations']['oozie-site'],
@@ -52,8 +54,16 @@ def oozie(is_server=False):
 
   Directory(params.oozie_tmp_dir,
             owner=params.oozie_user,
-             recursive = True,
+            recursive = True,
   )
+
+  if is_server:
+    # Manually overriding service logon user & password set by the installation package
+    ServiceConfig(oozie_server_win_service_name,
+                  action="change_user",
+                  username = params.oozie_user,
+                  password = Script.get_password(params.oozie_user))
+
   download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"),
                       os.path.join(params.oozie_root, "extra_libs", "sqljdbc4.jar")
   )

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py
index 9d6b062..ec404c4 100644
--- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py
@@ -23,11 +23,12 @@ from status_params import *
 
 config = Script.get_config()
 
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
 hdp_root = os.path.abspath(os.path.join(os.environ["HADOOP_HOME"], ".."))
 oozie_root = os.environ['OOZIE_ROOT']
 oozie_home = os.environ['OOZIE_HOME']
 oozie_conf_dir = os.path.join(oozie_home,'conf')
-oozie_user = "hadoop"
+oozie_user = hadoop_user
 oozie_tmp_dir = "c:\\hadoop\\temp\\oozie"
 
 oozie_env_cmd_template = config['configurations']['oozie-env']['content']

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/package/scripts/params_windows.py
index 3e63083..7bb7ef8 100644
--- a/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/package/scripts/params_windows.py
@@ -32,5 +32,6 @@ if (('pig-log4j' in config['configurations']) and ('content' in config['configur
 else:
   log4j_props = None
 
-pig_user = "hadoop"
-hdfs_user = "hadoop"
\ No newline at end of file
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+pig_user = hadoop_user
+hdfs_user = hadoop_user

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/params_windows.py
index c28d062..932c5a4 100644
--- a/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/SLIDER/0.60.0.2.2/package/scripts/params_windows.py
@@ -30,5 +30,6 @@ slider_conf_dir = os.path.join(slider_home, 'conf')
 storm_slider_conf_dir = os.path.join(os.environ['STORM_HOME'], 'conf')
 slider_home_dir = slider_home
 
-slider_user = 'hadoop'
-hdfs_user = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+slider_user = hadoop_user
+hdfs_user = hadoop_user

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py
index 57db32d..8e3c6b4 100644
--- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py
+++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py
@@ -42,7 +42,7 @@ class Nimbus(Script):
   def configure(self, env):
     import params
     env.set_params(params)
-    storm()
+    storm("nimbus")
 
 
 @OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
@@ -136,6 +136,5 @@ class NimbusWindows(Nimbus):
     env.set_params(status_params)
     check_windows_service_status(status_params.nimbus_win_service_name)
 
-
 if __name__ == "__main__":
   Nimbus().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py
index 152baa4..d98246c 100644
--- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py
@@ -26,4 +26,11 @@ config = Script.get_config()
 
 hdp_root = os.path.abspath(os.path.join(os.environ["HADOOP_HOME"],".."))
 conf_dir = os.environ["STORM_CONF_DIR"]
-storm_user = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+storm_user = hadoop_user
+
+service_map = {
+  "nimbus" : nimbus_win_service_name,
+  "supervisor" : supervisor_win_service_name,
+  "ui" : ui_win_service_name
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
index 08d5b34..e7e5a4c 100644
--- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
+++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py
@@ -18,13 +18,13 @@ limitations under the License.
 
 """
 
-import resource_management
-from resource_management.core.resources import File
-from resource_management.core.resources import Execute
-from resource_management.core.resources import Directory
+from resource_management.core.exceptions import Fail
+from resource_management.core.resources.service import ServiceConfig
+from resource_management.core.resources.system import Directory, Execute, File
 from resource_management.core.source import InlineTemplate
 from resource_management.libraries.resources.template_config import TemplateConfig
 from resource_management.libraries.functions.format import format
+from resource_management.libraries.script.script import Script
 from resource_management.core.source import Template
 from resource_management.libraries.functions import compare_versions
 from yaml_utils import yaml_config_template, yaml_config
@@ -32,7 +32,7 @@ from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
 
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
-def storm():
+def storm(name=None):
   import params
   yaml_config("storm.yaml",
               conf_dir=params.conf_dir,
@@ -40,8 +40,16 @@ def storm():
               owner=params.storm_user
   )
 
+  if params.service_map.has_key(name):
+    service_name = params.service_map[name]
+    ServiceConfig(service_name,
+                  action="change_user",
+                  username = params.storm_user,
+                  password = Script.get_password(params.storm_user))
+
+
 @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
-def storm():
+def storm(name=None):
   import params
 
   Directory(params.log_dir,

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/supervisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/supervisor.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/supervisor.py
index 4acfd80..cee42d4 100644
--- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/supervisor.py
+++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/supervisor.py
@@ -39,7 +39,7 @@ class Supervisor(Script):
   def configure(self, env):
     import params
     env.set_params(params)
-    storm()
+    storm("supervisor")
 
 
 @OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py
index 172a357..0814282 100644
--- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py
+++ b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/ui_server.py
@@ -44,7 +44,7 @@ class UiServer(Script):
   def configure(self, env):
     import params
     env.set_params(params)
-    storm()
+    storm("ui")
 
 @OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
 class UiServerWindows(UiServer):

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/params_windows.py
index 767ed1c..2a7bd8b 100644
--- a/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/TEZ/0.4.0.2.1/package/scripts/params_windows.py
@@ -21,7 +21,8 @@ from resource_management import *
 import os
 
 config = Script.get_config()
-tez_user = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+tez_user = hadoop_user
 tez_home_dir = None
 tez_conf_dir = "conf"
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/params_windows.py
index edd4d17..0f8ce73 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/params_windows.py
@@ -27,9 +27,10 @@ from status_params import *
 # server configurations
 config = Script.get_config()
 
-yarn_user = "hadoop"
-hdfs_user = "hadoop"
-smokeuser = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+yarn_user = hadoop_user
+hdfs_user = hadoop_user
+smokeuser = hadoop_user
 config_dir = os.environ["HADOOP_CONF_DIR"]
 hadoop_home = os.environ["HADOOP_HOME"]
 
@@ -55,4 +56,4 @@ hadoopMapredExamplesJarName = "hadoop-mapreduce-examples-2.*.jar"
 
 exclude_hosts = default("/clusterHostInfo/decom_nm_hosts", [])
 exclude_file_path = default("/configurations/yarn-site/yarn.resourcemanager.nodes.exclude-path","/etc/hadoop/conf/yarn.exclude")
-update_exclude_file_only = config['commandParams']['update_exclude_file_only']
\ No newline at end of file
+update_exclude_file_only = config['commandParams']['update_exclude_file_only']

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
index f6487e5..c827529 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/service.py
@@ -26,7 +26,7 @@ from ambari_commons import OSConst
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
 def service(componentName, action='start', serviceName='yarn'):
   import status_params
-  if componentName == 'resourcemanager' or componentName == 'nodemanager' or componentName == 'historyserver' or componentName == 'timelineserver':
+  if status_params.service_map.has_key(componentName):
     service_name = status_params.service_map[componentName]
     if action == 'start' or action == 'stop':
       Service(service_name, action=action)
@@ -36,7 +36,6 @@ def service(componentName, action='start', serviceName='yarn'):
 
 @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
 def service(componentName, action='start', serviceName='yarn'):
-
   import params
 
   if serviceName == 'mapreduce' and componentName == 'historyserver':

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/status_params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/status_params.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/status_params.py
index 42e6fad..61402a0 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/status_params.py
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/status_params.py
@@ -25,7 +25,17 @@ config = Script.get_config()
 tmp_dir = Script.get_tmp_dir()
 
 if OSCheck.is_windows_family():
-  service_map = {'resourcemanager':'resourcemanager', 'nodemanager':'nodemanager', 'historyserver':'jobhistoryserver', 'timelineserver':'historyserver'}
+  resourcemanager_win_service_name = 'resourcemanager'
+  nodemanager_win_service_name = 'nodemanager'
+  historyserver_win_service_name = 'jobhistoryserver'
+  timelineserver_win_service_name = 'timelineserver'
+
+  service_map = {
+    'resourcemanager' : resourcemanager_win_service_name,
+    'nodemanager' : nodemanager_win_service_name,
+    'historyserver' : historyserver_win_service_name,
+    'timelineserver' : timelineserver_win_service_name
+  }
 else:
   mapred_user = config['configurations']['mapred-env']['mapred_user']
   yarn_user = config['configurations']['yarn-env']['yarn_user']

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/yarn.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/yarn.py b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/yarn.py
index 22888e2..583e6e9 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/yarn.py
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/yarn.py
@@ -49,6 +49,14 @@ def yarn(name = None):
             mode='f'
   )
 
+  if params.service_map.has_key(name):
+    service_name = params.service_map[name]
+
+    ServiceConfig(service_name,
+                  action="change_user",
+                  username = params.yarn_user,
+                  password = Script.get_password(params.yarn_user))
+
 
 @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
 def yarn(name = None):

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/params_windows.py
index c7302a5..e5ce948 100644
--- a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/params_windows.py
@@ -28,7 +28,8 @@ config = Script.get_config()
 # notused zookeeper_home_dir = os.environ["ZOOKEEPER_HOME"]
 config_dir = os.environ["ZOOKEEPER_CONF_DIR"]
 hdp_root = os.environ["HADOOP_NODE_INSTALL_ROOT"]
-zk_user = "hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+zk_user = hadoop_user
 
 # notused zk_log_dir = config['configurations']['zookeeper-env']['zk_log_dir']
 zk_data_dir = ensure_double_backslashes(config['configurations']['zoo.cfg']['dataDir'])

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper.py b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper.py
index d6c40ee..6ea9047 100644
--- a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper.py
+++ b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/package/scripts/zookeeper.py
@@ -107,6 +107,12 @@ def zookeeper(type = None, rolling_restart = False):
   configFile("zoo.cfg", template_name="zoo.cfg.j2", mode="f")
   configFile("configuration.xsl", template_name="configuration.xsl.j2", mode="f")
 
+  ServiceConfig(params.zookeeper_win_service_name,
+                action="change_user",
+                username = params.zk_user,
+                password = Script.get_password(params.zk_user))
+
+
   Directory(params.zk_data_dir,
             owner=params.zk_user,
             mode="(OI)(CI)F",

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/params.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/params.py
index 3f494d3..bfc605c 100644
--- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/after-INSTALL/scripts/params.py
@@ -23,7 +23,8 @@ from urlparse import urlparse
 config = Script.get_config()
 hadoop_conf_dir = None
 hadoop_common_dir = os.path.join("share", "hadoop", "common", "lib")
-hdfs_user="hadoop"
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+hdfs_user = hadoop_user
 hadoop_common_bin = "bin"
 
 if os.environ.has_key("HADOOP_CONF_DIR"):

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py
index a9ac605..093ea38 100644
--- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py
@@ -35,4 +35,4 @@ if has_metric_collector:
 
 hadoop_conf_dir = os.environ["HADOOP_CONF_DIR"]
 hbase_conf_dir = os.environ["HBASE_CONF_DIR"]
-hadoop_user = "hadoop"
\ No newline at end of file
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
index 92b9297..0ca5bb0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
@@ -85,7 +85,7 @@ public class UpgradeTest {
   private static String DROP_DERBY_URL = "jdbc:derby:memory:myDB/ambari;drop=true";
 
   private final String sourceVersion;
-  private  Properties properties = new Properties();
+  private Properties properties = new Properties();
 
   private Injector injector;
 
@@ -94,9 +94,9 @@ public class UpgradeTest {
     properties.setProperty(Configuration.SERVER_PERSISTENCE_TYPE_KEY, "remote");
     properties.setProperty(Configuration.SERVER_JDBC_URL_KEY, Configuration.JDBC_IN_MEMORY_URL);
     properties.setProperty(Configuration.SERVER_JDBC_DRIVER_KEY, Configuration.JDBC_IN_MEMROY_DRIVER);
-    properties.setProperty(Configuration.METADETA_DIR_PATH,"src/test/resources/stacks");
-    properties.setProperty(Configuration.SERVER_VERSION_FILE,"src/test/resources/version");
-    properties.setProperty(Configuration.OS_VERSION_KEY,"centos5");
+    properties.setProperty(Configuration.METADETA_DIR_PATH, "src/test/resources/stacks");
+    properties.setProperty(Configuration.SERVER_VERSION_FILE, "src/test/resources/version");
+    properties.setProperty(Configuration.OS_VERSION_KEY, "centos5");
     properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, "src/test/resources/");
   }
 
@@ -188,7 +188,7 @@ public class UpgradeTest {
     LOG.info("Upgrading schema to target version = " + targetVersion);
 
     UpgradeCatalog targetUpgradeCatalog = AbstractUpgradeCatalog
-      .getUpgradeCatalog(targetVersion);
+        .getUpgradeCatalog(targetVersion);
 
     LOG.debug("Target upgrade catalog. " + targetUpgradeCatalog);
 
@@ -197,7 +197,7 @@ public class UpgradeTest {
     LOG.info("Upgrading schema from source version = " + sourceVersion);
 
     List<UpgradeCatalog> upgradeCatalogs =
-      schemaUpgradeHelper.getUpgradePath(sourceVersion, targetVersion);
+        schemaUpgradeHelper.getUpgradePath(sourceVersion, targetVersion);
 
     try {
       schemaUpgradeHelper.executeUpgrade(upgradeCatalogs);

http://git-wip-us.apache.org/repos/asf/ambari/blob/77e4d50c/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py
index 2a810a0..fb2699a 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-START/test_before_start.py
@@ -23,6 +23,7 @@ from mock.mock import MagicMock, call, patch
 from resource_management import Hook
 import json
 
+@patch("platform.linux_distribution", new = MagicMock(return_value="Linux"))
 @patch("os.path.exists", new = MagicMock(return_value=True))
 @patch.object(Hook, "run_custom_hook", new = MagicMock())
 class TestHookBeforeStart(RMFTestCase):


Mime
View raw message