From d8b9a2b43e586654e2d1aba05de222552ffcf67b Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 17 Oct 2013 09:20:04 -0400 Subject: [PATCH] better path checking when attempting to write the config Signed-off-by: Alfredo Deza --- ceph_deploy/hosts/remotes.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ceph_deploy/hosts/remotes.py b/ceph_deploy/hosts/remotes.py index 19c8038..b556fbe 100644 --- a/ceph_deploy/hosts/remotes.py +++ b/ceph_deploy/hosts/remotes.py @@ -40,8 +40,15 @@ def write_conf(cluster, conf, overwrite): old = f.read() if old != conf and not overwrite: raise RuntimeError(err_msg) - tmp_file.write(conf) - os.rename(tmp_file.name, path) + tmp_file.write(conf) + os.rename(tmp_file.name, path) + return + if os.path.exists('/etc/ceph'): + with open(path, 'w') as f: + f.write(conf) + else: + err_msg = '/etc/ceph/ does not exist - could not write config' + raise RuntimeError(err_msg) def write_keyring(path, key): -- 2.47.3