Managing Templates
A template in Virtuozzo Server is a pre-configured virtual machine or container that can be easily and quickly deployed into a fully functional virtual machine or container. Like any normal virtual machine or container, a template contains hardware (virtual disks, peripheral devices) and the operating system. It can also have additional software installed. In fact, the only main difference between a virtual machine or container and a template is that the latter cannot be started.
You can perform the following operations on templates:
- Create a new template.
- List existing templates.
- Create a virtual machine or container from a template.
- Migrate templates between Virtuozzo Server servers.
- Store templates on Virtuozzo Storage.
These operations are described in the following subsections in detail.
Creating Templates
In Virtuozzo Server, you can create a template using the prlctl clone utility. Making a template may prove useful if you need to create several virtual machines or containers with the same configuration. In this case, your steps can be as follows:
- Create a virtual machine or container with the required configuration.
- Make a template on the basis of the created virtual machine or container.
- Use the template to create as many virtual machines or containers as necessary.
For example, to create a template of the virtual machine MyVM, run the following command:
| |
This command clones the virtual machine and saves it as the template1 template. After the template has been successfully created, you can use it for creating new virtual machines.
/mode:vm parameter.Listing Templates
Sometimes, you may need to get an overview of the templates available on your hardware node. For example, this may be necessary if you plan to create a virtual machine or container from a specific template, but do not remember its exact name. In this case, you can use the prlctl list command to list all templates on the hardware node and find the one you need:
| |
In this example, 5 templates exist on the server. The information on these templates is presented in the form of a table with the following columns (from left to right): the template ID, the operating system contained in the template, the template type (for a container or virtual machine) and the template name.
Deploying Templates
To deploy a virtual machine or container from a template, use the --ostemplate option of the prlctl create command. For example, to deploy the virtual machine MyVMtemplate1 from the template template1, run the following:
| |
To check that the virtual machine has been successfully created, use the prlctl list -a command:
| |
The template itself is left intact and can be used for creating other virtual machines:
| |
Migrating Templates
Migrating virtual machine and container templates between Virtuozzo Server servers is similar to migrating virtual machines and containers offline.
To migrate (move) the template
template1to the remote serverremoteserver.com, on the local server run:1# prlctl migrate template1 remoteserver.comTo migrate (move) the template
template1from the remote serverremoteserver.com, on the local server run:1# prlctl migrate remoteserver.com/template1 localhost
The root account is used to log in to the remote server by default, so you will be asked for the root password. You can also provide different credentials (and port) in the format [
Once migration is complete, the original template is removed from the source server (unless --clone is added).
Storing Templates on Virtuozzo Storage
Starting from Virtuozzo Server 7.0.7 (Update 7), you can store container and virtual machine templates in shared directories of Virtuozzo Storage clusters. These templates will be available to any server participating in the cluster.
To place a template on Virtuozzo Storage, do as follows on the cluster node where the source container or VM is located:
Create a template. For example:
1# prlctl clone MyVM --name template1 --templateMove this template to the
vmtemplatesdirectory located on Virtuozzo Storage:for Virtuozzo Storage with CLI management, the path is
/vstorage/<cluster_name>/vmtemplates, e.g.:1# prlctl move template1 --dst /vstorage/vstor1/vmtemplatesfor Virtuozzo Storage with GUI management, the path is
/mnt/vstorage/vmtemplates, e.g.:1# prlctl move template1 --dst /mnt/vstorage/vmtemplates
Within five minutes, the template will be autodetected by the prlctl utility. You can check template availability by listing templates on another Virtuozzo Storage server. For example:
| |
Once the template is available throughout the cluster, you can start creating containers or VMs based on it on any cluster node as described in Deploying Templates.