summaryrefslogtreecommitdiff
path: root/keystone/common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'keystone/common/utils.py')
-rw-r--r--keystone/common/utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/keystone/common/utils.py b/keystone/common/utils.py
index 7c3e7ae1a..70d277e52 100644
--- a/keystone/common/utils.py
+++ b/keystone/common/utils.py
@@ -17,6 +17,7 @@
# under the License.
import collections.abc
+import contextlib
import grp
import hashlib
import itertools
@@ -489,3 +490,9 @@ def create_directory(directory, keystone_user_id=None, keystone_group_id=None):
'Unable to change the ownership of key repository without '
'a keystone user ID and keystone group ID both being '
'provided: %s', directory)
+
+
+@contextlib.contextmanager
+def nested_contexts(*contexts):
+ with contextlib.ExitStack() as stack:
+ yield [stack.enter_context(c) for c in contexts]