]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/admin_socket: get rid of cStringIO for py3
authorKyr Shatskyy <kyrylo.shatskyy@suse.com>
Fri, 21 Feb 2020 18:35:15 +0000 (19:35 +0100)
committerKefu Chai <kchai@redhat.com>
Wed, 4 Mar 2020 05:09:17 +0000 (13:09 +0800)
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
qa/tasks/admin_socket.py

index 54fe1a1ba5dff3bc08b4ea0a74732e083261af4a..c454d3d0c03ee41d9ab8ca3a67ad6975eaa2c1d4 100644 (file)
@@ -1,13 +1,13 @@
 """
 Admin Socket task -- used in rados, powercycle, and smoke testing
 """
-from cStringIO import StringIO
 
 import json
 import logging
 import os
 import time
 
+from teuthology.exceptions import CommandFailedError
 from teuthology.orchestra import run
 from teuthology import misc as teuthology
 from teuthology.parallel import parallel
@@ -84,31 +84,26 @@ def _socket_command(ctx, remote, socket_path, command, args):
 
     :returns: output of command in json format
     """
-    json_fp = StringIO()
     testdir = teuthology.get_testdir(ctx)
     max_tries = 120
     while True:
-        proc = remote.run(
-            args=[
+        try:
+            out = remote.sh([
                 'sudo',
                 'adjust-ulimits',
                 'ceph-coverage',
                 '{tdir}/archive/coverage'.format(tdir=testdir),
                 'ceph',
                 '--admin-daemon', socket_path,
-                ] + command.split(' ') + args,
-            stdout=json_fp,
-            check_status=False,
-            )
-        if proc.exitstatus == 0:
-            break
-        assert max_tries > 0
-        max_tries -= 1
-        log.info('ceph cli returned an error, command not registered yet?')
-        log.info('sleeping and retrying ...')
-        time.sleep(1)
-    out = json_fp.getvalue()
-    json_fp.close()
+                ] + command.split(' ') + args)
+        except CommandFailedError:
+            assert max_tries > 0
+            max_tries -= 1
+            log.info('ceph cli returned an error, command not registered yet?')
+            log.info('sleeping and retrying ...')
+            time.sleep(1)
+            continue
+        break
     log.debug('admin socket command %s returned %s', command, out)
     return json.loads(out)