From: Mykola Golub Date: Wed, 29 Sep 2021 07:18:03 +0000 (+0300) Subject: tools/crushdiff: support old format json dump X-Git-Tag: v17.1.0~729^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=40a67b1b4abcbe5e388ef9bb1e0a7b3e252994ee;p=ceph.git tools/crushdiff: support old format json dump Someone may try running crushdiff against osdmap and pg dump collected for an older cluster. In general it is not guaranteed to work as not tested well, but still we can do our best to make it work if possible. One know issue is that for older versions `ceph pg dump` json output does not have a separate 'pg_map' section, where actual data is stored. This change makes crushdiff to support this old format too. Signed-off-by: Mykola Golub --- diff --git a/src/tools/crushdiff b/src/tools/crushdiff index ca9173379731..4b0b71bed43e 100755 --- a/src/tools/crushdiff +++ b/src/tools/crushdiff @@ -104,7 +104,8 @@ def get_erasure_code_profiles(osdmap): def get_pgmap(pg_dump_file): with open(pg_dump_file, "r") as f: - return json.load(f)['pg_map'] + dump = json.load(f) + return dump.get('pg_map', dump) def get_pg_stats(pgmap): return {pg['pgid']: pg for pg in pgmap['pg_stats']}