3.6. Managing Images

3.6.1. Creating Images

3.6.1.1. Syntax

usage: vinfra service compute image create [-h] [-f {json,table,value,yaml}]
                                           [-c COLUMN] [--wait]
                                           [--timeout <seconds>]
                                           [--min-disk <size-gb>]
                                           [--min-ram <size-mb>]
                                           [--os-distro <os-distro>]
                                           [--protected]
                                           [--disk-format <disk_format>]
                                           [--container-format <format>]
                                           --file <file>
                                           <image-name>

Create a new compute image.

positional arguments:
  <image-name>          Image name

optional arguments:
  -h, --help            show this help message and exit
  --min-disk <size-gb>  Minimum disk size required to boot from image, in
                        gigabytes
  --min-ram <size-mb>   Minimum RAM size required to boot from image, in
                        megabytes
  --os-distro <os-distro>
                        OS distribution. To list available distributions, run
                        'service compute cluster show'.
  --protected           Protect image from deletion.
  --disk-format <disk_format>
                        Disk format aki,ami,ari,detect,iso,ploop,qcow2,raw,vdi
                        ,vhd,vhdx,vmdk (default: detect)
  --container-format <format>
                        Container format: aki,ami,ari,bare,docker,ovf,ova
                        (default: bare)
  --file <file>         Create image from a local file
...

3.6.1.2. Sample Output

This command creates a task to create a Cirros image from the file at the Cirros website and upload it to Virtuozzo Infrastructure Platform.

# vinfra service compute image create mycirrosimg \
--url http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
Uploading image to server [Elapsed Time: 0:01:01] ... |
+---------+--------------------------------------+
| Field   | Value                                |
+---------+--------------------------------------+
| task_id | 03874663-d03f-4891-a10b-64837e7faf43 |
+---------+--------------------------------------+

Task outcome:

# vinfra task show 03874663-d03f-4891-a10b-64837e7faf43
+---------+------------------------------------------------------------------+
| Field   | Value                                                            |
+---------+------------------------------------------------------------------+
| args    | []                                                               |
| kwargs  | file_path: /mnt/vstorage/vols/datastores/glance/                 |
|         | eca77b47-9e76-44e2-ac97-867a5036f41c.import                      |
|         | os_task_id: aaee0f90-7f1a-422e-822c-02522428c593                 |
| name    | backend.presentation.compute.images.tasks.ImportComputeImageTask |
| result  | id: 179f45ef-c5d6-4270-b0c0-085b542544c5                         |
| state   | success                                                          |
| task_id | 03874663-d03f-4891-a10b-64837e7faf43                             |
+---------+------------------------------------------------------------------+

3.6.2. Listing Images

3.6.2.1. Syntax

usage: vinfra service compute image list [-h] [-f {json,table,value,yaml}]
                                         [-c COLUMN]

List compute images.
...

3.6.2.2. Sample Output

This command lists images available to the compute cluster.

# vinfra service compute image list
+--------------------------------------+-------------+----------+--------+-------------+
| id                                   | name        |     size | status | disk_format |
+--------------------------------------+-------------+----------+--------+-------------+
| 179f45ef-c5d6-4270-b0c0-085b542544c5 | mycirrosimg | 12716032 | active | qcow2       |
| 4741274f-5cca-4205-8f66-a2e89fb346cc | cirros      | 12716032 | active | qcow2       |
+--------------------------------------+-------------+----------+--------+-------------+

3.6.3. Showing Image Details

3.6.3.1. Syntax

usage: vinfra service compute image show [-h] [-f {json,table,value,yaml}]
                                         [-c COLUMN]
                                         <image>

Display compute image details.

positional arguments:
  <image>               Image ID or name
...

3.6.3.2. Sample Output

This command shows the details of the default Cirros image.

