From: Kyr Shatskyy Date: Sat, 14 Dec 2019 00:16:34 +0000 (+0100) Subject: qa/tasks: fix imports for py3 compatibility X-Git-Tag: v15.1.1~129^2~26 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e46eb8348e0639ea162b7e224bca40e0257ad6ef;p=ceph.git qa/tasks: fix imports for py3 compatibility Signed-off-by: Kyr Shatskyy --- diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index 631081c85ecd..3a04d5e55c50 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -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 from tasks.daemonwatchdog import DaemonWatchdog diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 3f090ea33e7b..8c33682c093a 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -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 diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 9c9978562890..0110c9c22f47 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -1,5 +1,4 @@ -from StringIO import StringIO import json import logging from gevent import Greenlet @@ -967,11 +966,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): @@ -1093,22 +1090,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): """ @@ -1130,9 +1125,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): """ @@ -1255,11 +1248,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): """ @@ -1336,9 +1326,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 diff --git a/qa/tasks/scrub.py b/qa/tasks/scrub.py index a8525b73bbda..7cf304e845d0 100644 --- a/qa/tasks/scrub.py +++ b/qa/tasks/scrub.py @@ -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__)