Hi,
I use a script which deploys same OVF file with different names and different network configuration multiple times ( Upto 8 times ).
I believe that by doing this, I am wasting the time when Import-Vapp copies the ( .vmdk, .mf, .ovf ) files from host onto datatstore each time it is called.
My OVF contains a single virtual machine.
Can I do thing like, copy the files ( .vmdk, .mf, .ovf ) first on the datastore. Than from there do Import-Vapp. Since the related files are already present on datastore, the time it used to take for copying the files from host onto datatstore each time will be saved.
Please correct me If I am wrong.
The whole point is to how we can shorten the time to deploy the same ovf multiple times.
Powercli version - 4.1
Thanks
Nikunj
Afaik, there is no option to import a vApp from a datastore location.
The underlying ImportVApp method relies on the client to upload the files to the URLs
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sounds like you really want to do just one vApp import, and then clone that vApp as many times as required. This should be much faster.
...but there's no Clone-VApp CmdLet, the following should do the job...
$SourceVappName = "Source VApp Name"
$DestDatastore = "Datastore Name"
$DestPortGroup = "Network Port Group Name"
$DestFolder = "vCentre Folder Name"$DestVAppName = "Destination VApp Name"
$SourceVapp = Get-VApp $SourceVappName
$TargetPool = (Get-View (Get-ResourcePool -Id $SourceVapp.ParentId)).MoRef
$VAppCloneSpec = New-Object VMware.Vim.VAppCloneSpec
$VAppCloneSpec.Location = (Get-View (Get-Datastore $DestDatastore)).MoRef
$VAppCloneSpec.vmFolder = (Get-View (Get-Folder $DestFolder)).MoRef
$VAppCloneSpec.networkMapping = New-Object VMware.Vim.VAppCloneSpecNetworkMappingPair[] (1)
$VAppCloneSpec.networkMapping[0] = New-Object VMware.Vim.VAppCloneSpecNetworkMappingPair
$VAppCloneSpec.networkMapping[0].source = (Get-View (Get-VirtualPortGroup -Distributed -Name $DestPortGroup)).MoRef
$VAppCloneSpec.networkMapping[0].destination = (Get-View (Get-VirtualPortGroup -Distributed -Name $DestPortGroup)).MoRef
$VAppToClone = Get-View -Id (Get-VApp $SourceVApp).Id
$VAppToClone.CloneVApp_Task($DestVAppName, $TargetPool, $VAppCloneSpec)
Correction to the above - use the New-VApp command to clone a vApp and use the -VApp parameter to specify the source vApp
Hi,
I am having difficulty in understanding your answer.
Could you please elaborate a little.?
Sorry, I am fairly new to powercli and vmware.
Thanks
Nikunj
Hi,
Rather than doing a Import-VApp multiple times, import the OVF once, then use New-VApp to create clones of that vApp. If your OVF just contains a single machine, then you could use New-VM to clone the VM.
This way you'll be cloning within your virtual infrastructure rather than copying in from outside each time.
Cheers
Simon