]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: rbd image primary ui
authorPedro Gonzalez Gomez <pegonzal@localhost.localdomain>
Fri, 3 Jun 2022 10:13:44 +0000 (12:13 +0200)
committerPere Diaz Bou <pdiazbou@redhat.com>
Thu, 30 Jun 2022 14:56:37 +0000 (16:56 +0200)
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/constants/app.constants.ts

index 6d1f8c7d3c9fd561eddae9041b3a5ee296aa5d95..8b994d958a7246dbfcd67af3ab9da1203d7efd45 100644 (file)
@@ -8,6 +8,7 @@ export class RbdFormEditRequestModel {
 
   enable_mirror?: boolean;
   mirror_mode?: string;
+  primary?: boolean;
   schedule_interval: string;
   remove_scheduling? = false;
 }
index 824e05f8034f3df7db15664475bc8fbe4164e9df..0f68f2df252cfe7c20462028a8cf095a55e14ea2 100644 (file)
 </ng-template>
 
 <ng-template #mirroringTpl
-             let-value="value">
+             let-value="value"
+             let-row="row">
   <span *ngIf="value.length === 3; else probb"
         class="badge badge-info">{{ value[0] }}</span>&nbsp;
   <span *ngIf="value.length === 3"
         class="badge badge-info"
         [ngbTooltip]="'Next scheduled snapshot on' + ' ' + (value[2] | cdDate)">{{ value[1] }}</span>
+  <span *ngIf="row.primary === true"
+        class="badge badge-info"
+        i18n>primary</span>
+  <span *ngIf="row.primary === false"
+        class="badge badge-info"
+        i18n>secondary</span>
   <ng-template #probb>
     <span class="badge badge-info">{{ value }}</span>
   </ng-template>
index c6dde029233d649abf63adc1aa5b5ef509b656b3..f192d25e6f79385635836fbb1b9697914fa1bb47 100644 (file)
@@ -322,12 +322,23 @@ describe('RbdListComponent', () => {
           'Resync',
           'Delete',
           'Move to Trash',
-          'Remove Scheduling'
+          'Remove Scheduling',
+          'Promote',
+          'Demote'
         ],
         primary: { multiple: 'Create', executing: 'Edit', single: 'Edit', no: 'Create' }
       },
       'create,update': {
-        actions: ['Create', 'Edit', 'Copy', 'Flatten', 'Resync', 'Remove Scheduling'],
+        actions: [
+          'Create',
+          'Edit',
+          'Copy',
+          'Flatten',
+          'Resync',
+          'Remove Scheduling',
+          'Promote',
+          'Demote'
+        ],
         primary: { multiple: 'Create', executing: 'Edit', single: 'Edit', no: 'Create' }
       },
       'create,delete': {
@@ -339,11 +350,20 @@ describe('RbdListComponent', () => {
         primary: { multiple: 'Create', executing: 'Copy', single: 'Copy', no: 'Create' }
       },
       'update,delete': {
-        actions: ['Edit', 'Flatten', 'Resync', 'Delete', 'Move to Trash', 'Remove Scheduling'],
+        actions: [
+          'Edit',
+          'Flatten',
+          'Resync',
+          'Delete',
+          'Move to Trash',
+          'Remove Scheduling',
+          'Promote',
+          'Demote'
+        ],
         primary: { multiple: 'Edit', executing: 'Edit', single: 'Edit', no: 'Edit' }
       },
       update: {
-        actions: ['Edit', 'Flatten', 'Resync', 'Remove Scheduling'],
+        actions: ['Edit', 'Flatten', 'Resync', 'Remove Scheduling', 'Promote', 'Demote'],
         primary: { multiple: 'Edit', executing: 'Edit', single: 'Edit', no: 'Edit' }
       },
       delete: {
index 215f7f6f874ac8f29e9f3f96b7a57ad229900a50..86819762164fcee1968f37989f24dcda0aa05abf 100644 (file)
@@ -202,6 +202,20 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
         this.getInvalidNameDisable(selection) ||
         selection.first().schedule_info === undefined
     };
+    const promoteAction: CdTableAction = {
+      permission: 'update',
+      icon: Icons.edit,
+      click: () => this.actionPrimary(true),
+      name: this.actionLabels.PROMOTE,
+      visible: () => this.selection.first() != null && !this.selection.first().primary
+    };
+    const demoteAction: CdTableAction = {
+      permission: 'update',
+      icon: Icons.edit,
+      click: () => this.actionPrimary(false),
+      name: this.actionLabels.DEMOTE,
+      visible: () => this.selection.first() != null && this.selection.first().primary
+    };
     this.tableActions = [
       addAction,
       editAction,
@@ -210,7 +224,9 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
       resyncAction,
       deleteAction,
       moveAction,
-      removeSchedulingAction
+      removeSchedulingAction,
+      promoteAction,
+      demoteAction
     ];
   }
 
@@ -530,6 +546,24 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
     });
   }
 
+  actionPrimary(primary: boolean) {
+    const request = new RbdFormEditRequestModel();
+    request.primary = primary;
+    const imageSpec = new ImageSpec(
+      this.selection.first().pool_name,
+      this.selection.first().namespace,
+      this.selection.first().name
+    );
+    this.taskWrapper
+      .wrapTaskAroundCall({
+        task: new FinishedTask('rbd/edit', {
+          image_spec: imageSpec.toString()
+        }),
+        call: this.rbdService.update(imageSpec, request)
+      })
+      .subscribe();
+  }
+
   hasSnapshots() {
     const snapshots = this.selection.first()['snapshots'] || [];
     return snapshots.length > 0;
index d78620a89b2d7c2294d8b7bf4671144a22dbdbc5..4248be8f59c20121fec34d7f3f341f9f6754e113 100644 (file)
@@ -128,6 +128,8 @@ export class ActionLabelsI18n {
   ENTER_MAINTENANCE: string;
   EXIT_MAINTENANCE: string;
   REMOVE_SCHEDULING: string;
+  PROMOTE: string;
+  DEMOTE: string;
   START_DRAIN: string;
   STOP_DRAIN: string;
   START: string;
@@ -202,6 +204,8 @@ export class ActionLabelsI18n {
     this.RESTART = $localize`Restart`;
 
     this.REMOVE_SCHEDULING = $localize`Remove Scheduling`;
+    this.PROMOTE = $localize`Promote`;
+    this.DEMOTE = $localize`Demote`;
   }
 }