Skip to content

Commit bf78b9d

Browse files
authored
Merge pull request ceph#56055 from rhcs-dashboard/add-nfsv3-support
mgr/dashboard: add support for NFSv3 exports Reviewed-by: afreen23 <NOT@FOUND> Reviewed-by: Ankush Behl <[email protected]>
2 parents 9555086 + 2a95bc7 commit bf78b9d

File tree

3 files changed

+69
-11
lines changed

3 files changed

+69
-11
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,26 +213,37 @@
213213
for="protocols"
214214
i18n>NFS Protocol</label>
215215
<div class="cd-col-form-input">
216+
<div class="custom-control custom-checkbox">
217+
<input type="checkbox"
218+
class="custom-control-input"
219+
formControlName="protocolNfsv3"
220+
name="protocolNfsv3"
221+
id="protocolNfsv3">
222+
<label for="protocolNfsv3"
223+
class="custom-control-label"
224+
i18n>NFSv3</label>
225+
</div>
216226
<div class="custom-control custom-checkbox">
217227
<input type="checkbox"
218228
class="custom-control-input"
219229
formControlName="protocolNfsv4"
220230
name="protocolNfsv4"
221-
id="protocolNfsv4"
222-
disabled>
223-
<label i18n
231+
id="protocolNfsv4">
232+
<label for="protocolNfsv4"
224233
class="custom-control-label"
225-
for="protocolNfsv4">NFSv4</label>
234+
i18n>NFSv4</label>
226235
</div>
227236
<span class="invalid-feedback"
228-
*ngIf="nfsForm.showError('protocolNfsv4', formDir, 'required')"
237+
*ngIf="nfsForm.showError('protocolNfsv3', formDir, 'required') ||
238+
nfsForm.showError('protocolNfsv4', formDir, 'required')"
229239
i18n>This field is required.</span>
240+
<hr>
230241
</div>
231242
</div>
232243

233244
<!-- Pseudo -->
234245
<div class="form-group row"
235-
*ngIf="nfsForm.getValue('protocolNfsv4')">
246+
*ngIf="nfsForm.getValue('protocolNfsv4') || nfsForm.getValue('protocolNfsv3')">
236247
<label class="cd-col-form-label"
237248
for="pseudo">
238249
<span class="required"

src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ describe('NfsFormComponent', () => {
9999
fsal: { fs_name: 'a', name: 'CEPH' },
100100
path: '/',
101101
protocolNfsv4: true,
102+
protocolNfsv3: true,
102103
pseudo: '',
103104
sec_label_xattr: 'security.selinux',
104105
security_label: false,
@@ -121,8 +122,9 @@ describe('NfsFormComponent', () => {
121122
expect(component.nfsForm.get('cluster_id').disabled).toBeTruthy();
122123
});
123124

124-
it('should mark NFSv4 protocol as enabled always', () => {
125+
it('should mark NFSv4 & NFSv3 protocols as enabled always', () => {
125126
expect(component.nfsForm.get('protocolNfsv4')).toBeTruthy();
127+
expect(component.nfsForm.get('protocolNfsv3')).toBeTruthy();
126128
});
127129

128130
it('should match backend squash values with ui values', () => {
@@ -142,6 +144,7 @@ describe('NfsFormComponent', () => {
142144
fsal: { name: 'CEPH', fs_name: 1 },
143145
path: '/foo',
144146
protocolNfsv4: true,
147+
protocolNfsv3: true,
145148
pseudo: '/baz',
146149
squash: 'no_root_squash',
147150
transportTCP: true,
@@ -157,6 +160,31 @@ describe('NfsFormComponent', () => {
157160
component.nfsForm.patchValue({ export_id: 1 });
158161
component.submitAction();
159162

163+
const req = httpTesting.expectOne('api/nfs-ganesha/export/cluster1/1');
164+
expect(req.request.method).toBe('PUT');
165+
expect(req.request.body).toEqual({
166+
access_type: 'RW',
167+
clients: [],
168+
cluster_id: 'cluster1',
169+
export_id: 1,
170+
fsal: { fs_name: 1, name: 'CEPH', sec_label_xattr: null },
171+
path: '/foo',
172+
protocols: [3, 4],
173+
pseudo: '/baz',
174+
security_label: false,
175+
squash: 'no_root_squash',
176+
transports: ['TCP', 'UDP']
177+
});
178+
});
179+
180+
it('should call update with selected nfs protocol', () => {
181+
activatedRoute.setParams({ cluster_id: 'cluster1', export_id: '1' });
182+
component.isEdit = true;
183+
component.cluster_id = 'cluster1';
184+
component.export_id = '1';
185+
component.nfsForm.patchValue({ export_id: 1, protocolNfsv3: false });
186+
component.submitAction();
187+
160188
const req = httpTesting.expectOne('api/nfs-ganesha/export/cluster1/1');
161189
expect(req.request.method).toBe('PUT');
162190
expect(req.request.body).toEqual({
@@ -190,7 +218,7 @@ describe('NfsFormComponent', () => {
190218
sec_label_xattr: null
191219
},
192220
path: '/foo',
193-
protocols: [4],
221+
protocols: [3, 4],
194222
pseudo: '/baz',
195223
security_label: false,
196224
squash: 'no_root_squash',

src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,23 @@ export class NfsFormComponent extends CdForm implements OnInit {
156156
})
157157
}),
158158
path: new UntypedFormControl('/'),
159-
protocolNfsv4: new UntypedFormControl(true),
159+
protocolNfsv3: new UntypedFormControl(true, {
160+
validators: [
161+
CdValidators.requiredIf({ protocolNfsv4: false }, (value: boolean) => {
162+
return !value;
163+
})
164+
]
165+
}),
166+
protocolNfsv4: new UntypedFormControl(true, {
167+
validators: [
168+
CdValidators.requiredIf({ protocolNfsv3: false }, (value: boolean) => {
169+
return !value;
170+
})
171+
]
172+
}),
160173
pseudo: new UntypedFormControl('', {
161174
validators: [
162-
CdValidators.requiredIf({ protocolNfsv4: true }),
175+
CdValidators.requiredIf({ protocolNfsv4: true, protocolNfsv3: true }),
163176
Validators.pattern('^/[^><|&()]*$')
164177
]
165178
}),
@@ -194,6 +207,7 @@ export class NfsFormComponent extends CdForm implements OnInit {
194207
}
195208

196209
res.protocolNfsv4 = res.protocols.indexOf(4) !== -1;
210+
res.protocolNfsv3 = res.protocols.indexOf(3) !== -1;
197211
delete res.protocols;
198212

199213
res.transportTCP = res.transports.indexOf('TCP') !== -1;
@@ -471,11 +485,16 @@ export class NfsFormComponent extends CdForm implements OnInit {
471485
}
472486

473487
requestModel.protocols = [];
488+
if (requestModel.protocolNfsv3) {
489+
requestModel.protocols.push(3);
490+
}
474491
if (requestModel.protocolNfsv4) {
475492
requestModel.protocols.push(4);
476-
} else {
493+
}
494+
if (!requestModel.protocolNfsv3 && !requestModel.protocolNfsv4) {
477495
requestModel.pseudo = null;
478496
}
497+
delete requestModel.protocolNfsv3;
479498
delete requestModel.protocolNfsv4;
480499

481500
requestModel.transports = [];

0 commit comments

Comments
 (0)