Creating Images

If there is no applicable image among the prebuilt ones, upload your own image.

Creating Images in the Control Panel

To create a new image in the Control panel:

  1. Go to the Images section in the project.
  2. Click Create image.
  3. Select the region in the new window.
  4. Select the source that the image will be created from:
    • from file — uploading an image file from the local computer;
    • from URL — a link to the image file accessible on the Internet;
    • from volume — creating an image from a previously created volume.
  5. Enter the image name.
  6. Specify the image format when selecting a file or URL as a source.
  7. In some regions, you can select the availability zone in which the image will be created (available for images uploaded from file or from URL). In this zone, network volumes and VMs from image will be created faster.

    Please note that images less than 16 GB in size will be automatically replicated (copied) to neighboring availability zones. For larger images, reupload an image or create a copy ticket specifying the region and image UUID.

  8. Select the operating system.

  9. When checking the There are requirements for a server box, the fields will appear to determine the minimum vCPU and RAM amount. These restrictions will subsequently be used by the Control panel and API to determine the suitability of the selected VM configuration for starting from this image.

  10. Click Create.

The created image will appear in the Image store in the region where it was created.

Creating Images Through CLI

Using Console Clients for uploading images allows you to specify the properties necessary for fine-tuning of the virtual machine. Learn more about getting started with the OpenStack CLI.

When creating an image from an external source (file or link) in the Cloud platform regions with multiple storage clusters, you must specify the availability zone in which this image will be used initially. This means that creating network volumes and VMs with a local disk will be optimized over time for the period of background image synchronization between storage locations in the availability zones of this region.

Please note that images less than 16 GB in size will be automatically replicated (copied) to neighboring availability zones. For larger images, reupload an image or create a copy ticket specifying the region and image UUID.

Uploading Images from URL

To create an image by uploading from URL, enter the following:

glance image-create-via-import \
 --import-method web-download \
 --uri <uri_image> \
 --name <image_name> \
 --disk-format <disk_format> \
 --container-format <container_format> \
 --property hw_disk_bus=scsi \
 --property hw_scsi_model=virtio-scsi \
 --property x_sel_image_owner=Selectel \
 --property hw_qemu_guest_agent=yes
 --store <zone_name>

Where:

  • <uri_image> is the URL link to the image;
  • <image_name> is the image name;
  • <disk_format> is the volume (image) format;
  • <container_format> is the container format. Learn more about volume and container formats;
  • <zone_name> is the name of the zone to which the image will be uploaded, for example ru-1a.

Uploading Images from File

To upload an image from a file of the local machine:

glance image-create \
 --name <image_name> \
 --disk-format <disk_format> \
 --container-format <container_format> \
 --file <file> \
 --property hw_disk_bus=scsi \
 --property hw_scsi_model=virtio-scsi \
 --store <zone_name>

Where:

  • <image_name> is the image name;
  • <disk_format> is the volume (image) format;
  • <container_format> is the container format. Learn more about volume and container formats;
  • <file> — local file;
  • <zone_name> is the name of the zone to which the image will be uploaded, for example ru-1a.

To create an image in ISO format:

glance image-create ISO_IMAGE \
 --disk-format iso \
 --container-format bare \
 --file <iso_file> \
 --property hw_disk_bus=scsi \
 --property hw_scsi_model=virtio-scsi
 --store <zone_name>

Uploading Large Images from File

Use curl when uploading large images (over 100 GB). Use the sequence of commands to upload a large image from file:

  1. Create a token to work with the API:

    openstack token issue -c id -f value
  2. Enter the following command:

    curl 'https://api.<region>.selvpc.ru/image/v2/images' \
    -H 'X-Auth-Token: <token>' \
    -H 'Content-Type: application/json;charset=utf-8' \
    --data {"name":"<image_name>","disk_format":"<disk_format>","container_format":"<container_format>"}'

    Where:

    • <region> is the name of the Cloud platform region, for example, ru-1;
    • <token> is a token for working with the API received after the first command output;
    • <image_name> is the image name;
    • <disk_format> is the volume (image) format; формат диска (образа);
    • <container_format> is the data format of a loaded volume. Learn more about volume and container formats.
  3. To upoad the image to the selected zone, enter the following:

    curl 'https://api.<region>.selvpc.ru/image/v2/images/<image_id_from_first_request>/file' -X PUT \
    -H 'Content-Type: application/octet-stream' \
    -H ‘X-Image-Meta-Store: <zone_name>’ \
    -H 'X-Auth-Token: <token>' \
    -T <path_to_file>

    Where:

    • <image_id_from_first_request> is the created image identifier from the previous command;
    • <zone_name> is the name of the zone to which the image will be uploaded, for example, ru-1a;
    • <path_to_file> is the path to the file on volume.

Uploading Images from Volume

Disconnect the volume from the virtual machine to create a consistent image from volume. A less reliable but more convenient option is to create a temporary volume from the snapshot of the main volume without stopping the VM.

Creating images from a network volume

To create an image from a network volume:

  1. Stop the server:

    openstack server stop <server>
  2. Browse the list of network volumes:

    openstack volume list
  3. Disconnect the volume from the server:

    openstack server remove volume <server> <volume>
  4. Check if the volume is in available status:

    openstack volume list
  5. Create an image from a network volume:

    openstack image create --volume <volume> <image_name>

Creating images from a cloud server with a local volume

To create an image from a cloud server (virtual machine) with a local volume, enter the following:

openstack server image create --name <image_name> <server>

Read more about volume operations in the article.