From 5f8eff3beff7b8aa0066811dedf0024b76001a6e Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Fri, 12 Aug 2022 21:04:23 +0530 Subject: [PATCH] mgr/dashboard: osd form preselect db/wal device filters If the hostname is selected for the primary devices, then we can preselect the hostname filter for the db/wal devices because osds will be deployed only on the hostname of the primary device. If preselected it'll be clear that only this devices will be used to deploy. Addition to this, usually ssd devices are used for db/wal devices. So I am preselecting these too in the filters. Fixes: https://tracker.ceph.com/issues/57118 Signed-off-by: Nizamudeen A --- .../inventory-devices.component.ts | 12 ++++++++++++ .../osd-devices-selection-groups.component.ts | 13 +++++++++---- .../osd-devices-selection-modal.component.html | 3 ++- .../osd-devices-selection-modal.component.ts | 12 +++++++++++- .../cluster/osd/osd-form/osd-form.component.html | 6 ++++-- .../ceph/cluster/osd/osd-form/osd-form.component.ts | 1 + 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory-devices/inventory-devices.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory-devices/inventory-devices.component.ts index e0d82cb1975d..0ef0449c4812 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory-devices/inventory-devices.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/inventory/inventory-devices/inventory-devices.component.ts @@ -47,6 +47,10 @@ export class InventoryDevicesComponent implements OnInit, OnDestroy { // Do not display these columns @Input() hiddenColumns: string[] = []; + @Input() hostname = ''; + + @Input() diskType = ''; + // Show filters for these columns, specify empty array to disable @Input() filterColumns = [ 'hostname', @@ -167,6 +171,14 @@ export class InventoryDevicesComponent implements OnInit, OnDestroy { if (col) { col.filterable = true; } + + if (col?.prop === 'human_readable_type' && this.diskType === 'ssd') { + col.filterInitValue = this.diskType; + } + + if (col?.prop === 'hostname' && this.hostname) { + col.filterInitValue = this.hostname; + } }); if (this.fetchInventory.observers.length > 0) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.ts index cff0cbc0563f..6c5cf52f6f53 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-groups/osd-devices-selection-groups.component.ts @@ -76,13 +76,18 @@ export class OsdDevicesSelectionGroupsComponent implements OnInit, OnChanges { } showSelectionModal() { - let filterColumns = ['human_readable_type', 'sys_api.vendor', 'sys_api.model', 'sys_api.size']; - if (this.type === 'data') { - filterColumns = ['hostname', ...filterColumns]; - } + const filterColumns = [ + 'hostname', + 'human_readable_type', + 'sys_api.vendor', + 'sys_api.model', + 'sys_api.size' + ]; + const diskType = this.name === 'Primary' ? 'hdd' : 'ssd'; const initialState = { hostname: this.hostname, deviceType: this.name, + diskType: diskType, devices: this.availDevices, filterColumns: filterColumns }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-modal/osd-devices-selection-modal.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-modal/osd-devices-selection-modal.component.html index 3e53d5c410cd..2a4344944c46 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-modal/osd-devices-selection-modal.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-modal/osd-devices-selection-modal.component.html @@ -20,7 +20,8 @@ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-modal/osd-devices-selection-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-modal/osd-devices-selection-modal.component.ts index edfe9d6a7c3e..f3ed46227bc2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-modal/osd-devices-selection-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-devices-selection-modal/osd-devices-selection-modal.component.ts @@ -1,4 +1,11 @@ -import { AfterViewInit, Component, EventEmitter, Output, ViewChild } from '@angular/core'; +import { + AfterViewInit, + ChangeDetectorRef, + Component, + EventEmitter, + Output, + ViewChild +} from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { TableColumnProp } from '@swimlane/ngx-datatable'; @@ -30,6 +37,7 @@ export class OsdDevicesSelectionModalComponent implements AfterViewInit { hostname: string; deviceType: string; + diskType: string; formGroup: CdFormGroup; action: string; @@ -42,6 +50,7 @@ export class OsdDevicesSelectionModalComponent implements AfterViewInit { constructor( private formBuilder: CdFormBuilder, + private cdRef: ChangeDetectorRef, public activeModal: NgbActiveModal, public actionLabels: ActionLabelsI18n, public wizardStepService: WizardStepsService @@ -83,6 +92,7 @@ export class OsdDevicesSelectionModalComponent implements AfterViewInit { this.capacity = _.sumBy(this.filteredDevices, 'sys_api.size'); this.event = event; } + this.cdRef.detectChanges(); } onSubmit() { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.html index 531bae257394..9711fe1a80d1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.html @@ -100,7 +100,8 @@ [availDevices]="availDevices" [canSelect]="dataDeviceSelectionGroups.devices.length !== 0" (selected)="onDevicesSelected($event)" - (cleared)="onDevicesCleared($event)"> + (cleared)="onDevicesCleared($event)" + [hostname]="hostname"> @@ -135,7 +136,8 @@ [availDevices]="availDevices" [canSelect]="dataDeviceSelectionGroups.devices.length !== 0" (selected)="onDevicesSelected($event)" - (cleared)="onDevicesCleared($event)"> + (cleared)="onDevicesCleared($event)" + [hostname]="hostname"> diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts index c2384425e701..e2085548f0f5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-form/osd-form.component.ts @@ -219,6 +219,7 @@ export class OsdFormComponent extends CdForm implements OnInit { onDevicesCleared(event: DevicesSelectionClearEvent) { if (event.type === 'data') { + this.hostname = ''; this.availDevices = [...this.allDevices]; this.walDeviceSelectionGroups.devices = []; this.dbDeviceSelectionGroups.devices = []; -- 2.47.3