]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
rgw: move common rgwadmin function to a new utility file
authorJosh Durgin <josh.durgin@inktank.com>
Fri, 19 Jul 2013 22:16:16 +0000 (15:16 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Wed, 24 Jul 2013 16:59:50 +0000 (09:59 -0700)
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
teuthology/task/radosgw-admin.py
teuthology/task/rgw.py
teuthology/task_util/__init__.py [new file with mode: 0644]
teuthology/task_util/rgw.py [new file with mode: 0644]

index 2bff6108f86571d7002892a1f9f516f4ff3e91dd..a9a0593b39d8930e5a5e6e6a25d64128bb7e6e94 100644 (file)
@@ -15,6 +15,7 @@ import boto.s3.acl
 import time
 
 from teuthology import misc as teuthology
+from teuthology.task.util.rgw import rgwadmin
 
 log = logging.getLogger(__name__)
 
@@ -25,38 +26,6 @@ def successful_ops(out):
     entry = summary[0]
     return entry['total']['successful_ops']
 
-def rgwadmin(ctx, client, cmd, stdin=StringIO()):
-    log.info('radosgw-admin: %s' % cmd)
-    testdir = teuthology.get_testdir(ctx)
-    pre = [
-        '{tdir}/adjust-ulimits'.format(tdir=testdir),
-        'ceph-coverage'.format(tdir=testdir),
-        '{tdir}/archive/coverage'.format(tdir=testdir),
-        'radosgw-admin'.format(tdir=testdir),
-        '--log-to-stderr',
-        '--format', 'json',
-        ]
-    pre.extend(cmd)
-    (remote,) = ctx.cluster.only(client).remotes.iterkeys()
-    proc = remote.run(
-        args=pre,
-        check_status=False,
-        stdout=StringIO(),
-        stderr=StringIO(),
-        stdin=stdin,
-        )
-    r = proc.exitstatus
-    out = proc.stdout.getvalue()
-    j = None
-    if not r and out != '':
-        try:
-            j = json.loads(out)
-            log.info(' json result: %s' % j)
-        except ValueError:
-            j = out
-            log.info(' raw result: %s' % j)
-    return (r, j)
-
 def task(ctx, config):
     """
     Test radosgw-admin functionality against a running rgw instance.
index c1d3d784aa5663f42c2655c959bd881c1e53202a..7296de3b68d6032b6331e71449b121b6f383bb3c 100644 (file)
@@ -7,42 +7,12 @@ from cStringIO import StringIO
 
 from teuthology import misc as teuthology
 from teuthology import contextutil
+from teuthology.task_util.rgw import rgwadmin
 from ..orchestra import run
 import ceph_manager
 
 log = logging.getLogger(__name__)
 
-# this was lifted from radosgw-admin-rest.
-def rgwadmin(ctx, remote, cmd):
-    log.info('radosgw-admin: %s' % cmd)
-    testdir = teuthology.get_testdir(ctx)
-    pre = [
-        '{tdir}/adjust-ulimits'.format(tdir=testdir),
-        'ceph-coverage'.format(tdir=testdir),
-        '{tdir}/archive/coverage'.format(tdir=testdir),
-        'radosgw-admin'.format(tdir=testdir),
-        '--log-to-stderr',
-        '--format', 'json',
-        ]
-    pre.extend(cmd)
-    proc = remote.run(
-        args=pre,
-        check_status=False,
-        stdout=StringIO(),
-        stderr=StringIO(),
-        )
-    r = proc.exitstatus
-    out = proc.stdout.getvalue()
-    j = None
-    if not r and out != '':
-        try:
-            j = json.loads(out)
-            log.info(' json result: %s' % j)
-        except ValueError:
-            j = out
-            log.info(' raw result: %s' % j)
-    return (r, j)
-
 # this was lifted from lost_unfound.py
 def rados(ctx, remote, cmd):
     testdir = teuthology.get_testdir(ctx)
diff --git a/teuthology/task_util/__init__.py b/teuthology/task_util/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/teuthology/task_util/rgw.py b/teuthology/task_util/rgw.py
new file mode 100644 (file)
index 0000000..5a41f7e
--- /dev/null
@@ -0,0 +1,39 @@
+from cStringIO import StringIO
+import logging
+import json
+
+from teuthology import misc as teuthology
+
+log = logging.getLogger(__name__)
+
+def rgwadmin(ctx, client, cmd, stdin=StringIO()):
+    log.info('radosgw-admin: %s' % cmd)
+    testdir = teuthology.get_testdir(ctx)
+    pre = [
+        '{tdir}/adjust-ulimits'.format(tdir=testdir),
+        'ceph-coverage'.format(tdir=testdir),
+        '{tdir}/archive/coverage'.format(tdir=testdir),
+        'radosgw-admin'.format(tdir=testdir),
+        '--log-to-stderr',
+        '--format', 'json',
+        ]
+    pre.extend(cmd)
+    (remote,) = ctx.cluster.only(client).remotes.iterkeys()
+    proc = remote.run(
+        args=pre,
+        check_status=False,
+        stdout=StringIO(),
+        stderr=StringIO(),
+        stdin=stdin,
+        )
+    r = proc.exitstatus
+    out = proc.stdout.getvalue()
+    j = None
+    if not r and out != '':
+        try:
+            j = json.loads(out)
+            log.info(' json result: %s' % j)
+        except ValueError:
+            j = out
+            log.info(' raw result: %s' % j)
+    return (r, j)