From 9bf48de84d38196eba3a55f51ea94038e1beb964 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Mon, 6 Aug 2012 10:40:08 +1000 Subject: ensure_tree calls mkdir -p Let's use os.makedirs() instead... Change-Id: Ie78b3c1107ac02263703cb5f4406c4ba4f83c7ad --- nova/virt/libvirt/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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): -- cgit