.. _Managing Virtual Machines:

Managing Virtual Machines
-------------------------

Each virtual machine (VM) is an independent system with an independent set of virtual hardware. Its main features are the following:

-  A virtual machine resembles and works like a regular computer. It has its own virtual hardware. Software applications can run in virtual machines without any modifications or adjustment.

-  Virtual machine configuration can be changed easily (e.g., adding new virtual disks or increasing RAM).

-  Although virtual machines share physical hardware resources, they are fully isolated from each other (file system, processes, sysctl variables) and the compute node.

-  A virtual machine can run any supported guest operating system.

**Virtual Machine Hardware**

The table below lists the current virtual machine configuration limits:

========  ======================
Resource  Limit      
========  ======================
RAM       1 TB            
CPU       64 logical CPUs
Storage   15 volumes, 16 TB each
Network   15 NICs
========  ======================

**Supported Guest Operating Systems**

The following guest operating systems have been tested and are supported in virtual machines:

.. Will need to review this list.

- Windows 8.1 Enterprise (x64)
- Windows 10 Enterprise (x64)
- Windows Server 2003 Standard (x86, x64)
- Windows Server 2008 Standard, Datacenter (x64)
- Windows Server 2008 R2 Standard, Datacenter (x64)
- Windows Server 2012 Standard, Datacenter (x64)
- Windows Server 2012 R2 Essentials, Standard, Datacenter (x64)
- Windows Server 2016 Essentials, Standard, Datacenter (x64)
- CentOS 7.x (x64)
- CentOS 6.x (x64)
- RHEL 6.x (x64)
- Debian 9.x (x64)
- Debian 8.x (x64)
- Debian 6.x (x64)
- Ubuntu 16.04.x (x64)
- Ubuntu 14.04.x (x64)
- Oracle Linux 6 (x64)
- Oracle Linux 7 (x64)
- Oracle Solaris 11 (x64)

.. _Creating and Deleting Virtual Machines:

Creating and Deleting Virtual Machines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Before you proceed to creating VMs, check that you have these:

- A guest OS source (see :ref:`Managing Images`):

   - a distribution ISO image of a guest OS to install in the VM,
   - a boot volume template, or
   - a boot volume.
   
     .. note:: To obtain a boot volume, create a volume as described in :ref:`Managing Volumes`, attach it to a VM, install an operating system in it, then detach it from the VM.

- A storage policy for volumes (see :ref:`Managing Storage Policies`).

- (Optional) A flavor (see :ref:`Managing Flavors`).

- (Optional) One or more virtual networks (see :ref:`Managing Virtual Networks`).

   .. #. If necessary, create an access key for the user as described in :ref:`Managing Keys`. This is not done yet.

To create a VM, do the following:

#. On the **COMPUTE** > **VIRTUAL MACHINES** tab, click **Create VM**. A window will open where you will need to specify VM parameters.

   .. image:: ../../../images/stor_image70.png
      :align: center
      :class: align-center

#. Specify a name for the new VM.

#. In **Deploy from**, choose **Volume** if you have a boot volume or want to create one. Otherwise, choose **Image**.

#. Depending on your choice, click the pencil icon in the **Volumes** or **Image** section and do one of the following:

   - In the **Images** window, select the ISO image or template and click **Done**.

     .. image:: ../../../images/stor_image71.png
        :align: center
        :class: align-center

     Then, in the **Volumes** window, make sure the default boot volume is large enough to accommodate the guest OS and click **Done**.

   - In the **Volumes** window, do one of the following:

     - If you have prepared a volume with an installed guest OS, click **Attach**, find and select the volume, and click **Done**.

       .. image:: ../../../images/stor_image72.png
          :align: center
          :class: align-center

     - Otherwise, click **Add new**. In the **Add volume** window, specify a name, size in GB, and select a storage policy from the drop-down list. Click **Add**.

       .. image:: ../../../images/stor_image73.png
          :align: center
          :class: align-center

     The top volume in the list is considered bootable. So the first created or attached volume becomes the boot volume by default.

#. Optionally, in the **Volumes** window, click **Add new** or **Attach new** to create or attach any other volumes you need.

   .. image:: ../../../images/stor_image75.png
      :align: center
      :class: align-center

   To select a volume as bootable, place it first in the list by clicking the up arrow button next to it.

#. In the **Flavor** window, choose a flavor and click **Done**.

   .. image:: ../../../images/stor_image76.png
      :align: center
      :class: align-center

#. In the network window, click **Add virtual network**, search for a virtual network interface, select it, and click **Done**.

   .. image:: ../../../images/stor_image74.png
      :align: center
      :class: align-center

   .. not yet in the UI 

      #. In the key management window, select an existing user access key or create a new one:

         #. Click **Add key**, and, in the **Add key** window, choose **Generate new key** or **Import existing key**.
         #. Depending on the choice, specify a **Name** and **Description** or select a key file to import. Click **Add**.

            .. unclear how key import works from mockups. Probably, need to select the key file.

#. Back in the **Create virtual machine** window, click **Deploy** to create and boot the VM.

#. If you are deploying the VM from an ISO image (not a boot volume template or volume with a pre-installed guest OS), select the VM, click **Console**, and install the guest OS using the built-in VNC console.

To remove a VM, select it, click the ellipsis button next to it, **Delete**, and **Remove**. You cannot delete running VMs.

.. _Running, Shutting Down, and Rebooting Virtual Machines:

Running, Shutting Down, and Rebooting Virtual Machines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To start, shut down, reboot, or hard reboot a VM, click the ellipsis button next to it and click the desired action.

.. image:: ../../../images/stor_image77.png
   :align: center
   :class: align-center

The start, shutdown, and reboot operations are equivalent to powering up, shutting down, and soft-rebooting a computer, respectively. The hard reboot operation is equivalent to cutting off and restoring power, then starting a computer.

.. _Suspending, Resuming, and Rebuilding Virtual Machines:

Suspending, Resuming, and Rebuilding Virtual Machines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Virtuozzo Infrastructure Platform allows you to suspend a running VM by saving its current state to a special file. Later on, you can restore VM's state by resuming it. Suspending VMs may prove useful, for example, if you need to restart the host but do not want to:

- quit the applications currently running in the VM,
- spend time on restarting the guest OS.

To rebuild a VM means to redeploy it from the chosen image keeping the same ID, flavor, network interfaces (IP and MAC addresses), and all the volumes except the boot one.

To suspend, resume, or rebuild a VM, click the ellipsis button next to it and click **Suspend**, **Resume**, or **Rebuild**, respectively.


.. _Reconfiguring and Monitoring Virtual Machines:

Reconfiguring and Monitoring Virtual Machines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To monitor virtual machine's CPU, storage, and network usage, select the VM and open the **Overview** tab. To download the VM's console log, click the ellipsis button next to it and **Download console log**.

To reconfigure a VM, select it and, on the **Configuration** tab, click the pencil icon next to a parameter you need to change. You cannot do the following:

- change, detach, or delete the boot volume;
- shrink volumes;
- modify network interfaces when the VM is running;
- downsize the flavor when the VM is running.

  .. note:: You can upsize the flavor when the VM is running if the guest OS supports RAM and CPU hotplugging. Windows 7, 8.1, and 10 do not support either CPU or RAM hotplugging; standard editions of Windows Server do not support RAM hotplugging; and Windows Server 2008 and 2008 R2 do not support CPU hotplugging.

  .. and change security group. Not implemented.

..
    .. _Migrating Virtual Machines:

    Migrating Virtual Machines
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    VSTOR-5573
