From: Loic Dachary Date: Thu, 18 Dec 2014 22:12:48 +0000 (+0100) Subject: ceph_objectstore_tool: --op list now prints [pg,object] X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8cedafff91b979ea63ff2e2ed99b266e0cb9e64b;p=ceph.git ceph_objectstore_tool: --op list now prints [pg,object] 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 (cherry picked from commit 3c2aaa9c359ff7f9273d0e0bcc139ee046e9a128) --- diff --git a/tasks/ceph_objectstore_tool.py b/tasks/ceph_objectstore_tool.py index 0d5bf3534b4c8..602f5e2b0c6e7 100644 --- a/tasks/ceph_objectstore_tool.py +++ b/tasks/ceph_objectstore_tool.py @@ -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)