mgr/dashboard: rbd force resync from fornt-end

Signed-off-by: Sarthak0702 <sarthak.dev.0702@gmail.com>
This commit is contained in:
Sarthak0702 2022-06-03 04:28:31 +05:30
parent ca1547c3d8
commit 87230dbe42
2 changed files with 43 additions and 1 deletions

View File

@ -153,6 +153,13 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
name: this.actionLabels.DELETE,
disable: (selection: CdTableSelection) => this.getDeleteDisableDesc(selection)
};
const resyncAction: CdTableAction = {
permission: 'update',
icon: Icons.refresh,
click: () => this.resyncRbdModal(),
name: this.actionLabels.RESYNC,
disable: (selection: CdTableSelection) => this.getResyncDisableDesc(selection)
};
const copyAction: CdTableAction = {
permission: 'create',
canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
@ -200,6 +207,7 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
editAction,
copyAction,
flattenAction,
resyncAction,
deleteAction,
moveAction,
removeSchedulingAction
@ -411,6 +419,26 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
});
}
resyncRbdModal() {
const poolName = this.selection.first().pool_name;
const namespace = this.selection.first().namespace;
const imageName = this.selection.first().name;
const imageSpec = new ImageSpec(poolName, namespace, imageName);
this.modalRef = this.modalService.show(CriticalConfirmationModalComponent, {
itemDescription: 'RBD',
itemNames: [imageSpec],
actionDescription: 'resync',
submitActionObservable: () =>
this.taskWrapper.wrapTaskAroundCall({
task: new FinishedTask('rbd/edit', {
image_spec: imageSpec.toString()
}),
call: this.rbdService.update(imageSpec, { resync: true })
})
});
}
trashRbdModal() {
const initialState = {
poolName: this.selection.first().pool_name,
@ -533,6 +561,19 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
return this.getInvalidNameDisable(selection) || this.hasClonedSnapshots(selection.first());
}
getResyncDisableDesc(selection: CdTableSelection): string | boolean {
const first = selection.first();
if (first && this.imageIsPrimary(first)) {
return $localize`Primary RBD cannot be resynced`;
}
return this.getInvalidNameDisable(selection);
}
imageIsPrimary(image: object) {
return image['primary'];
}
getInvalidNameDisable(selection: CdTableSelection): string | boolean {
const first = selection.first();

View File

@ -134,6 +134,7 @@ export class ActionLabelsI18n {
STOP: string;
REDEPLOY: string;
RESTART: string;
RESYNC: string;
constructor() {
/* Create a new item */
@ -190,7 +191,7 @@ export class ActionLabelsI18n {
this.START_DRAIN = $localize`Start Drain`;
this.STOP_DRAIN = $localize`Stop Drain`;
this.RESYNC = $localize`Resync`;
/* Prometheus wording */
this.RECREATE = $localize`Recreate`;
this.EXPIRE = $localize`Expire`;