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:
-
Go to the Images section in the project.
-
Click Create image.
-
Select the pool in the new window.
-
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.
-
Enter the image name.
-
Specify the image format when selecting a file or URL as a source.
-
Select the pool segment in which the image will be created (available for images uploaded from file or from URL). In this pool segment, 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 pool segments. For larger images, reupload an image or create a copy ticket specifying the pool and image UUID.
-
Select the operating system.
-
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.
-
Click Create.
The created image will appear in the Image store in the pool 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 pools with multiple storage clusters, you must specify the pool segment 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 pool segments of this pool.
Please note that images less than 16 GB in size will be automatically replicated (copied) to neighboring pool segments. For larger images, reupload an image or create a copy ticket specifying the pool 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 pool segment 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 pool segment 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:
- Create a token to work with the API:
openstack token issue -c id -f value
- 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 pool, 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](https://docs.openstack.org/glance/pike/user/formats.html).
- To upoad the image to the selected pool segment, 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 pool segment 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:
- Stop the server:
openstack server stop <server>
- Browse the list of network volumes:
openstack volume list
- Disconnect the volume from the server:
openstack server remove volume <server> <volume>
- Check if the volume is in available status:
openstack volume list
- 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.