From 3bd3e641213550eacecbddd4e76bbea8daa3f0f2 Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Fri, 25 Oct 2019 14:24:19 +0200 Subject: [PATCH] restful: Use node_id for _gather_leaf_ids The _gather_leaf_ids function doesn't need the node structure, it only needs the id. Signed-off-by: Boris Ranto (cherry picked from commit a325f28d93defbec48793060d6768204da94edd5) --- src/pybind/mgr/restful/common.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/restful/common.py b/src/pybind/mgr/restful/common.py index b5e03b66849d5..8f62b438b9400 100644 --- a/src/pybind/mgr/restful/common.py +++ b/src/pybind/mgr/restful/common.py @@ -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'] -- 2.39.5