summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorDavid Ripton <dripton@redhat.com>2013-05-28 10:49:19 -0400
committerDavid Ripton <dripton@redhat.com>2013-05-28 10:56:25 -0400
commita3f28804004805b5f151fc9147ac281d029a4393 (patch)
treed9fc2594aaff7980e9b626e48f68a3962de0d1ec /nova/utils.py
parentca3d4590d3d46e452480bdea3143291c4bd7ca34 (diff)
downloadnova-a3f28804004805b5f151fc9147ac281d029a4393.tar.gz
nova-a3f28804004805b5f151fc9147ac281d029a4393.tar.xz
nova-a3f28804004805b5f151fc9147ac281d029a4393.zip
In utils.tempdir, pass CONF.tempdir as an argument.
It's ugly, and potentially racy, to mess around with other modules' global variables. Instead, pass CONF.tempdir into tempfile.mkdtemp as the 'dir' keyword argument. Because we already pass **kwargs to mkdtemp, inspect **kwargs and only set 'dir' if it's not already there. Change-Id: I8a2b34cd051919db29facabc1664cf357073b1d7
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 97551e8eb..94c425cc1 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -920,8 +920,10 @@ def temporary_chown(path, owner_uid=None):
@contextlib.contextmanager
def tempdir(**kwargs):
- tempfile.tempdir = CONF.tempdir
- tmpdir = tempfile.mkdtemp(**kwargs)
+ argdict = kwargs.copy()
+ if 'dir' not in argdict:
+ argdict['dir'] = CONF.tempdir
+ tmpdir = tempfile.mkdtemp(**argdict)
try:
yield tmpdir
finally: