self.assertStatus(200)
self.assertSchemaBody(JObj({
'names': JList(str),
- 'nodes': JList(JObj({}, allow_unknown=True))
+ 'nodes': JList(JObj({}, allow_unknown=True)),
+ 'roots': JList(int)
}))
@ReadPermission
def info(self):
'''Used for crush rule creation modal'''
+ osd_map = mgr.get_osdmap()
+ crush = osd_map.get_crush()
+ crush.dump()
return {
'names': [r['rule_name'] for r in mgr.get('osd_map_crush')['rules']],
- 'nodes': mgr.get('osd_map_tree')['nodes']
+ 'nodes': mgr.get('osd_map_tree')['nodes'],
+ 'roots': crush.find_roots()
}
{ status: 'up', type: 'osd', name: 'osd.0', id: 0 },
{ status: 'down', type: 'osd', name: 'osd.1', id: 1 },
{ status: 'up', type: 'osd', name: 'osd.2', id: 2 },
- { children: [-4], type: 'root', name: 'default-2', id: -3 },
+ { children: [-4], type: 'datacenter', name: 'site1', id: -3 },
{ children: [4], type: 'host', name: 'my-host-2', id: -4 },
{ status: 'up', type: 'osd', name: 'osd.0-2', id: 4 }
- ]
+ ],
+ roots: [-1, -3, -6]
})
);
fixture.detectChanges();
],
id: component.nodes[0].id,
status: undefined,
- type: 'root',
- name: 'default-2 (root)'
+ type: 'datacenter',
+ name: 'site1 (datacenter)'
},
{
children: [
private abstractTreeData(data: any): any[] {
const nodes = data.nodes || [];
+ const rootNodes = data.roots || [];
const treeNodeMap: { [key: number]: any } = {};
if (0 === nodes.length) {
const roots: any[] = [];
nodes.reverse().forEach((node: any) => {
- if (node.type === 'root') {
+ if (rootNodes.includes(node.id)) {
roots.push(node.id);
}
treeNodeMap[node.id] = this.generateTreeLeaf(node, treeNodeMap);