]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-11694] Add file mode option to write_file()
authorTravis Rhoden <trhoden@redhat.com>
Fri, 22 May 2015 14:49:28 +0000 (10:49 -0400)
committerTravis Rhoden <trhoden@redhat.com>
Tue, 26 May 2015 14:38:26 +0000 (10:38 -0400)
You an now pass a file mode to write_file with "mode=" and
it will set the file mode that after writing the file.

Signed-off-by: Travis Rhoden <trhoden@redhat.com>
(cherry picked from commit 5368d9d14d3bfbef480d1302511121768d557d5e)

ceph_deploy/hosts/remotes.py

index f2c2e82a0b010f62c25b136389223ea1a38a14d4..fb4d1bbaaa3fa7c85a3395c1b579e1a4fb2afa79 100644 (file)
@@ -200,12 +200,12 @@ def write_monitor_keyring(keyring, monitor_keyring):
     write_file(keyring, monitor_keyring)
 
 
-def write_file(path, content, directory=None):
+def write_file(path, content, mode=0644, directory=None):
     if directory:
         if path.startswith("/"):
             path = path[1:]
         path = os.path.join(directory, path)
-    with file(path, 'w') as f:
+    with os.fdopen(os.open(path, os.O_WRONLY | os.O_CREAT, mode), 'w') as f:
         f.write(content)