From 5368d9d14d3bfbef480d1302511121768d557d5e Mon Sep 17 00:00:00 2001 From: Travis Rhoden Date: Fri, 22 May 2015 10:49:28 -0400 Subject: [PATCH] [RM-11694] Add file mode option to write_file() 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 --- ceph_deploy/hosts/remotes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ceph_deploy/hosts/remotes.py b/ceph_deploy/hosts/remotes.py index 19be3e4..ba3e7d8 100644 --- a/ceph_deploy/hosts/remotes.py +++ b/ceph_deploy/hosts/remotes.py @@ -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) -- 2.47.3