My colleagues and I had a discussion regarding the vApp template. After virtual machine template for virtual machine, you would expect vApp template for vApp and manage it in a similar way from the vSphere Client. But you cannot.
Most of us know that from vSphere Client, you have context menu item allowing you to convert a virtual machine to a template easily with a click. However you cannot find a similar menu item with a vApp. You can choose to convert a virtual machine inside a vApp, but then the converted template will jump out of the vApp container.
Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.
Can we have vApp template? The answer is we can, but in a different way.
To fully understand what’s happening, let’s look into vSphere API which will shed some insights about this. To most people’s surprise, vApp (VirtualApp) is a sub type of ResourcePool, not VirtualMachine although it behaves somewhat like a virtual machine in that you can power on and off a vApp as would a virtual machine. This is a good example in which knowing API gives you insights on how the system is constructed under the hook. That is why system administrators want to learn about API, especially object model, even though not developing code.
The difference of a virtual machine and a virtual machine template is that a virtual machine is not associated with a ResourcePool object. That is why you need to specify a resource pool when turning a template to a virtual machine, as shown in the following method:
public void markAsVirtualMachine(ResourcePool pool, HostSystem host)
Note that the first pool parameter is a required parameter and cannot be null as the second one. Given a vApp itself is a ResourcePool, you cannot remove its association with a ResourcePool object, or destroy itself.
Now, how can we have a template for vApp? In fact, it’s pretty easy. You would use OVF as the template.
From vSphere Client, you can get to the “Export OVF Template” dialog box, shown below, from File->Export->Export OVF Template. It allows you to export a vApp to your local machine in OVF.
It’s also easy to deploy an OVF package to vApp with “Deploy OVF Template” dialog box as follows from File->Deploy OVF Template menu path. You can specify either from a local file or from a URL pointing to an OVF package. Unlike the other direction, you will have to go through several more steps here including accepting end user license agreement.
You can of course export and deploy (import) OVF packages with vSphere API. Check out this blog for more details and samples.