From 4bc9e271d5d5d7715dfd36d0142e8aba2911138e Mon Sep 17 00:00:00 2001 From: Travis Rhoden Date: Thu, 7 May 2015 17:43:15 -0400 Subject: [PATCH] Add safe_makedirs function safe_makedirs will recursively create paths, just like mkdirs -p The "safe" part is that it wont error/except if any of the paths already exist. Signed-off-by: Travis Rhoden --- ceph_deploy/hosts/remotes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ceph_deploy/hosts/remotes.py b/ceph_deploy/hosts/remotes.py index 88812fc..6c8e63a 100644 --- a/ceph_deploy/hosts/remotes.py +++ b/ceph_deploy/hosts/remotes.py @@ -296,6 +296,17 @@ def safe_mkdir(path): raise +def safe_makedirs(path): + """ create path recursively if it doesn't exist """ + try: + os.makedirs(path) + except OSError, e: + if e.errno == errno.EEXIST: + pass + else: + raise + + def zeroing(dev): """ zeroing last few blocks of device """ # this kills the crab -- 2.47.3