in source/idea/idea-cluster-manager/webapp/src/pages/virtual-desktops/virtual-desktop-software-stacks.tsx [233:475]
buildRegisterSoftwareStackForm() {
return (
<IdeaForm
ref={this.registerSoftwareStackForm}
name="register-software-stack"
modal={true}
title="Register new Software Stack"
modalSize="medium"
onSubmit={() => {
this.getRegisterSoftwareStackForm().clearError();
if (!this.getRegisterSoftwareStackForm().validate()) {
return;
}
const values = this.getRegisterSoftwareStackForm().getValues();
let projects: Project[] = [];
values.projects?.forEach((project_id: string) => {
projects.push({
project_id: project_id,
});
});
this.getVirtualDesktopAdminClient()
.createSoftwareStack({
software_stack: {
name: values.name,
description: values.description,
ami_id: values.ami_id.toLowerCase().trim(),
base_os: values.base_os,
gpu: values.gpu,
min_storage: {
value: values.root_storage_size,
unit: "gb",
},
min_ram: {
value: values.ram_size,
unit: "gb",
},
placement: {
affinity: values.affinity,
tenancy: values.tenancy,
host_id: (values.target_host_by === "host_id") ? values.host_id : undefined,
host_resource_group_arn: (values.target_host_by === "host_resource_group") ? values.host_resource_group_arn : undefined,
},
projects: projects,
allowed_instance_types: []
},
})
.then(() => {
this.hideRegisterSoftwareStackForm();
this.setFlashMessage(<p key={values.name}>Software Stack: {values.name}, Create request submitted</p>, "success");
this.getListing().fetchRecords();
})
.catch((error) => {
this.getRegisterSoftwareStackForm().setError(error.errorCode, error.message);
});
}}
onCancel={() => {
this.hideRegisterSoftwareStackForm();
}}
params={[
{
name: "name",
title: "Name",
description: "Enter a name for the software stack",
help_text: "Use any characters and form a name of length between 3 and 24 characters, inclusive.",
data_type: "str",
param_type: "text",
validate: {
required: true,
regex: "^.{3,24}$",
message: "Use any characters and form a name of length between 3 and 24 characters, inclusive.",
},
},
{
name: "description",
title: "Description",
description: "Enter a user friendly description for the software stack",
data_type: "str",
param_type: "text",
validate: {
required: true,
},
},
{
name: "ami_id",
title: "AMI ID",
description: "Enter the AMI ID",
help_text: "AMI ID must start with ami-xxx",
data_type: "str",
param_type: "text",
validate: {
required: true,
},
},
{
name: "base_os",
title: "Operating System",
description: "Select the operating system for the software stack",
data_type: "str",
param_type: "select",
validate: {
required: true,
},
default: "amazonlinux2",
choices: this.state.supportedOsChoices,
},
{
name: "gpu",
title: "GPU Manufacturer",
description: "Select the GPU Manufacturer for the software stack",
data_type: "str",
param_type: "select",
validate: {
required: true,
},
default: "NO_GPU",
choices: this.state.supportedGPUChoices,
},
{
name: "root_storage_size",
title: "Min. Storage Size (GB)",
description: "Enter the min. storage size for your virtual desktop in GBs",
data_type: "int",
param_type: "text",
default: 50,
validate: {
required: true,
},
},
{
name: "ram_size",
title: "Min. RAM (GB)",
description: "Enter the min. ram for your virtual desktop in GBs",
data_type: "int",
param_type: "text",
default: 10,
validate: {
required: true,
},
},
{
name: "projects",
title: "Projects",
description: "Select applicable projects for the software stack",
data_type: "str",
param_type: "select",
multiple: true,
choices: this.state.projectChoices,
},
{
name: "tenancy",
title: "Tenancy",
description: "The type of tenancy",
data_type: "str",
param_type: "select",
validate: {
required: true,
},
default: "default",
choices: this.state.tenancyChoices,
},
{
name: "affinity",
title: "Tenancy Affinity",
description: "The relationship between an instance and a dedicated host",
data_type: "str",
param_type: "select",
validate: {
required: true,
},
choices: this.state.affinityChoices,
when: {
param: "tenancy",
eq: "host",
},
},
{
name: "target_host_by",
title: "Target Host By",
description: "The type of target host",
data_type: "str",
param_type: "select",
validate: {
required: true,
},
choices: this.state.targetHostChoices,
when: {
param: "tenancy",
eq: "host",
},
},
{
name: "host_id",
title: "Tenancy Host ID",
description: "The ID of the dedicated host",
help_text: "",
data_type: "str",
param_type: "text",
validate: {
required: true,
regex: "^h-.+$",
},
when: {
and: [
{
param: "tenancy",
eq: "host",
},
{
param: "target_host_by",
eq: "host_id",
}
]
},
},
{
name: "host_resource_group_arn",
title: "Host Resource Group ARN",
description: "The ARN of the dedicated resource group",
help_text: "",
data_type: "str",
param_type: "text",
validate: {
required: true,
regex: "^(?:arn:(?:aws(?:-cn|-us-gov)?)):resource-groups:.+:\\d{12}:group/.{1,128}$",
},
when: {
and: [
{
param: "tenancy",
eq: "host",
},
{
param: "target_host_by",
eq: "host_resource_group",
}
]
},
},
]}
/>
);
}