From 1b28705be53a97d16973125b90971573f9e30c0a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20M=C3=BCller?= Date: Fri, 13 Apr 2018 17:43:18 +0200 Subject: [PATCH] mgr/dashboard: Add pool listing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Adds a new top level menu entry, called "Pool", which lists all pools and contains a minimalistic detail view. Signed-off-by: Stephan Müller --- qa/tasks/mgr/dashboard/test_pool.py | 4 +- src/pybind/mgr/dashboard/controllers/pool.py | 2 + .../frontend/src/app/app-routing.module.ts | 2 + .../frontend/src/app/ceph/ceph.module.ts | 2 + .../pool/pool-list/pool-list.component.html | 19 +++++ .../pool/pool-list/pool-list.component.scss | 0 .../pool-list/pool-list.component.spec.ts | 34 ++++++++ .../pool/pool-list/pool-list.component.ts | 77 +++++++++++++++++++ .../frontend/src/app/ceph/pool/pool.module.ts | 24 ++++++ .../navigation/navigation.component.html | 8 ++ .../src/app/shared/api/pool.service.ts | 4 + 11 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.scss create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.module.ts diff --git a/qa/tasks/mgr/dashboard/test_pool.py b/qa/tasks/mgr/dashboard/test_pool.py index d04fd2b0be0d..bae49fc8b360 100644 --- a/qa/tasks/mgr/dashboard/test_pool.py +++ b/qa/tasks/mgr/dashboard/test_pool.py @@ -31,6 +31,7 @@ class PoolTest(DashboardTestCase): for pool in data: self.assertIn('pool_name', pool) self.assertIn('type', pool) + self.assertIn('application_metadata', pool) self.assertIn('flags', pool) self.assertIn('flags_names', pool) self.assertNotIn('stats', pool) @@ -61,6 +62,7 @@ class PoolTest(DashboardTestCase): for pool in data: self.assertIn('pool_name', pool) self.assertIn('type', pool) + self.assertIn('application_metadata', pool) self.assertIn('flags', pool) self.assertIn('stats', pool) self.assertIn('flags_names', pool) @@ -93,7 +95,7 @@ class PoolTest(DashboardTestCase): self.assertEqual(pool[k], int(v), '{}: {} != {}'.format(k, pool[k], v)) elif k == 'application_metadata': self.assertEqual(pool[k], - {name: {} for name in data['application_metadata'].split(',')}) + data['application_metadata'].split(',')) elif k == 'pool': self.assertEqual(pool['pool_name'], v) elif k in ['compression_mode', 'compression_algorithm', diff --git a/src/pybind/mgr/dashboard/controllers/pool.py b/src/pybind/mgr/dashboard/controllers/pool.py index 6a8f605d02c0..56f5c9a026b2 100644 --- a/src/pybind/mgr/dashboard/controllers/pool.py +++ b/src/pybind/mgr/dashboard/controllers/pool.py @@ -27,6 +27,8 @@ class Pool(RESTController): res[attr] = {1: 'replicated', 3: 'erasure'}[pool[attr]] elif attr == 'crush_rule': res[attr] = crush_rules[pool[attr]] + elif attr == 'application_metadata': + res[attr] = pool[attr].keys() else: res[attr] = pool[attr] diff --git a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts index 5c8e025abd99..f6b0ed126d26 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts @@ -15,6 +15,7 @@ import { DashboardComponent } from './ceph/dashboard/dashboard/dashboard.compone import { PerformanceCounterComponent } from './ceph/performance-counter/performance-counter/performance-counter.component'; +import { PoolListComponent } from './ceph/pool/pool-list/pool-list.component'; import { RgwBucketListComponent } from './ceph/rgw/rgw-bucket-list/rgw-bucket-list.component'; import { RgwDaemonListComponent } from './ceph/rgw/rgw-daemon-list/rgw-daemon-list.component'; import { RgwUserListComponent } from './ceph/rgw/rgw-user-list/rgw-user-list.component'; @@ -47,6 +48,7 @@ const routes: Routes = [ { path: 'block/rbd', component: RbdListComponent, canActivate: [AuthGuardService] }, { path: 'rbd/add', component: RbdFormComponent, canActivate: [AuthGuardService] }, { path: 'rbd/edit/:pool/:name', component: RbdFormComponent, canActivate: [AuthGuardService] }, + { path: 'pool', component: PoolListComponent, canActivate: [AuthGuardService] }, { path: 'perf_counters/:type/:id', component: PerformanceCounterComponent, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/ceph.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/ceph.module.ts index 0f74b8234a6e..add8458502cf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/ceph.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/ceph.module.ts @@ -7,6 +7,7 @@ import { CephfsModule } from './cephfs/cephfs.module'; import { ClusterModule } from './cluster/cluster.module'; import { DashboardModule } from './dashboard/dashboard.module'; import { PerformanceCounterModule } from './performance-counter/performance-counter.module'; +import { PoolModule } from './pool/pool.module'; import { RgwModule } from './rgw/rgw.module'; @NgModule({ @@ -17,6 +18,7 @@ import { RgwModule } from './rgw/rgw.module'; RgwModule, PerformanceCounterModule, BlockModule, + PoolModule, CephfsModule, SharedModule ], diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html new file mode 100644 index 000000000000..5bda82ef1000 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.scss new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts new file mode 100644 index 000000000000..b5b32d5fa616 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.spec.ts @@ -0,0 +1,34 @@ +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TabsModule } from 'ngx-bootstrap/tabs/tabs.module'; + +import { SharedModule } from '../../../shared/shared.module'; +import { PoolListComponent } from './pool-list.component'; + +describe('PoolListComponent', () => { + let component: PoolListComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PoolListComponent ], + imports: [ + SharedModule, + TabsModule.forRoot(), + HttpClientTestingModule + ], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PoolListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts new file mode 100644 index 000000000000..303eca25d29f --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts @@ -0,0 +1,77 @@ +import { Component } from '@angular/core'; + +import { PoolService } from '../../../shared/api/pool.service'; +import { CdTableColumn } from '../../../shared/models/cd-table-column'; +import { CdTableSelection } from '../../../shared/models/cd-table-selection'; + +@Component({ + selector: 'cd-pool-list', + templateUrl: './pool-list.component.html', + styleUrls: ['./pool-list.component.scss'] +}) +export class PoolListComponent { + pools = []; + columns: CdTableColumn[]; + selection = new CdTableSelection(); + + constructor( + private poolService: PoolService, + ) { + this.columns = [ + { + prop: 'pool_name', + name: 'Name', + flexGrow: 3 + }, + { + prop: 'type', + name: 'Type', + flexGrow: 2 + }, + { + prop: 'application_metadata', + name: 'Applications', + flexGrow: 3 + }, + { + prop: 'pg_placement_num', + name: 'Placement Groups', + flexGrow: 1, + cellClass: 'text-right' + }, + { + prop: 'size', + name: 'Replica Size', + flexGrow: 1, + cellClass: 'text-right' + }, + { + prop: 'last_change', + name: 'Last Change', + flexGrow: 1, + cellClass: 'text-right' + }, + { + prop: 'erasure_code_profile', + name: 'Erasure Coded Profile', + flexGrow: 2 + }, + { + prop: 'crush_rule', + name: 'Crush Ruleset', + flexGrow: 2 + } + ]; + } + + updateSelection(selection: CdTableSelection) { + this.selection = selection; + } + + getPoolList() { + this.poolService.getList().subscribe((pools: any[]) => { + this.pools = pools; + }); + } + +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.module.ts new file mode 100644 index 000000000000..bae60b59c2d9 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.module.ts @@ -0,0 +1,24 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; + +import { TabsModule } from 'ngx-bootstrap/tabs'; + +import { ServicesModule } from '../../shared/services/services.module'; +import { SharedModule } from '../../shared/shared.module'; +import { PoolListComponent } from './pool-list/pool-list.component'; + +@NgModule({ + imports: [ + CommonModule, + TabsModule, + SharedModule, + ServicesModule + ], + exports: [ + PoolListComponent + ], + declarations: [ + PoolListComponent + ] +}) +export class PoolModule { } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html index 54cde66a9075..0a3d8fa5471f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.html @@ -80,6 +80,14 @@ + +
  • + Pool + +
  • +
  • { -- 2.47.3