From af4058f8b5659fe4b5b46b064e279d5b9d50c220 Mon Sep 17 00:00:00 2001 From: "Jay S. Bryant" Date: Fri, 20 Feb 2015 15:05:56 -0600 Subject: [PATCH] Sync the 'fileutils' module from oslo-incubator The fileutils module hasn't been updated since November of 2014. We need to bring this module up to date to support the namespace changes that have been made. Current HEAD in OSLO: --------------------- commit e589dde0721a0a67e4030813e582afec6e70d042 Date: Wed Feb 18 03:08:12 2015 +0000 Merge "Have a little fun with release notes" Changes merged with this patch: --------------------- ac17de97 - Use oslo_utils instead of deprecated oslo.utils 809080ed - Introduce fileutils ensure_dir creation mode parameter Change-Id: I0bca3cc59126abed8ef736bf5e199857f681e5cd --- cinder/openstack/common/fileutils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cinder/openstack/common/fileutils.py b/cinder/openstack/common/fileutils.py index ec26eaf9c..6cacf22b2 100644 --- a/cinder/openstack/common/fileutils.py +++ b/cinder/openstack/common/fileutils.py @@ -17,6 +17,7 @@ import contextlib import errno import logging import os +import stat import tempfile from oslo.utils import excutils @@ -24,15 +25,17 @@ from oslo.utils import excutils LOG = logging.getLogger(__name__) _FILE_CACHE = {} +DEFAULT_MODE = stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO -def ensure_tree(path): +def ensure_tree(path, mode=DEFAULT_MODE): """Create a directory (and any ancestor directories required) :param path: Directory to create + :param mode: Directory creation permissions """ try: - os.makedirs(path) + os.makedirs(path, mode) except OSError as exc: if exc.errno == errno.EEXIST: if not os.path.isdir(path): -- 2.45.2