]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts
import 15.2.9
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / osd / osd-list / osd-list.component.ts
index 1deb200343415f74e81540b39aba017e9c5029f1..0b7d4f9cad85d908f9b1f7d4f31208743e77a4aa 100644 (file)
@@ -29,6 +29,7 @@ import { DepCheckerService } from '../../../../shared/services/dep-checker.servi
 import { NotificationService } from '../../../../shared/services/notification.service';
 import { TaskWrapperService } from '../../../../shared/services/task-wrapper.service';
 import { URLBuilderService } from '../../../../shared/services/url-builder.service';
+import { OsdFlagsIndivModalComponent } from '../osd-flags-indiv-modal/osd-flags-indiv-modal.component';
 import { OsdFlagsModalComponent } from '../osd-flags-modal/osd-flags-modal.component';
 import { OsdPgScrubModalComponent } from '../osd-pg-scrub-modal/osd-pg-scrub-modal.component';
 import { OsdRecvSpeedModalComponent } from '../osd-recv-speed-modal/osd-recv-speed-modal.component';
@@ -58,6 +59,8 @@ export class OsdListComponent extends ListWithDetails implements OnInit {
   safeToDestroyBodyTpl: TemplateRef<any>;
   @ViewChild('deleteOsdExtraTpl', { static: false })
   deleteOsdExtraTpl: TemplateRef<any>;
+  @ViewChild('flagsTpl', { static: true })
+  flagsTpl: TemplateRef<any>;
 
   permissions: Permissions;
   tableActions: CdTableAction[];
@@ -68,6 +71,13 @@ export class OsdListComponent extends ListWithDetails implements OnInit {
 
   selection = new CdTableSelection();
   osds: any[] = [];
+  disabledFlags: string[] = [
+    'sortbitwise',
+    'purged_snapdirs',
+    'recovery_deletes',
+    'pglog_hardlimit'
+  ];
+  indivFlagNames: string[] = ['noup', 'nodown', 'noin', 'noout'];
 
   protected static collectStates(osd: any) {
     const states = [osd['in'] ? 'in' : 'out'];
@@ -118,6 +128,13 @@ export class OsdListComponent extends ListWithDetails implements OnInit {
         icon: Icons.edit,
         click: () => this.editAction()
       },
+      {
+        name: this.actionLabels.FLAGS,
+        permission: 'update',
+        icon: Icons.flag,
+        click: () => this.configureFlagsIndivAction(),
+        disable: () => !this.hasOsdSelected
+      },
       {
         name: this.actionLabels.SCRUB,
         permission: 'update',
@@ -293,6 +310,11 @@ export class OsdListComponent extends ListWithDetails implements OnInit {
         flexGrow: 1,
         pipe: this.dimlessBinaryPipe
       },
+      {
+        prop: 'state',
+        name: this.i18n(`Flags`),
+        cellTemplate: this.flagsTpl
+      },
       { prop: 'stats.usage', name: this.i18n('Usage'), cellTemplate: this.osdUsageTpl },
       {
         prop: 'stats_history.out_bytes',
@@ -362,13 +384,16 @@ export class OsdListComponent extends ListWithDetails implements OnInit {
   }
 
   getOsdList() {
-    this.osdService.getList().subscribe((data: any[]) => {
-      this.osds = data.map((osd) => {
+    const observables = [this.osdService.getList(), this.osdService.getFlags()];
+    observableForkJoin(observables).subscribe((resp: [any[], string[]]) => {
+      this.osds = resp[0].map((osd) => {
         osd.collectedStates = OsdListComponent.collectStates(osd);
         osd.stats_history.out_bytes = osd.stats_history.op_out_bytes.map((i: string) => i[1]);
         osd.stats_history.in_bytes = osd.stats_history.op_in_bytes.map((i: string) => i[1]);
         osd.stats.usage = osd.stats.stat_bytes_used / osd.stats.stat_bytes;
         osd.cdIsBinary = true;
+        osd.cdIndivFlags = osd.state.filter((f: string) => this.indivFlagNames.includes(f));
+        osd.cdClusterFlags = resp[1].filter((f: string) => !this.disabledFlags.includes(f));
         return osd;
       });
     });
@@ -424,6 +449,13 @@ export class OsdListComponent extends ListWithDetails implements OnInit {
     this.bsModalRef = this.modalService.show(OsdFlagsModalComponent, {});
   }
 
+  configureFlagsIndivAction() {
+    const initialState = {
+      selected: this.getSelectedOsds()
+    };
+    this.bsModalRef = this.modalService.show(OsdFlagsIndivModalComponent, { initialState });
+  }
+
   showConfirmationModal(markAction: string, onSubmit: (id: number) => Observable<any>) {
     this.bsModalRef = this.modalService.show(ConfirmationModalComponent, {
       initialState: {