in source/idea/idea-cluster-manager/webapp/src/pages/cluster-admin/filesystem.tsx [566:759]
buildOnboardFileSystemForm() {
return (
<IdeaForm
ref={this.onboardFileSystemForm}
name="onboard-filesystem"
modal={true}
modalSize="medium"
title="Onboard New File System"
onSubmit={() => {
if (!this.getOnboardFileSystemForm().validate()) {
return;
}
const values = this.getOnboardFileSystemForm().getValues();
if (
!dot.pick(`${Constants.SHARED_STORAGE_PROVIDER_EFS}.mount_directory`, values) &&
!dot.pick(`${Constants.SHARED_STORAGE_PROVIDER_FSX_NETAPP_ONTAP}.mount_directory`, values) &&
!dot.pick(`${Constants.SHARED_STORAGE_PROVIDER_FSX_NETAPP_ONTAP}.mount_drive`, values) &&
!dot.pick(`${Constants.SHARED_STORAGE_PROVIDER_FSX_LUSTRE}.mount_directory`, values)
) {
this.getOnboardFileSystemForm().setError("InvalidParams", "one of mount directory or mount drive is required");
return;
}
//Extract filesystemId
const addFilesystemValue = dot.pick("onboard_filesystem", values);
const addFilesystemValueSplit = addFilesystemValue.split(".");
const provider = addFilesystemValueSplit[0];
const fileSystemId = addFilesystemValueSplit[1];
//Extract common file system values
const commonFileSystemValues = dot.pick("filesystem", values);
//Extract specified provider values
const providerValues = dot.pick(provider, values);
let attachFileSystem;
let volumeId;
if (provider === Constants.SHARED_STORAGE_PROVIDER_EFS) {
attachFileSystem = (request: any) => this.filesystem().onboardEFSFileSystem(request);
} else if (provider === Constants.SHARED_STORAGE_PROVIDER_FSX_LUSTRE) {
attachFileSystem = (request: any) => this.filesystem().onboardFSXLUSTREFileSystem(request);
} else {
//Extract volume id
const volumeIdValue = dot.del("volume_id", providerValues);
volumeId = volumeIdValue.split(".")[1];
const svmId = volumeIdValue.split(".")[0];
if (svmId != dot.pick("svm_id", providerValues)) {
this.getOnboardFileSystemForm().setError("InvalidParams", "the volume is not mapped to the svm, please refresh the volume list");
return;
}
attachFileSystem = (request: any) => this.filesystem().onboardFSXONTAPFileSystem(request);
}
attachFileSystem({
...commonFileSystemValues,
...providerValues,
filesystem_id: fileSystemId,
volume_id: volumeId,
})
.then(() => {
this.props.onFlashbarChange({
items: [
{
type: "success",
content: `File System: ${fileSystemId} is being onboarded, it will be available once the onboarding process is complete.`,
dismissible: true,
},
],
});
this.setState(
{
filesystemsNotOnboarded: {},
},
() => {
this.hideOnboardFileSystemForm();
this.getListing().fetchRecords();
}
);
this.saveFilesystemIdToLocalStorage(fileSystemId);
})
.catch((error) => {
this.getOnboardFileSystemForm().setError(error.errorCode, error.message);
});
}}
onCancel={() => {
this.hideOnboardFileSystemForm();
}}
onFetchOptions={(request) => {
if (request.param === "onboard_filesystem") {
this.setState({ fileSystemOnboardingOptionLoading: true });
return this.proxyService()
.listFileSystemsForOnboard(this.getFilesystemIdsFromLocalStorage())
.then((result) => {
const efsFileSystems = result.efs;
const fsxONTAPFileSystems = result.fsx_ontap;
const fsxLUSTREFileSystems = result.fsx_lustre;
const filesystemsNotOnboarded: FileSystemsNotOnboarded = {};
const choices: SocaUserInputChoice[] = [];
efsFileSystems?.forEach((efsFileSystem) => {
const fileSystemId = efsFileSystem.efs.FileSystemId;
const provider = Constants.SHARED_STORAGE_PROVIDER_EFS;
choices.push({
title: `${fileSystemId} [${provider}]`,
value: `${provider}.${fileSystemId}`,
});
dot.set(fileSystemId, efsFileSystem, filesystemsNotOnboarded);
});
fsxONTAPFileSystems?.forEach((fsxONTAPFileSystem) => {
const fileSystemId = fsxONTAPFileSystem.filesystem.FileSystemId;
const provider = Constants.SHARED_STORAGE_PROVIDER_FSX_NETAPP_ONTAP;
choices.push({
title: `${fileSystemId} [${provider}]`,
value: `${provider}.${fileSystemId}`,
});
dot.set(fileSystemId, fsxONTAPFileSystem, filesystemsNotOnboarded);
});
fsxLUSTREFileSystems?.forEach((fsxLUSTREFileSystem) => {
const fileSystemId = fsxLUSTREFileSystem.filesystem.FileSystemId;
const provider = Constants.SHARED_STORAGE_PROVIDER_FSX_LUSTRE;
choices.push({
title: `${fileSystemId} [${provider}]`,
value: `${provider}.${fileSystemId}`,
});
dot.set(fileSystemId, fsxLUSTREFileSystem, filesystemsNotOnboarded);
});
this.setState({
filesystemsNotOnboarded,
fileSystemOnboardingOptionLoading: false,
});
return {
listing: choices,
};
});
} else if (request.param === `${Constants.SHARED_STORAGE_PROVIDER_FSX_NETAPP_ONTAP}.svm_id`) {
const filesystemsNotOnboarded = this.state.filesystemsNotOnboarded;
const selectedOnboardFileSystemValue = this.getSelectedOnboardFileSystem()!.getValueAsString();
const filesystemId = selectedOnboardFileSystemValue.split(".")[1];
const fsxFileSystem: FSxONTAPFileSystem = dot.pick(filesystemId, filesystemsNotOnboarded);
const fsxFileSystemSVMs = fsxFileSystem.svm || [];
const choices: SocaUserInputChoice[] = [];
fsxFileSystemSVMs.forEach((svm) => {
const svmId = dot.pick("StorageVirtualMachineId", svm.storage_virtual_machine);
choices.push({
title: svmId,
value: svmId,
});
});
return Promise.resolve({
listing: choices,
});
} else if (request.param === `${Constants.SHARED_STORAGE_PROVIDER_FSX_NETAPP_ONTAP}.volume_id`) {
const filesystemsNotOnboarded = this.state.filesystemsNotOnboarded;
const selectedOnboardFileSystemValue = this.getSelectedOnboardFileSystem()!.getValueAsString();
const selectedSVM = this.getSelectedSVM()!.getValueAsString();
const filesystemId = selectedOnboardFileSystemValue.split(".")[1];
const fsxFileSystem: FSxONTAPFileSystem = dot.pick(filesystemId, filesystemsNotOnboarded);
const fsxFileSystemVolumes = fsxFileSystem.volume;
const choices: SocaUserInputChoice[] = [];
fsxFileSystemVolumes.forEach((volume) => {
if (dot.pick("OntapConfiguration.StorageVirtualMachineId", volume.volume) === selectedSVM) {
const volumeId = dot.pick("VolumeId", volume.volume);
const svmId = dot.pick("OntapConfiguration.StorageVirtualMachineId", volume.volume);
choices.push({
title: volumeId,
value: `${svmId}.${volumeId}`,
});
}
});
return Promise.resolve({
listing: choices,
});
} else {
return Promise.resolve({
listing: [],
});
}
}}
params={[
{
name: "onboard_filesystem",
title: "Onboard File System",
readonly: this.state.fileSystemOnboardingOptionLoading,
description: this.state.fileSystemOnboardingOptionLoading ? "Selections loading..." : "Select applicable file system to onboard",
param_type: "select",
multiple: false,
data_type: "str",
dynamic_choices: true,
},
...this.buildCommonOnboardFileSystemParams(),
...this.buildOnboardEFSParams(),
...this.buildOnboardFSxNetAppONTAPParams(),
...this.buildOnboardFSxLUSTREParams(),
]}
/>
);
}