summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py
index a14263eaf..f10422935 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -1273,3 +1273,18 @@ class UndoManager(object):
LOG.exception(msg, **kwargs)
self._rollback()
+
+
+def ensure_tree(path):
+ """Create a directory (and any ancestor directories required)
+
+ :param path: Directory to create
+ """
+ try:
+ os.makedirs(path)
+ except OSError as exc:
+ if exc.errno == errno.EEXIST:
+ if not os.path.isdir(path):
+ raise
+ else:
+ raise