]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_objectstore_tool: --op list now prints [pg,object]
authorLoic Dachary <ldachary@redhat.com>
Thu, 18 Dec 2014 22:12:48 +0000 (23:12 +0100)
committerDavid Zafman <dzafman@redhat.com>
Wed, 4 Mar 2015 00:09:52 +0000 (16:09 -0800)
The format of the output of --op list was changed to include the PG to
which the object belong. It simplifies the loop in
ceph_objectstore_tool.py.

http://tracker.ceph.com/issues/10376 Fixes: #10376

Signed-off-by: Loic Dachary <ldachary@redhat.com>
(cherry picked from commit 3c2aaa9c359ff7f9273d0e0bcc139ee046e9a128)

tasks/ceph_objectstore_tool.py

index 0d5bf3534b4c8e3cee18608a0e024d649533ba5c..602f5e2b0c6e79edabc380cdecfbd7630af6e895 100644 (file)
@@ -276,33 +276,23 @@ def test_objectstore(ctx, config, cli_remote, REP_POOL, REP_NAME, ec=False):
             if string.find(role, "osd.") != 0:
                 continue
             osdid = int(role.split('.')[1])
-            if osdid not in pgs:
-                continue
             log.info("process osd.{id} on {remote}".format(id=osdid, remote=remote))
-            for pg in pgs[osdid]:
-                cmd = (prefix + "--op list --pgid {pg}").format(id=osdid, pg=pg)
-                proc = remote.run(args=cmd.split(), check_status=False, stdout=StringIO())
-                # proc.wait()
-                if proc.exitstatus != 0:
-                    log.error("Bad exit status {ret} from --op list request".format(ret=proc.exitstatus))
-                    ERRORS += 1
-                else:
-                    data = proc.stdout.getvalue()
-                    if len(data):
-                        # This pg has some objects in it
+            cmd = (prefix + "--op list").format(id=osdid)
+            proc = remote.run(args=cmd.split(), check_status=False, stdout=StringIO())
+            if proc.exitstatus != 0:
+                log.error("Bad exit status {ret} from --op list request".format(ret=proc.exitstatus))
+                ERRORS += 1
+            else:
+                for pgline in proc.stdout.getvalue().splitlines():
+                    if not pgline:
+                        continue
+                    (pg, obj) = json.loads(pgline)
+                    name = obj['oid']
+                    if name in db:
                         pgswithobjects.add(pg)
-                        pglines = data.split('\n')
-                        # All copies of a pg are the same so we can overwrite
-                        objsinpg[pg] = []
-                        while(len(pglines)):
-                            # Drop any blank lines
-                            if (len(pglines[-1]) == 0):
-                                pglines.pop()
-                                continue
-                            objjson = pglines.pop()
-                            name = json.loads(objjson)['oid']
-                            objsinpg[pg].append(name)
-                            db[name].setdefault("pg2json", {})[pg] = objjson
+                        objsinpg.setdefault(pg, []).append(name)
+                        db[name].setdefault("pg2json",
+                                            {})[pg] = json.dumps(obj)
 
     log.info(db)
     log.info(pgswithobjects)