Creating templates

Prerequisites

To create a template from a boot volume

Admin panel

  1. Power off the VM that the original volume is attached to.
  2. Switch to the Compute > Storage > Volumes tab, click volume’s ellipsis button and select Create image.
  3. In the Create image window, enter an image name, and then click Create.

The new image will appear on the Images screen.

Command-line interface

  1. Shut down the VM which boot volume you want to use. For example:

    # vinfra service compute server stop myvm
  2. Find out the boot volume's ID. For example:

    # vinfra service compute server show myvm
    +---------------+--------------------------------------------+
    | Field         | Value                                      |
    +---------------+--------------------------------------------+
    | config_drive  |                                            |
    | created       | 2021-06-10T08:55:53Z                       |
    | description   |                                            |
    | fault         |                                            |
    | flavor        | disk: 0                                    |
    |               | ephemeral: 0                               |
    |               | extra_specs: {}                            |
    |               | original_name: tiny                        |
    |               | ram: 512                                   |
    |               | swap: 0                                    |
    |               | vcpus: 1                                   |
    | ha_enabled    | True                                       |
    | host          | amigai-ac-ve0.vstoragedomain               |
    | host_status   | UP                                         |
    | id            | 6d0fc132-7ea7-41f0-81ca-a4a2b2a2c893       |
    | key_name      |                                            |
    | metadata      | {}                                         |
    | name          | myvm                                       |
    | networks      | - id: bd17c207-5291-4096-be6a-0a8a4bf67792 |
    |               |   ipam_enabled: true                       |
    |               |   ips:                                     |
    |               |   - 192.168.128.100                        |
    |               |   mac_addr: fa:16:3e:6b:6c:83              |
    |               |   name: private                            |
    |               |   spoofing_protection: true                |
    | orig_hostname | amigai-ac-ve0                              |
    | placements    | []                                         |
    | power_state   | SHUTDOWN                                   |
    | project_id    | dfd99654b8c94b939b638f94abb2ad73           |
    | status        | SHUTOFF                                    |
    | task_state    |                                            |
    | updated       | 2021-06-15T11:24:05Z                       |
    | user_data     |                                            |
    | vm_state      | stopped                                    |
    | volumes       | - delete_on_termination: false             |
    |               |   id: 49be1057-c026-494f-b85d-e013728d41bd |
    |               | - delete_on_termination: false             |
    |               |   id: eca9f679-7e35-4768-ad20-9bcb6af6fd59 |
    +---------------+--------------------------------------------+
    

    The first volume in the output is the boot one.

  3. Upload the boot volume to an image specifying the image name. For example:

    # vinfra service compute volume upload-to-image 49be1057-c026-494f-b85d-e013728d41bd \
    --name image_from_volume

The new image will appear in the vinfra service compute image list output:

# vinfra service compute image list
+--------------------------------------+-------------------+-----------+--------+-------------+
| id                                   | name              | size      | status | disk_format |
+--------------------------------------+-------------------+-----------+--------+-------------+
| d51ad587-6524-4685-b54c-56b7f3e0591d | image_from_volume | 171966464 | active | qcow2       |
| cd964608-edef-479e-b10e-9851dbc0b431 | cirros            | 12716032  | active | qcow2       |
+--------------------------------------+-------------------+-----------+--------+-------------+