From a59a1df85382d559362c51bb45284b61caaca1d4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 27 Oct 2017 12:53:52 -0500 Subject: [PATCH] mgr/balancer: simplify pool_info tracking Signed-off-by: Sage Weil --- src/pybind/mgr/balancer/module.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 2e46eccd6eebe..b8cc087b9e8b8 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -377,11 +377,13 @@ class Module(MgrModule): def calc_eval(self, ms): pe = Eval(ms) pool_rule = {} + pool_info = {} for p in ms.osdmap_dump.get('pools',[]): pe.pool_name[p['pool']] = p['pool_name'] pe.pool_id[p['pool_name']] = p['pool'] pool_rule[p['pool_name']] = p['crush_rule'] pe.pool_roots[p['pool_name']] = [] + pool_info[p['pool_name']] = p pools = pe.pool_id.keys() if len(pools) == 0: return pe @@ -433,9 +435,7 @@ class Module(MgrModule): self.log.debug('target_by_root %s' % pe.target_by_root) # pool and root actual - for pool in pools: - pi = [p for p in ms.osdmap_dump.get('pools',[]) - if p['pool_name'] == pool][0] + for pool, pi in pool_info.iteritems(): poolid = pi['pool'] pm = ms.pg_up_by_poolid[poolid] pgs = 0 -- 2.39.5