def save_buckets_tree(self, buckets): ceph_api = CephAPI() buckets_types = ceph_api.get_bucket_types() buckets_tree = json.loads(buckets) crush_map = [] for bucket_tree in buckets_tree: if "children" in bucket_tree.keys(): get_children_info(bucket_tree, crush_map, buckets_types) else: crush_map.append({ "name": bucket_tree["name"], "id": bucket_tree["id"], "class_ids": bucket_tree["class_ids"], "hash": bucket_tree["hash"], "alg": bucket_tree["alg"], "type_id": buckets_types.index(bucket_tree["type"]) }) ceph_api.save_buckets(crush_map)
def get_buckets_types(self): ceph_api = CephAPI() buckets_type = ceph_api.get_bucket_types() return json.dumps(buckets_type)