From b54b0f92423d0e06639c02a67d30ab18907bd2e1 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Mon, 23 Sep 2019 13:15:35 +0000 Subject: [PATCH] mgr/dashboard: Display the "destroyed" state in OSD list Signed-off-by: Tiago Melo --- .../cluster/osd/osd-list/osd-list.component.html | 2 +- .../osd/osd-list/osd-list.component.spec.ts | 14 ++++++++++++-- .../cluster/osd/osd-list/osd-list.component.ts | 10 +++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html index 7b2dcd69b31..01c3a3f6fbc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html @@ -35,7 +35,7 @@ let-value="value"> {{ state }} + [ngClass]="{'badge-success': ['in', 'up'].includes(state), 'badge-danger': ['down', 'out', 'destroyed'].includes(state)}">{{ state }}   diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts index 59e82dcc14d..a26a34d713a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts @@ -4,7 +4,7 @@ import { ReactiveFormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { RouterTestingModule } from '@angular/router/testing'; -import _ = require('lodash'); +import * as _ from 'lodash'; import { BsModalService } from 'ngx-bootstrap/modal'; import { TabsModule } from 'ngx-bootstrap/tabs'; import { EMPTY, of } from 'rxjs'; @@ -129,7 +129,8 @@ describe('OsdListComponent', () => { stats: { stat_bytes_used: n * n, stat_bytes: n * n * n - } + }, + state: [] }); const expectAttributeOnEveryOsd = (attr: string) => @@ -156,6 +157,15 @@ describe('OsdListComponent', () => { expect(component.osds[0].collectedStates).toEqual(['in', 'up']); }); + it('should have "destroyed" state in "collectedStates"', () => { + osds[0].state.push('destroyed'); + osds[0].up = 0; + component.getOsdList(); + + expectAttributeOnEveryOsd('collectedStates'); + expect(component.osds[0].collectedStates).toEqual(['in', 'destroyed']); + }); + it('should have custom attribute "stats_history.out_bytes"', () => { expectAttributeOnEveryOsd('stats_history.out_bytes'); expect(component.osds[0].stats_history.out_bytes).toEqual([1, 2]); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts index abf6f2992f6..103b0e20a9f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts @@ -56,7 +56,15 @@ export class OsdListComponent implements OnInit { osds = []; protected static collectStates(osd) { - return [osd['in'] ? 'in' : 'out', osd['up'] ? 'up' : 'down']; + const states = [osd['in'] ? 'in' : 'out']; + if (osd['up']) { + states.push('up'); + } else if (osd.state.includes('destroyed')) { + states.push('destroyed'); + } else { + states.push('down'); + } + return states; } constructor( -- 2.39.5