# vinfra service compute image show 4741274f-5cca-4205-8f66-a2e89fb346cc
+------------------+-------------------------------------------------------------------+
| Field            | Value                                                             |
+------------------+-------------------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                                  |
| container_format | bare                                                              |
| created_at       | 2018-09-11T13:29:10Z                                              |
| disk_format      | qcow2                                                             |
| file             | /api/v2/compute/images/4741274f-5cca-4205-8f66-a2e89fb346cc/file/ |
| id               | 4741274f-5cca-4205-8f66-a2e89fb346cc                              |
| min_disk         | 1                                                                 |
| min_ram          | 0                                                                 |
| name             | cirros                                                            |
| os_distro        | linux                                                             |
| os_type          | linux                                                             |
| project_id       | 72a5db3a033c403a86756021e601ef34                                  |
| protected        | False                                                             |
| size             | 12716032                                                          |
| status           | active                                                            |
| tags             | []                                                                |
| updated_at       | 2018-09-11T13:29:13Z                                              |
| virtual_size     |                                                                   |
| visibility       | public                                                            |
+------------------+-------------------------------------------------------------------+

3.6.4. Changing Image Parameters

3.6.4.1. Syntax

usage: vinfra service compute image set [-h] [-f {json,table,value,yaml}]
                                        [-c COLUMN] [--min-disk <size-gb>]
                                        [--min-ram <size-mb>]
                                        [--os-distro <os-distro>]
                                        [--protected] [--name <name>]
                                        <image>

Modify compute image parameters.

positional arguments:
  <image>               Image ID or name

optional arguments:
  -h, --help            show this help message and exit
  --min-disk <size-gb>  Minimum disk size required to boot from image, in
                        gigabytes
  --min-ram <size-mb>   Minimum RAM size required to boot from image, in
                        megabytes
  --os-distro <os-distro>
                        OS distribution. To list available distributions, run
                        'service compute cluster show'.
  --protected           Protect image from deletion.
  --name <name>         Image name
...

3.6.4.2. Sample Output

This command protects the default Cirros image and sets the minimum RAM size for it to 1 GB.

# vinfra service compute image set 4741274f-5cca-4205-8f66-a2e89fb346cc --protected --min-ram 1
+------------------+-------------------------------------------------------------------+
| Field            | Value                                                             |
+------------------+-------------------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                                  |
| container_format | bare                                                              |
| created_at       | 2018-09-11T13:29:10Z                                              |
| disk_format      | qcow2                                                             |
| file             | /api/v2/compute/images/4741274f-5cca-4205-8f66-a2e89fb346cc/file/ |
| id               | 4741274f-5cca-4205-8f66-a2e89fb346cc                              |
| min_disk         | 1                                                                 |
| min_ram          | 1                                                                 |
| name             | cirros                                                            |
| os_distro        | linux                                                             |
| os_type          | linux                                                             |
| project_id       | 72a5db3a033c403a86756021e601ef34                                  |
| protected        | True                                                              |
| size             | 12716032                                                          |
| status           | active                                                            |
| tags             | []                                                                |
| updated_at       | 2018-09-12T09:26:29Z                                              |
| virtual_size     |                                                                   |
| visibility       | public                                                            |
+------------------+-------------------------------------------------------------------+

3.6.5. Downloading Images

3.6.5.1. Syntax

usage: vinfra service compute image save [-h] [--file <filename>] <image>

Download a compute image.

positional arguments:
  <image>            Image ID or name

optional arguments:
  -h, --help         show this help message and exit
  --file <filename>  File to save the image to (default: stdout)

3.6.5.2. Sample Output

This command downloads the default Cirros image to the local disk as cirros.qcow2.

# vinfra service compute image save 4741274f-5cca-4205-8f66-a2e89fb346cc --file cirros.qcow2
Operation successful

3.6.6. Deleting Images

3.6.6.1. Syntax

usage: vinfra service compute image delete [-h] <image>

Delete a compute image.

positional arguments:
  <image>     Image ID or name
...

3.6.6.2. Sample Output

This command deletes the image with the ID 179f45ef-c5d6-4270-b0c0-085b542544c5.

# vinfra service compute image delete 179f45ef-c5d6-4270-b0c0-085b542544c5
Operation successful