This chapter describes creating templates and cloning virtual machines.
This chapter contains the following sections:
“Understanding Templates” on page 177
“Creating Templates” on page 178
“Editing a Template” on page 182
“Deploying Virtual Machines from Templates” on page 183
“Template Registry” on page 186
“Cloning an Existing Virtual Machine” on page 187
“Creating a Scheduled Task to Clone a Virtual Machine” on page 190
Understanding Templates
A template is a golden image of a virtual machine that can be used as a master copy to create and provision new virtual machines. This image typically includes a specified operating system and configuration that provides virtual counterparts to hardware components. Typically, a template includes an installed guest operating system and a set of applications.
Templates coexist with virtual machines at any level within the template and virtual machine domain. You can order collections of virtual machines and templates into arbitrary folders and apply a variety of permissions to both virtual machines and templates. Virtual machines can be transformed into templates without requiring a full copy of the virtual machine files and the creation of a new object.
You can use templates to create new virtual machines by cloning the template as a virtual machine. When complete, the deployed virtual machine is added to the inventory panel datacenter where the host resides.
Templates are created from existing virtual machines. After a template is created, it can be deployed only to managed hosts that have access to the datastore where the
template resides. On ESX Server hosts, the datastores are the VMFS, local, or NAS volumes that you configured for your ESX Server.
If a managed host with templates stored in it is removed from VirtualCenter, all the templates are also removed from the inventory. Returning the managed host to VirtualCenter does not re‐register the templates because they are invisible to the host.
When a host is added back to VirtualCenter, you can register the templates, making them visible.
Creating Templates
There are three ways to create a template:
Using an existing virtual machine in place. This process converts the original virtual machine.
Cloning a virtual machine to a template.
Cloning an existing template.
To create a template in place from a virtual machine 1 Start the VI Client and log on to the VirtualCenter Server.
2 Click the Inventory button in the navigation bar.
The inventory panel and the information panel display information about managed datacenters, hosts, resource pools, and virtual machines. The inventory toolbar appears.
3 Expand the inventory as needed, and select a virtual machine.
4 From the Commands area or the pop‐up menu, click Convert to Template.
VirtualCenter marks that virtual machine as a template and displays the task in the Recent Tasks pane.
To clone a virtual machine to a template
1 Start the VI client, and log on to the VirtualCenter Server.
2 Click Inventory in the navigation bar to display the inventory panel.
3 If the virtual machine you want to clone is powered on, right‐click it and click Power Off.
4 Right‐click the virtual machine and click Clone to Template.
The Clone Virtual Machine to Template wizard appears.
5 Give the new template a name and description, and click Next.
Enter a useful name that describes the template. Description information can include, for example, the operating system, applications, versions, and intended uses for the template. The name can be up to 80 characters long and can contain alphanumeric characters and the underscore ( _ ) and hyphen (‐) characters. It should also be unique across all templates and virtual machines in the datacenter.
6 Pass through the target location page. Click Next.
7 Click Finish.
VirtualCenter displays the Tasks inventory panel for reference and adds the cloned template to the list in the information panel.
To clone an existing template
1 Start the VI client, and log on to the VirtualCenter Server.
2 Click the Inventory button in the navigation bar.
3 Select the datacenter that contains the template.
The virtual machines and templates associated with the datacenter appear in the datacenter panel.
4 Right‐click the template and choose Clone.
The Clone Template wizard appears.
5 Give the new template a name and description, and click Next.
Enter a useful name and a brief description of the template. Description
information can include, for example, the operating system, applications, versions, and intended uses for the template. The name can be up to 80 characters long, and can contain alphanumeric characters and the underscore
( _ ) and hyphen (‐) characters. It should also be unique across all templates and virtual machines in the datacenter.
6 Select the host or cluster, and click Next.
7 Choose a datastore for the template. Click Next.
8 Select a radio button to either leave the virtual disks in their Normal virtual machine format or to Compact the virtual disks to minimize storage. Click Next.
9 On the Ready to Complete window, review the information for your new virtual machine, and click Finish.
You cannot use the new template until the cloning task completes. VirtualCenter adds the cloned template to the list in the Virtual Machines tab.
Editing a Template
You might want to edit your template (to upgrade an application, for example).
However, templates cannot be edited as templates. You must convert the template to a virtual machine, edit it, and convert the edited virtual machine to a template.
To edit the template
1 If you want to edit the properties of a template, convert the template to a virtual machine.
2 Edit the virtual machine.
3 Convert the virtual machine to a template.
You can directly change the name of a template using the procedure below.
To change the name of a virtual machine
1 From the VirtualCenter client, click the Inventory button.
2 Select the datacenter that contains the template.
3 Select the Virtual Machines tab.
4 Right‐click on the virtual machine, and choose Rename.
The name of the virtual machine is now an editable field.
5 Change the name, and click outside the field.
Deploying Virtual Machines from Templates
To deploy a virtual machine from a template
1 Start the VI Client, and log on to the VirtualCenter Server.
2 Click the Inventory button in the navigation bar.
The inventory panel and the information panel display information about managed datacenters, hosts, resource pools, and virtual machines. The inventory toolbar appears.
3 Select the datacenter that contains the template, and click the Virtual Machines tab.
The virtual machines and templates associated with the datacenter appear in the datacenter panel.
4 Right‐click the template, and choose Deploy Virtual Machine from this Template.
The Deploy Template wizard appears.
5 Give the new virtual machine a name, select a location, and click Next.
The name can be up to 80 characters long and can contain alphanumeric characters and the underscore ( _ ) and hyphen (‐) characters. It should also be unique across all templates and virtual machines in the datacenter.
6 On the Host / Cluster page, select the host on which you want to store the template and click Next.
7 Select a resource pool (if applicable) in which you want to run the virtual machine, and click Next.
Resource pools allow hierarchical management of resources within a host or cluster. Virtual machines and child pools share the resources of their parent pool.
8 Choose a datastore for the virtual machine, and click Next.
You are choosing the datastore in which to store the files for the virtual machine.
You should choose one that is large enough to accommodate the virtual machine and all of its virtual disk files so that they can all reside in the same place.
The Advanced button allows you to store individual files in separate locations. To return to the datastore selection page, click the Basic button.
9 On the Select Guest Customization Option page, perform one of these actions:
If you do not want to customize your guest operating system, select Do not customize and click Next.
If you want to customize your guest operating system, click one of the other selections as appropriate. You customize guest operating systems through the Guest Customization Wizard or by using an existing customization