]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
Add safe_makedirs function
authorTravis Rhoden <trhoden@redhat.com>
Thu, 7 May 2015 21:43:15 +0000 (17:43 -0400)
committerTravis Rhoden <trhoden@redhat.com>
Thu, 7 May 2015 21:43:15 +0000 (17:43 -0400)
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 <trhoden@redhat.com>
ceph_deploy/hosts/remotes.py

index 88812fc34d1c3478b912c3c384e4376ae491615f..6c8e63aab8c96717442be750c92c1e7f415a96dd 100644 (file)
@@ -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