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/05/18 14:35:02 UTC

ambari git commit: AMBARI-11206 [WinTP2] Ambari Agent fails to start

Repository: ambari
Updated Branches:
  refs/heads/trunk 28cb5fb2f -> a01d92b18


AMBARI-11206 [WinTP2] Ambari Agent fails to start

Reinstated the Windows-specific read_file()


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

Branch: refs/heads/trunk
Commit: a01d92b18cb0f1a2e1f526702707ce3edf0bdf11
Parents: 28cb5fb
Author: Florian Barca <fb...@hortonworks.com>
Authored: Mon May 18 05:34:46 2015 -0700
Committer: Florian Barca <fb...@hortonworks.com>
Committed: Mon May 18 05:34:46 2015 -0700

----------------------------------------------------------------------
 .../src/main/python/resource_management/core/source.py       | 8 ++++++++
 .../src/main/python/resource_management/core/sudo.py         | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a01d92b1/ambari-common/src/main/python/resource_management/core/source.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/source.py b/ambari-common/src/main/python/resource_management/core/source.py
index 7317492..1f888ac 100644
--- a/ambari-common/src/main/python/resource_management/core/source.py
+++ b/ambari-common/src/main/python/resource_management/core/source.py
@@ -33,6 +33,8 @@ import time
 import urllib2
 import urlparse
 
+from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+from ambari_commons import OSConst
 
 class Source(object):
   def __init__(self, name):
@@ -74,10 +76,16 @@ class StaticFile(Source):
 
     return self.read_file(path)
 
+  @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
   def read_file(self, path):
     from resource_management.core import sudo
     return sudo.read_file(path)
 
+  @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
+  def read_file(self, path):
+    with open(path, "rb") as fp:
+      return fp.read()
+
 
 try:
   from ambari_jinja2 import Environment as JinjaEnvironment, BaseLoader, TemplateNotFound, FunctionLoader, StrictUndefined

http://git-wip-us.apache.org/repos/asf/ambari/blob/a01d92b1/ambari-common/src/main/python/resource_management/core/sudo.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/sudo.py b/ambari-common/src/main/python/resource_management/core/sudo.py
index b5dfa47..e7bb08a 100644
--- a/ambari-common/src/main/python/resource_management/core/sudo.py
+++ b/ambari-common/src/main/python/resource_management/core/sudo.py
@@ -29,7 +29,7 @@ from resource_management.core.utils import _coerce_uid
 from resource_management.core.utils import _coerce_gid
 from ambari_commons.os_check import OSCheck
 
-if os.geteuid() == 0 or OSCheck.is_windows_family():
+if os.geteuid() == 0:
   def chown(path, owner, group):
     return os.chown(path, _coerce_uid(owner) if owner else -1, _coerce_gid(group) if group else -1)