.. _Managing Templates:

Managing Templates
------------------

A template in Virtuozzo 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 servers (see :ref:`Migrating Virtual Machine and Container Templates`).

These operations are described in the following subsections in detail.

.. note:: In addition, see :ref:`Using Customized EZ Templates` for details on how to manually create and use custom container templates.

.. _Creating Templates:

Creating Templates
~~~~~~~~~~~~~~~~~~

In Virtuozzo, 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:

1. You create a virtual machine or container with the required configuration.

2. You make a template on the basis of the created virtual machine or container.

3. You use the template to create as many virtual machines or containers as necessary.

Let us assume that you want to create a template of the virtual machine ``MyVM``. To do this, you can run the following command:

::

    # prlctl clone MyVM --name template1 --template

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.

.. _Listing Templates:

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:

::

    # prlctl list -t
    UUID                                    DIST            T  NAME
    {017bfdf0-b546-4309-90d0-147ce55773f2}  centos          VM centos1_tmpl
    {92cd331e-0572-46ac-8586-f19b8d029c4d}  centos          CT ct201_tmp1
    {fc40e38e-8da4-4b26-bb18-6098ec85f7b4}  debian          VM deb7_tmpl
    {0dea5912-b114-45a9-bd1a-dc065c1b8e9f}  ubuntu          VM ubuntu1_tmp1
    {479e66aa-332c-4e3e-975e-b8b6bfc9d2e0}  win-2012        VM w12en_tmpl

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:

Deploying Templates
~~~~~~~~~~~~~~~~~~~

To convert a template into a virtual machine or container, use the ``--ostemplate`` option of the ``prlctl create`` command. For example, to convert the ``template1`` template to the ``ConvertedVM`` virtual machine, you can run this command:

::

    # prlctl create ConvertedVM --ostemplate template1

To check that the virtual machine has been successfully created, use the ``prlctl list -a`` command:

::

    # prlctl list -a
    STATUS       IP_ADDR         NAME
    running      10.12.12.101    MyVM
    stopped      10.12.12.34     ConvertedVM

The template itself is left intact and can be used for creating other virtual machines:

::

    # prlctl list -t
    {4ad11c28-9f0e-4086-84ea-9c0487644026} win-2008 template1
    {64bd8fea-6047-45bb-a144-7d4bba49c849} rhel     template2

