diff options
author | Michael Still <mikal@stillhq.com> | 2012-08-26 21:26:50 +1000 |
---|---|---|
committer | Michael Still <mikal@stillhq.com> | 2012-08-26 21:31:57 +1000 |
commit | e88218ee0f4b04c86ed6f611d4566e38427f3075 (patch) | |
tree | 84b0ad326b0b8236d18efed4ddb6310f8fe2e290 /nova/utils.py | |
parent | 72815cfa963e307df9376ec9eeb296dc45b8acbc (diff) | |
download | nova-e88218ee0f4b04c86ed6f611d4566e38427f3075.tar.gz nova-e88218ee0f4b04c86ed6f611d4566e38427f3075.tar.xz nova-e88218ee0f4b04c86ed6f611d4566e38427f3075.zip |
Move ensure_tree to utils
Its useful to people other that virt drivers.
Change-Id: I721094a1785d7a275f4bfa8994b7b114a6ec07f6
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 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 |