]> 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>
Fri, 22 May 2015 20:38:36 +0000 (16: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>
ceph_deploy/hosts/remotes.py

index 19be3e46c3d4ea493ee8930451ee4a8a5f41c14e..ba3e7d83f80ba5296a0570ab0563c19cdbcf048d 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)