From: Kiefer Chang Date: Mon, 23 Dec 2019 08:12:53 +0000 (+0800) Subject: mgr/dashboard: Check Orchestrator availability for OSD actions X-Git-Tag: v15.1.1~14^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3867cbd8c7a12dfbfb380094a534b9007dfbf451;p=ceph.git mgr/dashboard: Check Orchestrator availability for OSD actions Check Orchestrator availability before creating/deleting OSDs. Signed-off-by: Kiefer Chang --- 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 183d67aad598..501943515e1a 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 @@ -16,6 +16,7 @@ import { PermissionHelper } from '../../../../../testing/unit-test-helper'; import { CoreModule } from '../../../../core/core.module'; +import { OrchestratorService } from '../../../../shared/api/orchestrator.service'; import { OsdService } from '../../../../shared/api/osd.service'; import { ConfirmationModalComponent } from '../../../../shared/components/confirmation-modal/confirmation-modal.component'; import { CriticalConfirmationModalComponent } from '../../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component'; @@ -82,6 +83,10 @@ describe('OsdListComponent', () => { ); }; + const mockOrchestratorStatus = () => { + spyOn(TestBed.get(OrchestratorService), 'status').and.callFake(() => of({ available: true })); + }; + configureTestBed({ imports: [ HttpClientTestingModule, @@ -395,6 +400,7 @@ describe('OsdListComponent', () => { expectOpensModal('Mark Lost', modalClass); expectOpensModal('Purge', modalClass); expectOpensModal('Destroy', modalClass); + mockOrchestratorStatus(); mockSafeToDelete(); expectOpensModal('Delete', modalClass); }); @@ -437,6 +443,7 @@ describe('OsdListComponent', () => { expectOsdServiceMethodCalled('Mark Lost', 'markLost'); expectOsdServiceMethodCalled('Purge', 'purge'); expectOsdServiceMethodCalled('Destroy', 'destroy'); + mockOrchestratorStatus(); mockSafeToDelete(); expectOsdServiceMethodCalled('Delete', 'delete'); }); 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 79c6b8aea976..5ed7567d7206 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 @@ -1,4 +1,5 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; +import { Router } from '@angular/router'; import { I18n } from '@ngx-translate/i18n-polyfill'; import * as _ from 'lodash'; @@ -20,6 +21,7 @@ import { CdTableSelection } from '../../../../shared/models/cd-table-selection'; import { Permissions } from '../../../../shared/models/permissions'; import { DimlessBinaryPipe } from '../../../../shared/pipes/dimless-binary.pipe'; import { AuthStorageService } from '../../../../shared/services/auth-storage.service'; +import { DepCheckerService } from '../../../../shared/services/dep-checker.service'; import { NotificationService } from '../../../../shared/services/notification.service'; import { URLBuilderService } from '../../../../shared/services/url-builder.service'; import { OsdFlagsModalComponent } from '../osd-flags-modal/osd-flags-modal.component'; @@ -79,6 +81,8 @@ export class OsdListComponent implements OnInit { private modalService: BsModalService, private i18n: I18n, private urlBuilder: URLBuilderService, + private router: Router, + private depCheckerService: DepCheckerService, public actionLabels: ActionLabelsI18n, public notificationService: NotificationService ) { @@ -88,7 +92,15 @@ export class OsdListComponent implements OnInit { name: this.actionLabels.CREATE, permission: 'create', icon: Icons.add, - routerLink: () => this.urlBuilder.getCreate(), + click: () => { + this.depCheckerService.checkOrchestratorOrModal( + this.actionLabels.CREATE, + this.i18n('OSD'), + () => { + this.router.navigate([this.urlBuilder.getCreate()]); + } + ); + }, canBePrimary: (selection: CdTableSelection) => !selection.hasSelection }, { @@ -200,20 +212,27 @@ export class OsdListComponent implements OnInit { { name: this.actionLabels.DELETE, permission: 'delete', - click: () => - this.showCriticalConfirmationModal( - this.i18n('delete'), + click: () => { + this.depCheckerService.checkOrchestratorOrModal( + this.actionLabels.DELETE, this.i18n('OSD'), - this.i18n('deleted'), - (ids: number[]) => { - return this.osdService.safeToDelete(JSON.stringify(ids)); - }, - 'is_safe_to_delete', - (id: number) => { - this.selection = new CdTableSelection(); - return this.osdService.delete(id, true); + () => { + this.showCriticalConfirmationModal( + this.i18n('delete'), + this.i18n('OSD'), + this.i18n('deleted'), + (ids: number[]) => { + return this.osdService.safeToDelete(JSON.stringify(ids)); + }, + 'is_safe_to_delete', + (id: number) => { + this.selection = new CdTableSelection(); + return this.osdService.delete(id, true); + } + ); } - ), + ); + }, disable: () => !this.hasOsdSelected, icon: Icons.destroy }