]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add multi root support in CRUSH map 28316/head
authorTiago Melo <tmelo@suse.com>
Thu, 9 May 2019 14:39:48 +0000 (14:39 +0000)
committerTiago Melo <tmelo@suse.com>
Thu, 30 May 2019 14:03:28 +0000 (14:03 +0000)
Fixes: http://tracker.ceph.com/issues/39647
Signed-off-by: Tiago Melo <tmelo@suse.com>
(cherry picked from commit a055f96325cbbb6f5b0fec7b0909275836c6cbab)

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/crushmap/crushmap.component.ts

index a9394aeed978db31ff62adfd0b65e855df24e049..5642543073906efd17836b710cb44672e49b0b5f 100644 (file)
@@ -9,6 +9,7 @@
       <div class="panel-body">
         <div class="col-sm-6 col-lg-6">
           <tree [tree]="tree"
+                [settings]="{rootIsVisible: false}"
                 (nodeSelected)="onNodeSelected($event)">
             <ng-template let-node>
               <span class="label"
index cf884056ec4a12417ccfddefbde08bc83cf42970..2e6e458a202f5de025238d36b6f52ab0035eff42 100644 (file)
@@ -2,10 +2,9 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { DebugElement } from '@angular/core';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
 
-import { of } from 'rxjs';
-
 import { TreeModule } from 'ng2-tree';
 import { TabsModule } from 'ngx-bootstrap/tabs';
+import { of } from 'rxjs';
 
 import { configureTestBed } from '../../../../testing/unit-test-helper';
 import { HealthService } from '../../../shared/api/health.service';
@@ -64,24 +63,88 @@ describe('CrushmapComponent', () => {
           { children: [1, 0, 2], type: 'host', name: 'my-host', id: -2 },
           { 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 }
+          { status: 'up', type: 'osd', name: 'osd.2', id: 2 },
+          { children: [-4], type: 'root', name: 'default-2', id: -3 },
+          { children: [4], type: 'host', name: 'my-host-2', id: -4 },
+          { status: 'up', type: 'osd', name: 'osd.0-2', id: 4 }
         ]);
       });
 
-      it('should have tree structure derived from a root', () => {
-        expect(component.tree.value).toBe('default (root)');
-      });
-
-      it('should have one host child with 3 osd children', () => {
-        expect(component.tree.children.length).toBe(1);
-        expect(component.tree.children[0].value).toBe('my-host (host)');
-        expect(component.tree.children[0].children.length).toBe(3);
-      });
-
-      it('should have 3 osds in orderd', () => {
-        expect(component.tree.children[0].children[0].value).toBe('osd.0 (osd)');
-        expect(component.tree.children[0].children[1].value).toBe('osd.1 (osd)');
-        expect(component.tree.children[0].children[2].value).toBe('osd.2 (osd)');
+      it('should have two root nodes', () => {
+        expect(component.tree.children).toEqual([
+          {
+            children: [
+              {
+                children: [
+                  {
+                    id: 4,
+                    settings: {
+                      static: true
+                    },
+                    status: 'up',
+                    value: 'osd.0-2 (osd)'
+                  }
+                ],
+                id: -4,
+                settings: {
+                  static: true
+                },
+                status: undefined,
+                value: 'my-host-2 (host)'
+              }
+            ],
+            id: -3,
+            settings: {
+              static: true
+            },
+            status: undefined,
+            value: 'default-2 (root)'
+          },
+          {
+            children: [
+              {
+                children: [
+                  {
+                    id: 0,
+                    settings: {
+                      static: true
+                    },
+                    status: 'up',
+                    value: 'osd.0 (osd)'
+                  },
+                  {
+                    id: 1,
+                    settings: {
+                      static: true
+                    },
+                    status: 'down',
+                    value: 'osd.1 (osd)'
+                  },
+                  {
+                    id: 2,
+                    settings: {
+                      static: true
+                    },
+                    status: 'up',
+                    value: 'osd.2 (osd)'
+                  }
+                ],
+                id: -2,
+                settings: {
+                  static: true
+                },
+                status: undefined,
+                value: 'my-host (host)'
+              }
+            ],
+            id: -1,
+            settings: {
+              static: true
+            },
+            status: undefined,
+            value: 'default (root)'
+          }
+        ]);
       });
     });
   });
index d7a6f5e4fbd5f8d1b5c1975a4bdc57440cbf173f..37b56b52de5ba4c9678cbdb821c55f970f216e2b 100644 (file)
@@ -34,12 +34,22 @@ export class CrushmapComponent implements OnInit {
       };
     }
 
-    const rootNodeId = nodes[0].id || null;
+    const roots = [];
     nodes.reverse().forEach((node) => {
+      if (node.type === 'root') {
+        roots.push(node.id);
+      }
       treeNodeMap[node.id] = this.generateTreeLeaf(node, treeNodeMap);
     });
 
-    return treeNodeMap[rootNodeId];
+    const children = roots.map((id) => {
+      return treeNodeMap[id];
+    });
+
+    return {
+      value: 'CRUSH map',
+      children: children
+    };
   }
 
   private generateTreeLeaf(node: any, treeNodeMap) {