From: Afreen Misbah Date: Thu, 15 May 2025 16:10:21 +0000 (+0530) Subject: mgr/dashboard: adapt service creation form to support nvmeof creation X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F63304%2Fhead;p=ceph.git mgr/dashboard: adapt service creation form to support nvmeof creation Fixes https://tracker.ceph.com/issues/71340 - nvmeof form failing due to absence of pool field in req - backport of https://github.com/ceph/ceph/pull/57801 Signed-off-by: Afreen Misbah --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html index b95f9353db352..fa01d95d36162 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html @@ -277,9 +277,10 @@ +
+ *ngIf="serviceForm.controls.service_type.value === 'iscsi' || serviceForm.controls.service_type.value === 'nvmeof'"> diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.spec.ts index ebecec5cc3854..c73b6208deef8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.spec.ts @@ -297,6 +297,27 @@ x4Ea7kGVgx9kWh5XjWz9wjZvY49UKIT5ppIAWPMbLl3UpfckiuNhTA== }); }); + describe('should test service nvmeof', () => { + beforeEach(() => { + formHelper.setValue('service_type', 'nvmeof'); + formHelper.setValue('pool', 'xyz'); + }); + + it('should submit iscsi', () => { + component.onSubmit(); + expect(cephServiceService.create).toHaveBeenCalledWith({ + service_type: 'nvmeof', + placement: {}, + unmanaged: false, + pool: 'xyz' + }); + }); + + it('should throw error when there is no pool', () => { + formHelper.expectErrorChange('pool', '', 'required'); + }); + }); + describe('should test service iscsi', () => { beforeEach(() => { formHelper.setValue('service_type', 'iscsi'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts index d6eea1711ffc7..1faf1aa611b28 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts @@ -142,6 +142,9 @@ export class ServiceFormComponent extends CdForm implements OnInit { CdValidators.requiredIf({ service_type: 'iscsi' }), + CdValidators.requiredIf({ + service_type: 'nvmeof' + }), CdValidators.requiredIf({ service_type: 'ingress' }), @@ -170,11 +173,15 @@ export class ServiceFormComponent extends CdForm implements OnInit { count: [null, [CdValidators.number(false)]], unmanaged: [false], // iSCSI + // NVMe/TCP pool: [ null, [ CdValidators.requiredIf({ service_type: 'iscsi' + }), + CdValidators.requiredIf({ + service_type: 'nvmeof' }) ] ], @@ -748,6 +755,7 @@ export class ServiceFormComponent extends CdForm implements OnInit { break; case 'iscsi': + case 'nvmeof': serviceSpec['pool'] = values['pool']; break;