]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Check Orchestrator availability for OSD actions
authorKiefer Chang <kiefer.chang@suse.com>
Mon, 23 Dec 2019 08:12:53 +0000 (16:12 +0800)
committerKiefer Chang <kiefer.chang@suse.com>
Wed, 11 Mar 2020 06:19:43 +0000 (14:19 +0800)
Check Orchestrator availability before creating/deleting OSDs.

Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts

index 183d67aad59847348a5da27c0f34e38480cef688..501943515e1a92f3fc453bbcd962a3621672c680 100644 (file)
@@ -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');
     });
index 79c6b8aea9764b14a84b2f31d88f85d7a0941fe4..5ed7567d72068d9b23aed640cdc94af7d7388fb6 100644 (file)
@@ -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
       }