formControlName="fs_name"
name="fs_name"
id="fs_name"
- (change)="pathChangeHandler()">
+ (change)="volumeChangeHandler()">
<option *ngIf="allFsNames === null"
value=""
i18n>Loading...</option>
</div>
</div>
+ <div class="form-group row"
+ *ngIf="storageBackend === 'CEPH'">
+ <label class="cd-col-form-label"
+ for="subvolume_group"
+ i18n>Subvolume Group</label>
+ <div class="cd-col-form-input">
+ <select class="form-select"
+ formControlName="subvolume_group"
+ name="subvolume_group"
+ id="subvolume_group"
+ (change)="getSubVol()">
+ <option *ngIf="allsubvolgrps === null"
+ value=""
+ i18n>Loading...</option>
+ <option *ngIf="allsubvolgrps !== null && allsubvolgrps.length === 0"
+ value=""
+ i18n>-- No CephFS subvolume group available --</option>
+ <option *ngIf="allsubvolgrps !== null && allsubvolgrps.length > 0"
+ value=""
+ i18n>-- Select the CephFS subvolume group --</option>
+ <option *ngFor="let subvol_grp of allsubvolgrps"
+ [value]="subvol_grp.name">{{ subvol_grp.name }}</option>
+ </select>
+ </div>
+ </div>
+
+ <div class="form-group row"
+ *ngIf="storageBackend === 'CEPH'">
+ <label class="cd-col-form-label"
+ for="subvolume"
+ i18n>Subvolume</label>
+ <div class="cd-col-form-input">
+ <select class="form-select"
+ formControlName="subvolume"
+ name="subvolume"
+ id="subvolume"
+ (change)="getPath()">
+ <option *ngIf="allsubvols === null"
+ value=""
+ i18n>Loading...</option>
+ <option *ngIf="allsubvols !== null && allsubvols.length === 0"
+ value=""
+ i18n>-- No CephFS subvolume available --</option>
+ <option *ngIf="allsubvols !== null && allsubvols.length > 0"
+ value=""
+ i18n>-- Select the CephFS subvolume --</option>
+ <option *ngFor="let subvolume of allsubvols"
+ [value]="subvolume.name">{{ subvolume.name }}</option>
+ </select>
+ </div>
+ </div>
+
<!-- Path -->
<div class="form-group row"
*ngIf="nfsForm.getValue('name') === 'CEPH'">
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
import { NfsFormClientComponent } from '../nfs-form-client/nfs-form-client.component';
+import { CephfsSubvolumeService } from '~/app/shared/api/cephfs-subvolume.service';
+import { CephfsSubvolumeGroupService } from '~/app/shared/api/cephfs-subvolume-group.service';
@Component({
selector: 'cd-nfs-form',
action: string;
resource: string;
+ allsubvolgrps: any[] = [];
+ allsubvols: any[] = [];
+ fsPath: string = null;
+
pathDataSource = (text$: Observable<string>) => {
return text$.pipe(
debounceTime(200),
constructor(
private authStorageService: AuthStorageService,
private nfsService: NfsService,
+ private subvolService: CephfsSubvolumeService,
+ private subvolgrpService: CephfsSubvolumeGroupService,
private route: ActivatedRoute,
private router: Router,
private rgwBucketService: RgwBucketService,
});
}
+ volumeChangeHandler() {
+ this.pathChangeHandler();
+ const fs_name = this.nfsForm.getValue('fsal').fs_name;
+ this.getSubVolGrp(fs_name);
+ }
+
+ getSubVol() {
+ this.getPath();
+ const fs_name = this.nfsForm.getValue('fsal').fs_name;
+ const subvolgrp = this.nfsForm.getValue('subvolume_group');
+ return this.subvolService.get(fs_name, subvolgrp).subscribe((data: any) => {
+ this.allsubvols = data;
+ });
+ }
+
+ getSubVolGrp(fs_name: string) {
+ return this.subvolgrpService.get(fs_name).subscribe((data: any) => {
+ this.allsubvolgrps = data;
+ });
+ }
+
+ getFsPath(volList: any[], value: string) {
+ const match = volList.find((vol) => vol.name === value);
+ if (match) {
+ return match.info.path;
+ }
+ }
+
+ getPath() {
+ const subvol = this.nfsForm.getValue('subvolume');
+ if (subvol === '') {
+ const subvolGroup = this.nfsForm.getValue('subvolume_group');
+ this.fsPath = this.getFsPath(this.allsubvolgrps, subvolGroup);
+ } else {
+ this.fsPath = this.getFsPath(this.allsubvols, subvol);
+ }
+ this.nfsForm.patchValue({
+ path: this.fsPath
+ });
+
+ this.pathChangeHandler();
+ }
+
createForm() {
this.nfsForm = new CdFormGroup({
cluster_id: new UntypedFormControl('', {
]
})
}),
- path: new UntypedFormControl('/'),
+ subvolume_group: new UntypedFormControl(''),
+ subvolume: new UntypedFormControl(''),
+ path: new UntypedFormControl('/', {
+ validators: [Validators.required]
+ }),
protocolNfsv4: new UntypedFormControl(true),
pseudo: new UntypedFormControl('', {
validators: [
resolveFilesystems(filesystems: any[]) {
this.allFsNames = filesystems;
- if (!this.isEdit && filesystems.length > 0) {
- this.nfsForm.patchValue({
- fsal: {
- fs_name: filesystems[0].name
- }
- });
- }
}
fsalChangeHandler() {
delete requestModel.fsal.fs_name;
}
+ delete requestModel.subvolume;
+ delete requestModel.subvolume_group;
+
requestModel.protocols = [];
if (requestModel.protocolNfsv4) {
requestModel.protocols.push(4);