From a6e77b598a3cd27337412327628b9961c59e91a2 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Wed, 13 Nov 2019 15:48:10 -0100 Subject: [PATCH] mgr/dashboard: Use new ImageSpec class This class should be used when dealing with RBD image specs. It allows the creation of an ImageSpec given the names of the pool, image and namespace. Alternatively you can also create one with an already existing image spec string. With it you keep the access to each individual component and can also convert it to a well formated string. Fixes: https://tracker.ceph.com/issues/42787 Signed-off-by: Tiago Melo --- .../frontend/e2e/block/images.e2e-spec.ts | 10 +- .../dashboard/frontend/e2e/block/images.po.ts | 4 +- .../frontend/e2e/pools/pools.e2e-spec.ts | 2 +- .../block/rbd-form/rbd-form.component.spec.ts | 7 +- .../ceph/block/rbd-form/rbd-form.component.ts | 67 ++++++-------- .../ceph/block/rbd-list/rbd-list.component.ts | 52 +++++------ .../rbd-snapshot-form.component.ts | 11 ++- .../rbd-snapshot-list.component.ts | 20 ++-- .../rbd-trash-list.component.ts | 13 ++- .../rbd-trash-move-modal.component.html | 2 +- .../rbd-trash-move-modal.component.spec.ts | 4 +- .../rbd-trash-move-modal.component.ts | 11 ++- .../rbd-trash-restore-modal.component.ts | 8 +- .../src/app/shared/api/rbd.service.spec.ts | 53 ++++++----- .../src/app/shared/api/rbd.service.ts | 91 +++++++------------ .../src/app/shared/models/image-spec.ts | 25 +++++ .../shared/services/task-message.service.ts | 16 ++-- 17 files changed, 197 insertions(+), 199 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/models/image-spec.ts diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts index f031a3ea72f..1d807e79017 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts @@ -37,8 +37,8 @@ describe('Images page', () => { describe('create, edit & delete image test', () => { const poolName = 'e2e_images_pool'; - const imageName = 'e2e_images_image'; - const newImageName = 'e2e_images_image_new'; + const imageName = 'e2e_images#image'; + const newImageName = 'e2e_images#image_new'; beforeAll(async () => { await pools.navigateTo('create'); // Need pool for image testing @@ -70,9 +70,9 @@ describe('Images page', () => { }); describe('move to trash, restore and purge image tests', () => { - const poolName = 'trashpool'; - const imageName = 'trashimage'; - const newImageName = 'newtrashimage'; + const poolName = 'trash_pool'; + const imageName = 'trash#image'; + const newImageName = 'newtrash#image'; beforeAll(async () => { await pools.navigateTo('create'); // Need pool for image testing diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts index 33b3661d49e..1d3dce13491 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts @@ -35,9 +35,9 @@ export class ImagesPageHelper extends PageHelper { async editImage(name, pool, newName, newSize) { const base_url = '/#/block/rbd/edit/'; const editURL = base_url - .concat(pool) + .concat(encodeURIComponent(pool)) .concat('%2F') - .concat(name); + .concat(encodeURIComponent(name)); await browser.get(editURL); await element(by.id('name')).click(); // click name box and send new name diff --git a/src/pybind/mgr/dashboard/frontend/e2e/pools/pools.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/e2e/pools/pools.e2e-spec.ts index 4b1712f44f1..7668dc2ccfa 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/pools/pools.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/pools/pools.e2e-spec.ts @@ -2,7 +2,7 @@ import { PoolPageHelper } from './pools.po'; describe('Pools page', () => { let pools: PoolPageHelper; - const poolName = 'pool_e2e_pool_test'; + const poolName = 'pool_e2e_pool/test'; beforeAll(async () => { pools = new PoolPageHelper(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts index 04635367646..e9d9e1f24a0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts @@ -14,6 +14,7 @@ import { delay } from 'rxjs/operators'; import { ActivatedRouteStub } from '../../../../testing/activated-route-stub'; import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper'; import { RbdService } from '../../../shared/api/rbd.service'; +import { ImageSpec } from '../../../shared/models/image-spec'; import { SharedModule } from '../../../shared/shared.module'; import { RbdConfigurationFormComponent } from '../rbd-configuration-form/rbd-configuration-form.component'; import { RbdFormMode } from './rbd-form-mode.enum'; @@ -181,20 +182,20 @@ describe('RbdFormComponent', () => { it('with namespace', () => { activatedRoute.setParams({ image_spec: 'foo%2Fbar%2Fbaz' }); - expect(rbdService.get).toHaveBeenCalledWith('foo', 'bar', 'baz'); + expect(rbdService.get).toHaveBeenCalledWith(new ImageSpec('foo', 'bar', 'baz')); }); it('without snapName', () => { activatedRoute.setParams({ image_spec: 'foo%2Fbar', snap: undefined }); - expect(rbdService.get).toHaveBeenCalledWith('foo', null, 'bar'); + expect(rbdService.get).toHaveBeenCalledWith(new ImageSpec('foo', null, 'bar')); expect(component.snapName).toBeUndefined(); }); it('with snapName', () => { activatedRoute.setParams({ image_spec: 'foo%2Fbar', snap: 'baz%2Fbaz' }); - expect(rbdService.get).toHaveBeenCalledWith('foo', null, 'bar'); + expect(rbdService.get).toHaveBeenCalledWith(new ImageSpec('foo', null, 'bar')); expect(component.snapName).toBe('baz/baz'); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts index 78a0a9f36b2..82dbe49bdd6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts @@ -18,6 +18,7 @@ import { RbdConfigurationSourceField } from '../../../shared/models/configuration'; import { FinishedTask } from '../../../shared/models/finished-task'; +import { ImageSpec } from '../../../shared/models/image-spec'; import { Permission } from '../../../shared/models/permissions'; import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @@ -235,13 +236,11 @@ export class RbdFormComponent implements OnInit { this.mode === this.rbdFormMode.copying ) { this.route.params.subscribe((params: { image_spec: string; snap: string }) => { - const [poolName, namespace, rbdName] = this.rbdService.parseImageSpec( - decodeURIComponent(params.image_spec) - ); + const imageSpec = ImageSpec.fromString(decodeURIComponent(params.image_spec)); if (params.snap) { this.snapName = decodeURIComponent(params.snap); } - promisses[Promisse.RbdServiceGet] = this.rbdService.get(poolName, namespace, rbdName); + promisses[Promisse.RbdServiceGet] = this.rbdService.get(imageSpec); }); } else { // New image @@ -496,11 +495,11 @@ export class RbdFormComponent implements OnInit { setResponse(response: RbdFormResponseModel, snapName: string) { this.response = response; - const imageSpec = this.rbdService.getImageSpec( + const imageSpec = new ImageSpec( response.pool_name, response.namespace, response.name - ); + ).toString(); if (this.mode === this.rbdFormMode.cloning) { this.rbdForm.get('parent').setValue(`${imageSpec}@${snapName}`); } else if (this.mode === this.rbdFormMode.copying) { @@ -618,44 +617,35 @@ export class RbdFormComponent implements OnInit { } editAction(): Observable { + const imageSpec = new ImageSpec( + this.response.pool_name, + this.response.namespace, + this.response.name + ); return this.taskWrapper.wrapTaskAroundCall({ task: new FinishedTask('rbd/edit', { - image_spec: this.rbdService.getImageSpec( - this.response.pool_name, - this.response.namespace, - this.response.name - ) + image_spec: imageSpec.toString() }), - call: this.rbdService.update( - this.response.pool_name, - this.response.namespace, - this.response.name, - this.editRequest() - ) + call: this.rbdService.update(imageSpec, this.editRequest()) }); } cloneAction(): Observable { const request = this.cloneRequest(); + const imageSpec = new ImageSpec( + this.response.pool_name, + this.response.namespace, + this.response.name + ); return this.taskWrapper.wrapTaskAroundCall({ task: new FinishedTask('rbd/clone', { - parent_image_spec: this.rbdService.get( - this.response.pool_name, - this.response.namespace, - this.response.name - ), + parent_image_spec: imageSpec.toString(), parent_snap_name: this.snapName, child_pool_name: request.child_pool_name, child_namespace: request.child_namespace, child_image_name: request.child_image_name }), - call: this.rbdService.cloneSnapshot( - this.response.pool_name, - this.response.namespace, - this.response.name, - this.snapName, - request - ) + call: this.rbdService.cloneSnapshot(imageSpec, this.snapName, request) }); } @@ -690,24 +680,19 @@ export class RbdFormComponent implements OnInit { copyAction(): Observable { const request = this.copyRequest(); - + const imageSpec = new ImageSpec( + this.response.pool_name, + this.response.namespace, + this.response.name + ); return this.taskWrapper.wrapTaskAroundCall({ task: new FinishedTask('rbd/copy', { - src_image_spec: this.rbdService.getImageSpec( - this.response.pool_name, - this.response.namespace, - this.response.name - ), + src_image_spec: imageSpec.toString(), dest_pool_name: request.dest_pool_name, dest_namespace: request.dest_namespace, dest_image_name: request.dest_image_name }), - call: this.rbdService.copy( - this.response.pool_name, - this.response.namespace, - this.response.name, - request - ) + call: this.rbdService.copy(imageSpec, request) }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts index 28a3a6e6688..b1101670924 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts @@ -16,6 +16,7 @@ import { CdTableAction } from '../../../shared/models/cd-table-action'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { FinishedTask } from '../../../shared/models/finished-task'; +import { ImageSpec } from '../../../shared/models/image-spec'; import { Permission } from '../../../shared/models/permissions'; import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; @@ -78,9 +79,9 @@ export class RbdListComponent implements OnInit { ) }; - private createRbdFromTaskImageSpec(imageSpec: string): RbdModel { - const [poolName, namespace, rbdName] = this.rbdService.parseImageSpec(imageSpec); - return this.createRbdFromTask(poolName, namespace, rbdName); + private createRbdFromTaskImageSpec(imageSpecStr: string): RbdModel { + const imageSpec = ImageSpec.fromString(imageSpecStr); + return this.createRbdFromTask(imageSpec.poolName, imageSpec.namespace, imageSpec.imageName); } private createRbdFromTask(pool: string, namespace: string, name: string): RbdModel { @@ -107,13 +108,11 @@ export class RbdListComponent implements OnInit { this.permission = this.authStorageService.getPermissions().rbdImage; const getImageUri = () => this.selection.first() && - `${encodeURIComponent( - this.rbdService.getImageSpec( - this.selection.first().pool_name, - this.selection.first().namespace, - this.selection.first().name - ) - )}`; + new ImageSpec( + this.selection.first().pool_name, + this.selection.first().namespace, + this.selection.first().name + ).toStringEncoded(); const addAction: CdTableAction = { permission: 'create', icon: Icons.add, @@ -231,32 +230,32 @@ export class RbdListComponent implements OnInit { let taskImageSpec: string; switch (task.name) { case 'rbd/copy': - taskImageSpec = this.rbdService.getImageSpec( + taskImageSpec = new ImageSpec( task.metadata['dest_pool_name'], task.metadata['dest_namespace'], task.metadata['dest_image_name'] - ); + ).toString(); break; case 'rbd/clone': - taskImageSpec = this.rbdService.getImageSpec( + taskImageSpec = new ImageSpec( task.metadata['child_pool_name'], task.metadata['child_namespace'], task.metadata['child_image_name'] - ); + ).toString(); break; case 'rbd/create': - taskImageSpec = this.rbdService.getImageSpec( + taskImageSpec = new ImageSpec( task.metadata['pool_name'], task.metadata['namespace'], task.metadata['image_name'] - ); + ).toString(); break; default: taskImageSpec = task.metadata['image_spec']; break; } return ( - taskImageSpec === this.rbdService.getImageSpec(entry.pool_name, entry.namespace, entry.name) + taskImageSpec === new ImageSpec(entry.pool_name, entry.namespace, entry.name).toString() ); }; @@ -321,7 +320,7 @@ export class RbdListComponent implements OnInit { const poolName = this.selection.first().pool_name; const namespace = this.selection.first().namespace; const imageName = this.selection.first().name; - const imageSpec = this.rbdService.getImageSpec(poolName, namespace, imageName); + const imageSpec = new ImageSpec(poolName, namespace, imageName); this.modalRef = this.modalService.show(CriticalConfirmationModalComponent, { initialState: { @@ -330,9 +329,9 @@ export class RbdListComponent implements OnInit { submitActionObservable: () => this.taskWrapper.wrapTaskAroundCall({ task: new FinishedTask('rbd/delete', { - image_spec: imageSpec + image_spec: imageSpec.toString() }), - call: this.rbdService.delete(poolName, namespace, imageName) + call: this.rbdService.delete(imageSpec) }) } }); @@ -348,13 +347,13 @@ export class RbdListComponent implements OnInit { this.modalRef = this.modalService.show(RbdTrashMoveModalComponent, { initialState }); } - flattenRbd(poolName, namespace, imageName) { + flattenRbd(imageSpec: ImageSpec) { this.taskWrapper .wrapTaskAroundCall({ task: new FinishedTask('rbd/flatten', { - image_spec: this.rbdService.getImageSpec(poolName, namespace, imageName) + image_spec: imageSpec.toString() }), - call: this.rbdService.flatten(poolName, namespace, imageName) + call: this.rbdService.flatten(imageSpec) }) .subscribe(undefined, undefined, () => { this.modalRef.hide(); @@ -366,11 +365,12 @@ export class RbdListComponent implements OnInit { const namespace = this.selection.first().namespace; const imageName = this.selection.first().name; const parent: RbdParentModel = this.selection.first().parent; - const parentImageSpec = this.rbdService.getImageSpec( + const parentImageSpec = new ImageSpec( parent.pool_name, parent.pool_namespace, parent.image_name ); + const childImageSpec = new ImageSpec(poolName, namespace, imageName); const initialState = { titleText: 'RBD flatten', @@ -378,10 +378,10 @@ export class RbdListComponent implements OnInit { bodyTpl: this.flattenTpl, bodyData: { parent: `${parentImageSpec}@${parent.snap_name}`, - child: this.rbdService.getImageSpec(poolName, namespace, imageName) + child: childImageSpec.toString() }, onSubmit: () => { - this.flattenRbd(poolName, namespace, imageName); + this.flattenRbd(childImageSpec); } }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts index 2cb712b6aeb..8b267a18739 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts @@ -9,6 +9,7 @@ import { RbdService } from '../../../shared/api/rbd.service'; import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { CdFormGroup } from '../../../shared/forms/cd-form-group'; import { FinishedTask } from '../../../shared/models/finished-task'; +import { ImageSpec } from '../../../shared/models/image-spec'; import { NotificationService } from '../../../shared/services/notification.service'; import { TaskManagerService } from '../../../shared/services/task-manager.service'; @@ -73,14 +74,15 @@ export class RbdSnapshotFormComponent implements OnInit { editAction() { const snapshotName = this.snapshotForm.getValue('snapshotName'); + const imageSpec = new ImageSpec(this.poolName, this.namespace, this.imageName); const finishedTask = new FinishedTask(); finishedTask.name = 'rbd/snap/edit'; finishedTask.metadata = { - image_spec: this.rbdService.getImageSpec(this.poolName, this.namespace, this.imageName), + image_spec: imageSpec.toString(), snapshot_name: snapshotName }; this.rbdService - .renameSnapshot(this.poolName, this.namespace, this.imageName, this.snapName, snapshotName) + .renameSnapshot(imageSpec, this.snapName, snapshotName) .toPromise() .then(() => { this.taskManagerService.subscribe( @@ -100,14 +102,15 @@ export class RbdSnapshotFormComponent implements OnInit { createAction() { const snapshotName = this.snapshotForm.getValue('snapshotName'); + const imageSpec = new ImageSpec(this.poolName, this.namespace, this.imageName); const finishedTask = new FinishedTask(); finishedTask.name = 'rbd/snap/create'; finishedTask.metadata = { - image_spec: this.rbdService.getImageSpec(this.poolName, this.namespace, this.imageName), + image_spec: imageSpec.toString(), snapshot_name: snapshotName }; this.rbdService - .createSnapshot(this.poolName, this.namespace, this.imageName, snapshotName) + .createSnapshot(imageSpec, snapshotName) .toPromise() .then(() => { this.taskManagerService.subscribe( diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts index 96a14ee2f6b..225354329cb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts @@ -15,6 +15,7 @@ import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { ExecutingTask } from '../../../shared/models/executing-task'; import { FinishedTask } from '../../../shared/models/finished-task'; +import { ImageSpec } from '../../../shared/models/image-spec'; import { Permission } from '../../../shared/models/permissions'; import { CdDatePipe } from '../../../shared/pipes/cd-date.pipe'; import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; @@ -124,6 +125,8 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { } ngOnChanges() { + const imageSpec = new ImageSpec(this.poolName, this.namespace, this.rbdName); + const actions = new RbdSnapshotActionsModel(this.i18n, this.actionLabels, this.featuresName); actions.create.click = () => this.openCreateSnapshotModal(); actions.rename.click = () => this.openEditSnapshotModal(); @@ -131,9 +134,7 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { actions.unprotect.click = () => this.toggleProtection(); const getImageUri = () => this.selection.first() && - `${encodeURIComponent( - this.rbdService.getImageSpec(this.poolName, this.namespace, this.rbdName) - )}/${encodeURIComponent(this.selection.first().name)}`; + `${imageSpec.toStringEncoded()}/${encodeURIComponent(this.selection.first().name)}`; actions.clone.routerLink = () => `/block/rbd/clone/${getImageUri()}`; actions.copy.routerLink = () => `/block/rbd/copy/${getImageUri()}`; actions.rollback.click = () => this.rollbackModal(); @@ -148,9 +149,7 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { return ( ['rbd/snap/create', 'rbd/snap/delete', 'rbd/snap/edit', 'rbd/snap/rollback'].includes( task.name - ) && - this.rbdService.getImageSpec(this.poolName, this.namespace, this.rbdName) === - task.metadata['image_spec'] + ) && imageSpec.toString() === task.metadata['image_spec'] ); }; @@ -204,12 +203,13 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { const isProtected = this.selection.first().is_protected; const finishedTask = new FinishedTask(); finishedTask.name = 'rbd/snap/edit'; + const imageSpec = new ImageSpec(this.poolName, this.namespace, this.rbdName); finishedTask.metadata = { - image_spec: this.rbdService.getImageSpec(this.poolName, this.namespace, this.rbdName), + image_spec: imageSpec.toString(), snapshot_name: snapshotName }; this.rbdService - .protectSnapshot(this.poolName, this.namespace, this.rbdName, snapshotName, !isProtected) + .protectSnapshot(imageSpec, snapshotName, !isProtected) .toPromise() .then(() => { const executingTask = new ExecutingTask(); @@ -231,7 +231,7 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { const finishedTask = new FinishedTask(); finishedTask.name = taskName; finishedTask.metadata = { - image_spec: this.rbdService.getImageSpec(this.poolName, this.namespace, this.rbdName), + image_spec: new ImageSpec(this.poolName, this.namespace, this.rbdName).toString(), snapshot_name: snapshotName }; this.rbdService[task](this.poolName, this.namespace, this.rbdName, snapshotName) @@ -258,7 +258,7 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { rollbackModal() { const snapshotName = this.selection.selected[0].name; - const imageSpec = this.rbdService.getImageSpec(this.poolName, this.namespace, this.rbdName); + const imageSpec = new ImageSpec(this.poolName, this.namespace, this.rbdName).toString(); const initialState = { titleText: this.i18n('RBD snapshot rollback'), buttonText: this.i18n('Rollback'), diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts index 7f3d9ea705c..811a2145d49 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts @@ -17,6 +17,7 @@ import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { ExecutingTask } from '../../../shared/models/executing-task'; import { FinishedTask } from '../../../shared/models/finished-task'; +import { ImageSpec } from '../../../shared/models/image-spec'; import { Permission } from '../../../shared/models/permissions'; import { CdDatePipe } from '../../../shared/pipes/cd-date.pipe'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @@ -115,10 +116,8 @@ export class RbdTrashListComponent implements OnInit { ]; const itemFilter = (entry, task) => { - return ( - this.rbdService.getImageSpec(entry.pool_name, entry.namespace, entry.id) === - task.metadata['image_id_spec'] - ); + const imageSpec = new ImageSpec(entry.pool_name, entry.namespace, entry.id); + return imageSpec.toString() === task.metadata['image_id_spec']; }; const taskFilter = (task) => { @@ -191,7 +190,7 @@ export class RbdTrashListComponent implements OnInit { const namespace = this.selection.first().namespace; const imageId = this.selection.first().id; const expiresAt = this.selection.first().deferment_end_time; - const imageIdSpec = this.rbdService.getImageSpec(poolName, namespace, imageId); + const imageIdSpec = new ImageSpec(poolName, namespace, imageId); this.modalRef = this.modalService.show(CriticalConfirmationModalComponent, { initialState: { @@ -202,9 +201,9 @@ export class RbdTrashListComponent implements OnInit { submitActionObservable: () => this.taskWrapper.wrapTaskAroundCall({ task: new FinishedTask('rbd/trash/remove', { - image_id_spec: imageIdSpec + image_id_spec: imageIdSpec.toString() }), - call: this.rbdService.removeTrash(poolName, namespace, imageId, true) + call: this.rbdService.removeTrash(imageIdSpec, true) }) } }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.html index 06d913bc3c6..63386ae0b47 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.html @@ -9,7 +9,7 @@ [formGroup]="moveForm" novalidate>