You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2015/06/24 18:55:18 UTC

[2/2] ambari git commit: AMBARI-12127. RU: install version fails with non-root + umask 027 (aonishuk)

AMBARI-12127. RU: install version fails with non-root + umask 027 (aonishuk)


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

Branch: refs/heads/branch-2.1
Commit: 105723260918a8d2b0d466dfce4e63dd751bda02
Parents: 7e84904
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Wed Jun 24 19:55:08 2015 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Wed Jun 24 19:55:08 2015 +0300

----------------------------------------------------------------------
 .../libraries/providers/repository.py                  | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/10572326/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py b/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
index 139cd68..4e5482b 100644
--- a/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
+++ b/ambari-common/src/main/python/resource_management/libraries/providers/repository.py
@@ -32,6 +32,7 @@ from resource_management.core.source import StaticFile
 from resource_management.libraries.functions.format import format
 from resource_management.core.environment import Environment
 from resource_management.core.shell import checked_call
+from resource_management.core import sudo
 import re
 
 REPO_TEMPLATE_FOLDER = 'data'
@@ -46,10 +47,13 @@ class RhelSuseRepositoryProvider(Provider):
                              base_url=self.resource.base_url, mirror_list=self.resource.mirror_list)
       repo_file_path = format("{repo_dir}/{repo_file_name}.repo")
       if self.resource.append_to_file and os.path.isfile(repo_file_path):
-        with open(repo_file_path, 'a') as repo_file:
-          repo_file.write('\n' + new_content.get_content())
+        content = sudo.read_file(repo_file_path) + '\n' + new_content.get_content()
       else:
-        File(repo_file_path, content=new_content)
+        content = new_content
+        
+      File(repo_file_path, 
+           content=content
+      )
   
   def action_remove(self):
     with Environment.get_instance_copy() as env:
@@ -85,8 +89,7 @@ class UbuntuRepositoryProvider(Provider):
                                       components=' '.join(self.resource.components)).get_content()
         old_content = ''
         if self.resource.append_to_file and os.path.isfile(repo_file_path):
-          with open(repo_file_path) as repo_file:
-            old_content = repo_file.read() + '\n'
+            old_content = sudo.read_file(repo_file_path) + '\n'
 
         File(tmpf.name, content=old_content+new_content)