VMware Cloud Community
lawrend
Contributor
Contributor

building multiple vms in a vCloud vApp, via powercli, want to run in parallel, rather than serial

Hi

So I have scripted the below as part of automating a vApp network build, the code works fine, but I have an issue, I would like to overcome.

When the code is run without -runAsync, it builds one vm at a time, this is fine, but takes a while, especially if a lot of vms to build.

When I run the code with -runAsync, I was thinking it would send the job with all the vms in to build at once.

What it actually does is go through the loop, starts building 1st VM, then errors with "the entity null is busy completing an operation", it completes first vm build but fails on the 2nd vm and so on.

I understand this is because the vApp is locked, I would like to be able to add all vms to vapp, then build the lot in one go, just like you can in the GUI.

Would anyone know of a solution for this by any chance ...

Code Below:

There a few variables in this, these variables are brought in from a csv file.

$vApp = get-civapp -name testVapp

#import config
$configs = import-csv "file......"


foreach ($item in $configs)
$vmname = $item.vmname
$template = $item.template


new-civm -vapp $vApp -VMTemplate $template -name $vmname -computername $vmname

## new-civm -vapp $vApp -VMTemplate $template -name $vmname -computername $vmname -runAsync

thanks
David

0 Kudos
0 Replies