From: Babu Shanmugam Date: Fri, 11 Apr 2014 11:28:14 +0000 (+0000) Subject: While generating crush_types, avoiding item parsing, and calculating type count by... X-Git-Tag: v0.80-rc1~8^2^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6d42bd9f910cdba0902a223ae97d73c22780b028;p=ceph.git While generating crush_types, avoiding item parsing, and calculating type count by just iterating thorugh buckets list Signed-off-by: Babu Shanmugam --- diff --git a/client/ceph-brag b/client/ceph-brag index 6daff795749..d502ee541b7 100755 --- a/client/ceph-brag +++ b/client/ceph-brag @@ -100,26 +100,16 @@ def get_crush_types(): for t in crush_dump['types']: crush_types[t['type_id']] = t['name'] - buckets = {} - items_list = [] + types_list = [] for bucket in crush_dump['buckets']: - buckets[bucket['id']] = bucket['type_id'] - for item in bucket['items']: - if item['id'] < 0: - items_list.append(item['id']) + types_list.append(bucket['type_id']) crush_map = [] - counter = Counter(items_list) + types_counter = Counter(types_list) append = lambda t,c: crush_map.append({'type':t, 'count':c}) - for id,count in counter.items(): - if id in buckets: - append(crush_types[buckets[id]], + for id,count in types_counter.items(): + append(crush_types[id], count) - del buckets[id] - - #the root item - for id,type_id in buckets.items(): - append(crush_types[type_id], 1) if 'devices' in crush_dump: append('devices', len(crush_dump['devices']))