]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
restful: Use node_id for _gather_leaf_ids 31153/head
authorBoris Ranto <branto@redhat.com>
Fri, 25 Oct 2019 12:24:19 +0000 (14:24 +0200)
committerBoris Ranto <branto@redhat.com>
Fri, 25 Oct 2019 13:51:15 +0000 (15:51 +0200)
The _gather_leaf_ids function doesn't need the node structure, it only
needs the id.

Signed-off-by: Boris Ranto <branto@redhat.com>
src/pybind/mgr/restful/common.py

index f249c520766522e4eb5eee5522500d4a2def5788..fbe5e208670d0bcd4b8a3b657655f4a80bf03113 100644 (file)
@@ -91,13 +91,13 @@ def pool_update_commands(pool_name, args):
 def crush_rule_osds(node_buckets, rule):
     nodes_by_id = dict((b['id'], b) for b in node_buckets)
 
-    def _gather_leaf_ids(node):
-        if node['id'] >= 0:
-            return set([node['id']])
+    def _gather_leaf_ids(node_id):
+        if node_id >= 0:
+            return set([node_id])
 
         result = set()
-        for item in nodes_by_id[node['id']]['items']:
-            result |= _gather_leaf_ids(item)
+        for item in nodes_by_id[node_id]['items']:
+            result |= _gather_leaf_ids(item['id'])
 
         return result
 
@@ -143,7 +143,7 @@ def crush_rule_osds(node_buckets, rule):
                         # Short circuit another iteration to find the emit
                         # and assume anything we've done a chooseleaf on
                         # is going to be part of the selected set of osds
-                        osds |= _gather_leaf_ids(desc_node)
+                        osds |= _gather_leaf_ids(desc_node['id'])
         elif step['op'] == 'emit':
             if root['id'] >= 0:
                 osds |= root['id']