.. _Managing Container Resource Configuration:

Managing Container Resource Configuration
-----------------------------------------

Any container is configured by means of its own configuration file. You can manage container configurations in a number of ways:

1. Using configuration sample files shipped with Virtuozzo. These files are used when a new container is being created (for details, see :ref:`Virtuozzo Containers`). Currently, the following configuration sample files are provided:

   -  ``basic`` for creating standard containers.

   -  ``confixx`` for creating containers that are to run the Confixx control panel.

   -  ``vswap.plesk`` for creating containers with the Plesk control panel.

   -  ``vswap.256MB`` for creating containers with 256 MB of main memory.

   -  ``vswap.512Mb`` for creating containers with 512 MB of main memory.

   -  ``vswap.1024Mb`` for creating containers with 1024 MB of main memory.

   -  ``vswap.2048Mb`` for creating containers with 2048 MB of main memory.

   .. note:: Configuration sample files cannot contain spaces in their names.

   Any sample configuration file can also be applied to an existing container. You would do this if, for example, you want to upgrade or downgrade the overall resources configuration of a particular container:

   ::

       # prlctl set MyCT --applyconfig basic

   This command applies all the parameters from the ``ve-basic.conf-sample`` file to the container ``MyCT``. When you install Virtuozzo on your hardware node, the default container samples are put to the ``/etc/vz/conf`` directory. They have the following format: ``ve-<name>.conf-sample`` (for example, ``ve-basic.conf-sample``).

2. Using specific utilities for preparing configuration files in their entirety. The tasks these utilities perform are described in the following subsections of this section.

3. The direct creating and editing of the corresponding container configuration file (``/etc/vz/conf/<UUID>.conf``). This can be performed with the help of any text editor. The instructions on how to edit container configuration files directly are provided in the four preceding sections. In this case you have to edit all the configuration parameters separately, one by one.

.. _Splitting Server Into Equal Pieces:

Splitting Server Into Equal Pieces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using the ``vzsplit`` command, you can create configurations for containers that would take a specific fraction of the hardware node resources. For example, to create a configuration ``myconf`` for up to 20 containers:

::

    # vzsplit -n 20 -f myconf
    Config /etc/vz/conf/ve-myconf.conf-sample was created

The configuration is calculated based on the hardware node resources. You can now use the ``--config myconf`` option of the ``prlctl create`` command to create containers based on this configuration.

.. _Applying New Configuration Samples to Containers:

Applying New Configuration Samples to Containers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Virtuozzo allows you to change the configuration sample file a container is based on and, thus, to modify all the resources the container may consume and/or allocate at once. For example, if the container ``MyCT`` is currently based on the ``basic`` configuration sample and you are planning to run the Plesk application inside the container, you may wish to apply the ``vswap.plesk`` sample to it instead of ``basic``, which will automatically adjust the necessary container resource parameters for running the Plesk application inside the container ``MyCT``. To do this, you can execute the following command on the hardware node:

::

    # prlctl set MyCT --applyconfig vswap.plesk

This command reads the resource parameters from the ``ve-vswap.plesk.conf-sample`` file located in the ``/etc/vz/conf`` directory and applies them one by one to the container ``MyCT``.

When applying new configuration samples to containers, keep in mind the following:

-  All container sample files are located in the ``/etc/vz/conf`` directory on the hardware node and are named according to the following pattern: ``ve-<name>.conf-sample``. You should specify only the ``<name>`` part of the corresponding sample name after the ``--applyconfig`` option (``vswap.plesk`` in the example above).

-  The ``--applyconfig`` option applies all the parameters from the specified sample file to the given container, except for the ``OSTEMPLATE``, ``TEMPLATES``, ``VE_ROOT``, ``VE_PRIVATE``, ``HOSTNAME``, ``IP_ADDRESS``, ``TEMPLATE``, ``NETIF`` parameters (if they exist in the sample file).

You may need to restart your container depending on the fact whether the changes for the selected parameters can be set on the fly or not. If some parameters could not be configured on the fly, you will be presented with the corresponding message informing you of this fact.

