]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: drop py2 compatible bits
authorKefu Chai <kchai@redhat.com>
Sun, 24 May 2020 04:34:59 +0000 (12:34 +0800)
committerSebastian Wagner <sebastian.wagner@suse.com>
Mon, 8 Jun 2020 11:52:24 +0000 (13:52 +0200)
since we've dropped Python3 support in octopus, there is no need to keep
the workaround for python2 anymore.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 2c71d733d6327a29617ba05b5d56891d45ad28d8)

src/pybind/mgr/cephadm/module.py

index db497013d51400499fbe58a7bd77c935eed0679e..0f5c825a18a84736cd2d6a2dfe9d1e826fe36a05 100644 (file)
@@ -2,8 +2,9 @@ import json
 import errno
 import logging
 from collections import defaultdict
-from threading import Event
 from functools import wraps
+from tempfile import TemporaryDirectory
+from threading import Event
 
 import string
 from typing import List, Dict, Optional, Callable, Tuple, TypeVar, \
@@ -82,27 +83,6 @@ CEPH_DATEFMT = '%Y-%m-%dT%H:%M:%S.%fZ'
 CEPH_TYPES = set(CEPH_UPGRADE_ORDER)
 
 
-# for py2 compat
-try:
-    from tempfile import TemporaryDirectory # py3
-except ImportError:
-    # define a minimal (but sufficient) equivalent for <= py 3.2
-    class TemporaryDirectory(object): # type: ignore
-        def __init__(self):
-            self.name = tempfile.mkdtemp()
-
-        def __enter__(self):
-            if not self.name:
-                self.name = tempfile.mkdtemp()
-            return self.name
-
-        def cleanup(self):
-            shutil.rmtree(self.name)
-
-        def __exit__(self, exc_type, exc_value, traceback):
-            self.cleanup()
-
-
 def forall_hosts(f: Callable[..., T]) -> Callable[..., List[T]]:
     @wraps(f)
     def forall_hosts_wrapper(*args) -> List[T]: