]> git.proxmox.com Git - ceph.git/blobdiff - ceph/qa/tasks/admin_socket.py
import 15.2.0 Octopus source
[ceph.git] / ceph / qa / tasks / admin_socket.py
index 3301372756be26c5c1bee2dfb9c78bcf807a2e3a..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
@@ -68,7 +68,7 @@ def task(ctx, config):
     teuthology.replace_all_with_clients(ctx.cluster, config)
 
     with parallel() as ptask:
-        for client, tests in config.iteritems():
+        for client, tests in config.items():
             ptask.spawn(_run_tests, ctx, client, tests)
 
 
@@ -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)
 
@@ -124,7 +119,7 @@ def _run_tests(ctx, client, tests):
     """
     testdir = teuthology.get_testdir(ctx)
     log.debug('Running admin socket tests on %s', client)
-    (remote,) = ctx.cluster.only(client).remotes.iterkeys()
+    (remote,) = ctx.cluster.only(client).remotes.keys()
     socket_path = '/var/run/ceph/ceph-{name}.asok'.format(name=client)
     overrides = ctx.config.get('overrides', {}).get('admin_socket', {})
 
@@ -145,7 +140,7 @@ def _run_tests(ctx, client, tests):
                 ],
             )
 
-        for command, config in tests.iteritems():
+        for command, config in tests.items():
             if config is None:
                 config = {}
             teuthology.deep_merge(config, overrides)