]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks: fix imports for py3 compatibility
authorKyr Shatskyy <kyrylo.shatskyy@suse.com>
Sat, 14 Dec 2019 00:16:34 +0000 (01:16 +0100)
committerKefu Chai <kchai@redhat.com>
Tue, 2 Jun 2020 02:32:23 +0000 (10:32 +0800)
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
(cherry picked from commit e46eb8348e0639ea162b7e224bca40e0257ad6ef)

qa/tasks/ceph.py
qa/tasks/ceph_manager.py
qa/tasks/cephfs/filesystem.py
qa/tasks/scrub.py

index c5d7cdd914b32ab339b7770733659ca33493dd05..c44e2cf26bfb4cfdd4a6064e175c924344b9834e 100644 (file)
@@ -19,14 +19,14 @@ import six
 import socket
 
 from paramiko import SSHException
-from ceph_manager import CephManager, write_conf
+from tasks.ceph_manager import CephManager, write_conf
 from tarfile import ReadError
 from tasks.cephfs.filesystem import Filesystem
 from teuthology import misc as teuthology
 from teuthology import contextutil
 from teuthology import exceptions
 from teuthology.orchestra import run
-import ceph_client as cclient
+import tasks.ceph_client as cclient
 from teuthology.orchestra.daemon import DaemonGroup
 
 CEPH_ROLE_TYPES = ['mon', 'mgr', 'osd', 'mds', 'rgw']
index 5d1e845f0ccad09fca1751e84bd74ef6626b1f35..e20583763384a34e0a4cde402e1c54f736cf12eb 100644 (file)
@@ -17,8 +17,8 @@ import os
 from io import BytesIO
 from teuthology import misc as teuthology
 from tasks.scrub import Scrubber
-from util.rados import cmd_erasure_code_profile
-from util import get_remote
+from tasks.util.rados import cmd_erasure_code_profile
+from tasks.util import get_remote
 from teuthology.contextutil import safe_while
 from teuthology.orchestra.remote import Remote
 from teuthology.orchestra import run
index 2e1a0d854af2bf3e52c6b5ab12bc2fed7765c5ab..3f1f9bf8036784a61c610026713ed48b14abd5cf 100644 (file)
@@ -1,5 +1,4 @@
 
-from StringIO import StringIO
 import json
 import logging
 from gevent import Greenlet
@@ -935,11 +934,9 @@ class Filesystem(MDSCluster):
             'sudo', os.path.join(self._prefix, 'rados'), '-p', self.metadata_pool_name, 'get', object_id, temp_bin_path
         ])
 
-        stdout = StringIO()
-        self.client_remote.run(args=[
+        dump_json = self.client_remote.sh([
             'sudo', os.path.join(self._prefix, 'ceph-dencoder'), 'type', object_type, 'import', temp_bin_path, 'decode', 'dump_json'
-        ], stdout=stdout)
-        dump_json = stdout.getvalue().strip()
+        ]).strip()
         try:
             dump = json.loads(dump_json)
         except (TypeError, ValueError):
@@ -1061,22 +1058,20 @@ class Filesystem(MDSCluster):
             os.path.join(self._prefix, "rados"), "-p", pool, "getxattr", obj_name, xattr_name
         ]
         try:
-            proc = remote.run(
-                args=args,
-                stdout=StringIO())
+            data = remote.sh(args)
         except CommandFailedError as e:
             log.error(e.__str__())
             raise ObjectNotFound(obj_name)
 
-        data = proc.stdout.getvalue()
-
-        p = remote.run(
-            args=[os.path.join(self._prefix, "ceph-dencoder"), "type", type, "import", "-", "decode", "dump_json"],
-            stdout=StringIO(),
+        dump = remote.sh(
+            [os.path.join(self._prefix, "ceph-dencoder"),
+                                            "type", type,
+                                            "import", "-",
+                                            "decode", "dump_json"],
             stdin=data
         )
 
-        return json.loads(p.stdout.getvalue().strip())
+        return json.loads(dump.strip())
 
     def _write_data_xattr(self, ino_no, xattr_name, data, pool=None):
         """
@@ -1098,9 +1093,7 @@ class Filesystem(MDSCluster):
             os.path.join(self._prefix, "rados"), "-p", pool, "setxattr",
             obj_name, xattr_name, data
         ]
-        remote.run(
-            args=args,
-            stdout=StringIO())
+        remote.sh(args)
 
     def read_backtrace(self, ino_no, pool=None):
         """
@@ -1223,11 +1216,8 @@ class Filesystem(MDSCluster):
         if stdin_file is not None:
             args = ["bash", "-c", "cat " + stdin_file + " | " + " ".join(args)]
 
-        p = remote.run(
-            args=args,
-            stdin=stdin_data,
-            stdout=StringIO())
-        return p.stdout.getvalue().strip()
+        output = remote.sh(args, stdin=stdin_data)
+        return output.strip()
 
     def list_dirfrag(self, dir_ino):
         """
@@ -1304,9 +1294,7 @@ class Filesystem(MDSCluster):
             base_args.extend(["--rank", "%s" % str(rank)])
 
         t1 = datetime.datetime.now()
-        r = self.tool_remote.run(
-            args=base_args + args,
-            stdout=StringIO()).stdout.getvalue().strip()
+        r = self.tool_remote.sh(base_args + args).strip()
         duration = datetime.datetime.now() - t1
         log.info("Ran {0} in time {1}, result:\n{2}".format(
             base_args + args, duration, r
index a8525b73bbda6d32ef744967016e15c9bf39219c..7cf304e845d0785b7254339247536b33b5cfd93b 100644 (file)
@@ -7,7 +7,7 @@ import logging
 import random
 import time
 
-import ceph_manager
+import tasks.ceph_manager
 from teuthology import misc as teuthology
 
 log = logging.getLogger(__name__)