]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Change `crush_rule` serialization of Pools from id to name
authorSebastian Wagner <sebastian.wagner@suse.com>
Wed, 21 Mar 2018 13:53:28 +0000 (14:53 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Fri, 23 Mar 2018 15:40:18 +0000 (16:40 +0100)
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/dashboard/controllers/pool.py

index c1216333b8af3d0823e398f842927e05f7e0ebe3..9a5176f646e5df9bc5165f97b0a97057e20e4404 100644 (file)
@@ -15,7 +15,9 @@ class Pool(RESTController):
     @classmethod
     def _serialize_pool(cls, pool, attrs):
         if not attrs or not isinstance(attrs, list):
-            return pool
+            attrs = pool.keys()
+
+        crush_rules = {r['rule_id']: r["rule_name"] for r in mgr.get('osd_map_crush')['rules']}
 
         res = {}
         for attr in attrs:
@@ -23,6 +25,8 @@ class Pool(RESTController):
                 continue
             if attr == 'type':
                 res[attr] = {1: 'replicated', 3: 'erasure'}[pool[attr]]
+            elif attr == 'crush_rule':
+                res[attr] = crush_rules[pool[attr]]
             else:
                 res[attr] = pool[attr]