1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B OpenNebula/one#6716: Correct instances amount when instantiate (#3223)

* Now instantiates the correct number of instances specified for a
  service ServiceTemplate
* Default number of instances set to 1

Signed-off-by: Victor Hansson <vhansson@opennebula.io>
(cherry picked from commit 212aa91a3c59a5a9fa351d1be6fbd9e3d0f10a33)
This commit is contained in:
vichansson 2024-09-10 17:44:49 +03:00 committed by Tino Vázquez
parent 1e3757d845
commit 8e3ec6fcee
No known key found for this signature in database
GPG Key ID: 14201E424D02047E
3 changed files with 15 additions and 5 deletions

View File

@ -36,7 +36,9 @@ const INSTANCE_FIELD = {
name: 'INSTANCES',
label: T.NumberOfInstances,
type: INPUT_TYPES.TEXT,
validation: number().required(),
validation: number()
.required()
.default(() => 1),
fieldProps: {
type: 'number',
},

View File

@ -120,6 +120,7 @@ const Steps = createSteps([General, UserInputs, Network, Charter], {
),
})),
name: generalData?.NAME,
instances: generalData?.INSTANCES,
}
return formatTemplate

View File

@ -62,11 +62,18 @@ function CreateServiceTemplate() {
useGetDatastoresQuery(undefined, { refetchOnMountOrArgChange: false })
const onSubmit = async (jsonTemplate) => {
const { instances = 1 } = jsonTemplate
try {
await instantiate({
id: templateId,
template: jsonTemplate,
}).unwrap()
await Promise.all(
Array.from({ length: instances }, async () =>
instantiate({
id: templateId,
template: jsonTemplate,
}).unwrap()
)
)
history.push(PATH.INSTANCE.SERVICES.LIST)
enqueueSuccess(T.SuccessServiceTemplateInitiated, [templateId, NAME])
} catch {}