in Part 1 we discussed how to add a configuration to the OvfConfiguration object (See Post HERE). In this post we will quickly discuss how to leverage the new –OvfConfiguration parameter when deploying vApps.
Import-VApp
PowerCLI has a nice little cmdlet called ‘Import-VApp’. This cmdlet allows us to import OVF and OVA packages into vSphere. Let’s run the get-help command to see what the cmdlet requires.
get-help Import-VApp
Looking under the SYNTAX section we can get a feel for what we can do with this cmdlet.
We will use the following information to deploy Log Insight:
- Source (location of the target vApp)
- OvfConfiguration (our hashtable or ovfconfiguration object)
- Name (name of our VM)
- VMHost (where the VM will reside)
- Datastore (which datastore we want to place Log Insight on)
- DiskStorageFormat (I prefer to use thin)
Assuming from the previous post that we now have an OvfConfiguration object ready to deploy a vApp. Let’s take a quick look at the hash table we have:
Ok, our hashtable ($ovfconfig) looks good. Let’s now populate our VMhost and Datastore variables.
$myhost = get-cluster “Main-CL” | Get-VMHost | Where {$_.PowerState –eq “PoweredOn” –and $_.ConnectionState –eq “Connected”} | Get-Random
$datastore = $myhost | get-Datastore | Sort FreeSpaceGB –Descending | Select –first 1
We’ll Name our VM “OVFConfig-LogInsight” since I feel that is very fitting for this example.
We now have all of the information we need to deploy Log Insight. We can put all of this information together in the following command:
Import-VApp –Source $ovfpath –OvfConfiguration $ovfconfig –Name OVFConfig-LogInsight –VMHost $myhost –Datastore $datastore –DiskStorageFormat Thin
When we hit enter, we see that the vApp is importing. Now we just need to wait for it to finish importing the package into vSphere.
Once the package has imported we can then power it on using the following command:
get-vm OVFConfig-LogInsight | Start-VM
We have now successfully created the configuration of the hashtable or configuration object and deployed the vApp into our environment using PowerCLI without having to leverage external scripts or modules, Enjoy!