mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
parent
ecd2d1a9b4
commit
56947c9962
@ -66,11 +66,12 @@ const Steps = createSteps(
|
||||
const data = { instances, hold, persistent, template: templateXML }
|
||||
|
||||
const templates = [...new Array(instances)].map((_, idx) => ({
|
||||
id: vmTemplate.ID,
|
||||
name: name?.replace(/%idx/gi, idx),
|
||||
...data,
|
||||
}))
|
||||
|
||||
return [vmTemplate, templates]
|
||||
return templates
|
||||
},
|
||||
}
|
||||
)
|
||||
|
@ -38,7 +38,7 @@ import { PATH } from 'client/apps/sunstone/routesOne'
|
||||
*/
|
||||
function InstantiateVmTemplate() {
|
||||
const history = useHistory()
|
||||
const { state: { ID: templateId } = {} } = useLocation()
|
||||
const { state: { ID: templateId, NAME: templateName } = {} } = useLocation()
|
||||
|
||||
const { enqueueInfo } = useGeneralApi()
|
||||
const [instantiate] = useInstantiateTemplateMutation()
|
||||
@ -51,17 +51,16 @@ function InstantiateVmTemplate() {
|
||||
useGetUsersQuery(undefined, { refetchOnMountOrArgChange: false })
|
||||
useGetGroupsQuery(undefined, { refetchOnMountOrArgChange: false })
|
||||
|
||||
const onSubmit = async ([templateSelected, templates]) => {
|
||||
const onSubmit = async (templates) => {
|
||||
try {
|
||||
const { ID, NAME } = templateSelected
|
||||
const templatesWithId = templates.map((t) => ({ id: ID, ...t }))
|
||||
|
||||
await Promise.all(templatesWithId.map((t) => instantiate(t).unwrap()))
|
||||
const promises = await Promise.all(templates.map(instantiate))
|
||||
promises.map((res) => res.unwrap?.())
|
||||
|
||||
history.push(PATH.INSTANCE.VMS.LIST)
|
||||
|
||||
const total = templates.length
|
||||
enqueueInfo(`VM Template instantiated x${total} - #${ID} ${NAME}`)
|
||||
const templateInfo = `#${templateId} ${templateName}`
|
||||
enqueueInfo(`VM Template instantiated x${total} - ${templateInfo}`)
|
||||
} catch {}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user