diff options
| author | Michael Still <mikal@stillhq.com> | 2012-08-06 10:40:08 +1000 |
|---|---|---|
| committer | Michael Still <mikal@stillhq.com> | 2012-08-06 12:34:26 +1000 |
| commit | 9bf48de84d38196eba3a55f51ea94038e1beb964 (patch) | |
| tree | a31a65c396beebc341238b3ef15076d70dd11dba | |
| parent | 9142e11580e901875617400c62e9f18aeb7d3b21 (diff) | |
ensure_tree calls mkdir -p
Let's use os.makedirs() instead...
Change-Id: Ie78b3c1107ac02263703cb5f4406c4ba4f83c7ad
| -rw-r--r-- | nova/virt/libvirt/utils.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py index c954d70ad..5adfe4cae 100644 --- a/nova/virt/libvirt/utils.py +++ b/nova/virt/libvirt/utils.py @@ -19,6 +19,7 @@ # License for the specific language governing permissions and limitations # under the License. +import errno import hashlib import os import random @@ -255,7 +256,14 @@ def ensure_tree(path): :param path: Directory to create """ - execute('mkdir', '-p', path) + try: + os.makedirs(path) + except OSError as exc: + if exc.errno == errno.EEXIST: + if not os.path.isdir(path): + raise + else: + raise def write_to_file(path, contents, umask=None): |
