4.5. Managing Images

Virtuozzo Infrastructure Platform allows you to upload ISO images and templates that can be used to create VM volumes. An ISO image is a typical OS distribution that needs to be installed on disk. In turn, a template is a ready volume in the QCOW2 format with an installed operating system and applications and a set minimum size. Many OS vendors offer templates of their operating systems under the name “cloud images”. For a list of guest OSes supported in virtual machines, see Supported Guest Operating Systems.

Note

Images are stored according to the default storage policy.

4.5.1. Uploading, Editing, and Removing Images

To add an image, do the following:

  1. On the COMPUTE > Virtual machines > IMAGES tab, click Add image.

  2. In the Add image window, do the following:

    1. Click Browse and select a template or ISO file.

    2. Specify an image name to be shown in the admin panel.

    3. Select a correct OS type from the drop-down list.

      Important

      OS type affects VM parameters like hypervisor settings. VMs created from an image with a wrong OS type may not work correctly, e.g., crash.

    ../_images/stor_image78_vz.png
  3. Optionally, select the Share between all projects checkbox. With the option disabled, the image will only be available in the admin project of the Default domain.

  4. Click Add to upload the image.

The admin panel will show the upload progress.

Important

Do not reload the page while the image is being uploaded or the process will fail.

To edit an image, select it and click the pencil icon next to a parameter you need to change.

To remove an image, click the ellipsis button next to it and Delete.

4.5.2. Creating Volumes from Images

You can create volumes from both ISO images and templates. Do the following:

  1. On the image panel, click Create volume.

  2. In the Create volume window, specify the volume name, size, and choose a storage policy.

    ../_images/stor_image161_vz.png
  3. Click Create.

The new volume will appear on the COMPUTE > Storage > VOLUMES tab.

4.5.3. Mounting ISO Images to Virtual Machines

Note

This feature is supported only for Linux virtual machines. You can, however, mount an ISO image to a Windows VM via the vinfra tool. Use the insructions provided in the section “Installing Guest Tools in Existing Windows VMs” of the Administrator’s Command Line Guide. Replace the guest tools image in the examples with your image.

To mount an ISO image to a Linux VM, do as follows:

  1. Create a volume from the ISO image as described in Creating Volumes from Images.
  2. Attach the resulting volume to the desired VM as described in Attaching and Detaching Volumes.

The mounted disk will appear inside the Linux VM.

4.5.4. Preparing Templates

To be able to connect to a virtual machine via SSH or perform some of the initial configuration tasks, you need to prepare a VM template (or a boot volume for Windows VMs) before creating a VM from it. The steps you need to perform to prepare the VM template differ depending on the guest operating system and are described in the sections below.

4.5.4.1. Preparing Linux Templates

As all Linux guests have OpenSSH Server pre-installed by default, you only need to make sure a Linux template has cloud-init installed.

The easiest way to get a Linux template with cloud-init installed is to obtain it from its official repository or build one with the diskimage-builder tool. (For more information, refer to the section “Creating Linux Templates” in the Administrator’s Command Line Guide.)

4.5.4.2. Preparing Windows Templates

Windows guests have neither Cloudbase-Init nor OpenSSH Server pre-installed by default. You need to install and configure them manually as follows:

Note

If you only need to configure Cloudbase-Init, skip step 4.

  1. Create a VM from a Windows image as described in Creating Virtual Machines.

  2. Log in to the VM and install the guest OS using the built-in VNC console.

  3. Create a new administrator account that will be used for SSH connections and log in with it.

    Important

    You will be able to log in with this account only using the key authentication method.

  4. Install and configure OpenSSH Server as follows:

    1. Run Windows PowerShell with administrator privileges and set the execution policy to unrestricted to be able to run scripts:

      > Set-ExecutionPolicy Unrestricted
      
    2. Download OpenSSH Server (for example, from the GitHub repository), extract the archive into the C:\Program Files directory, and install it by running:

      > & 'C:\Program Files\OpenSSH-Win64\install-sshd.ps1'
      
    3. Start the OpenSSH SSH Server service in the Control Panel > System and Security > Administrative Tools > Services and set its startup type to Automatic:

      ../_images/win_guests_ssh1.png
    4. Open TCP port 22 for the OpenSSH service in the Windows Firewall:

      > New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound \
      -Action Allow -DisplayName OpenSSH
      
    5. Open the C:\ProgramData\ssh\sshd_config file:

      > notepad 'C:\ProgramData\ssh\sshd_config'
      

      Comment out the following lines at the end of the file:

      #Match Group administrators
      #AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
      

      And save the changes.

    6. Create the .ssh directory in C:\Users\<current_user> and an empty authorized_keys file inside it:

      > cd C:\Users\<current_user>
      > mkdir .ssh
      > notepad .ssh\authorized_keys
      

      Remove the .txt extension from the created file:

      > move .\.ssh\authorized_keys.txt .\.ssh\authorized_keys
      
    7. Modify the permissions for the created file to disable inheritance as follows:

      > icacls .ssh\authorized_keys /inheritance:r
      
  5. Download Cloudbase-Init (for example, from the official site), launch the installation, and follow the on-screen instructions:

    1. In the Configuration options window, enter Administrator in the Username field and check Run Cloudbase-Init service as LocalSystem:

      ../_images/win_guests_ssh2.png
    2. When the installation is complete, run Windows PowerShell with administrator privileges and open the file C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\cloudbase-init.conf:

      > notepad 'C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\\
      cloudbase-init.conf'
      

      Add the following lines:

      metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService,\
      cloudbaseinit.metadata.services.httpservice.HttpService,cloudbaseinit.metadata.\
      services.ec2service.EC2Service,cloudbaseinit.metadata.services.maasservice.MaaSHttpService
      plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,cloudbaseinit.plugins.common.\
      sethostname.SetHostNamePlugin,cloudbaseinit.plugins.windows.extendvolumes.\
      ExtendVolumesPlugin,cloudbaseinit.plugins.common.networkconfig.NetworkConfigPlugin
      allow_reboot=false
      

      And save the changes.

    3. Open the file C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\cloudbase-init-unattend.conf:

      > notepad 'C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\\
      cloudbase-init-unattend.conf'
      

      Add cloudbaseinit.plugins.common.networkconfig.NetworkConfigPlugin to the plugins line:

      plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,cloudbaseinit.plugins.common.\
      sethostname.SetHostNamePlugin,cloudbaseinit.plugins.windows.extendvolumes.\
      ExtendVolumesPlugin,cloudbaseinit.plugins.common.networkconfig.NetworkConfigPlugin
      
    4. Finish the Cloudbase-Init installation by selecting the following checkboxes and clicking Finish:

      ../_images/win_guests_ssh3.png

After the VM shuts down, you can either

  • delete it to make its boot volume available for creating new VMs, or
  • convert the VM boot volume to a template (see Creating Images from Volumes).