diff options
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py index 7eb7aa662..6f199e659 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -1266,3 +1266,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 |