Atom feed of this document
  
 

 Manage images

The cloud operator assigns roles to users. Roles determine who can upload and manage images. The operator might restrict image upload and management to only cloud administrators or operators.

You can upload images through the glance client or the Image Service API. You can also use the nova client to list images, set and delete image metadata, delete images, and take a snapshot of a running instance to create an image. After you upload an image, you cannot change it.

For details about image creation, see the Virtual Machine Image Guide.

 List or get details for images (glance)

To get a list of images and to then get further details about a single image, use glance image-list and glance image-show.

$ glance image-list
+--------------------------------------+---------------------------------+-------------+------------------+----------+--------+
| ID                                   | Name                            | Disk Format | Container Format | Size     | Status |
+--------------------------------------+---------------------------------+-------------+------------------+----------+--------+
| 397e713c-b95b-4186-ad46-6126863ea0a9 | cirros-0.3.2-x86_64-uec         | ami         | ami              | 25165824 | active |
| df430cc2-3406-4061-b635-a51c16e488ac | cirros-0.3.2-x86_64-uec-kernel  | aki         | aki              | 4955792  | active |
| 3cf852bd-2332-48f4-9ae4-7d926d50945e | cirros-0.3.2-x86_64-uec-ramdisk | ari         | ari              | 3714968  | active |
| 7e5142af-1253-4634-bcc6-89482c5f2e8a | myCirrosImage                   | ami         | ami              | 14221312 | active |
+--------------------------------------+---------------------------------+-------------+------------------+----------+--------+
$ glance image-show myCirrosImage

+---------------------------------------+--------------------------------------+
| Property                              | Value                                |
+---------------------------------------+--------------------------------------+
| Property 'base_image_ref'             | 397e713c-b95b-4186-ad46-6126863ea0a9 |
| Property 'image_location'             | snapshot                             |
| Property 'image_state'                | available                            |
| Property 'image_type'                 | snapshot                             |
| Property 'instance_type_ephemeral_gb' | 0                                    |
| Property 'instance_type_flavorid'     | 2                                    |
| Property 'instance_type_id'           | 5                                    |
| Property 'instance_type_memory_mb'    | 2048                                 |
| Property 'instance_type_name'         | m1.small                             |
| Property 'instance_type_root_gb'      | 20                                   |
| Property 'instance_type_rxtx_factor'  | 1                                    |
| Property 'instance_type_swap'         | 0                                    |
| Property 'instance_type_vcpu_weight'  | None                                 |
| Property 'instance_type_vcpus'        | 1                                    |
| Property 'instance_uuid'              | 84c6e57d-a6b1-44b6-81eb-fcb36afd31b5 |
| Property 'kernel_id'                  | df430cc2-3406-4061-b635-a51c16e488ac |
| Property 'owner_id'                   | 66265572db174a7aa66eba661f58eb9e     |
| Property 'ramdisk_id'                 | 3cf852bd-2332-48f4-9ae4-7d926d50945e |
| Property 'user_id'                    | 376744b5910b4b4da7d8e6cb483b06a8     |
| checksum                              | 8e4838effa1969ad591655d6485c7ba8     |
| container_format                      | ami                                  |
| created_at                            | 2013-07-22T19:45:58                  |
| deleted                               | False                                |
| disk_format                           | ami                                  |
| id                                    | 7e5142af-1253-4634-bcc6-89482c5f2e8a |
| is_public                             | False                                |
| min_disk                              | 0                                    |
| min_ram                               | 0                                    |
| name                                  | myCirrosImage                        |
| owner                                 | 66265572db174a7aa66eba661f58eb9e     |
| protected                             | False                                |
| size                                  | 14221312                             |
| status                                | active                               |
| updated_at                            | 2013-07-22T19:46:42                  |
+---------------------------------------+--------------------------------------+

When viewing a list of images, you can also use grep to filter the list, as follows:

$ glance image-list | grep 'cirros'
| 397e713c-b95b-4186-ad46-6126863ea0a9 | cirros-0.3.2-x86_64-uec         | ami         | ami              | 25165824 | active |
| df430cc2-3406-4061-b635-a51c16e488ac | cirros-0.3.2-x86_64-uec-kernel  | aki         | aki              | 4955792  | active |
| 3cf852bd-2332-48f4-9ae4-7d926d50945e | cirros-0.3.2-x86_64-uec-ramdisk | ari         | ari              | 3714968  | active |
[Note]Note

To store location metadata for images, which enables direct file access for a client, update the /etc/glance/glance.conf file with the following statements:

  • show_multiple_locations = True

  • filesystem_store_metadata_file = filePath, where filePath points to a JSON file that defines the mount point for OpenStack images on your system and a unique ID. For example:

    [{
        "id": "2d9bb53f-70ea-4066-a68b-67960eaae673",
        "mountpoint": "/var/lib/glance/images/"
    }]

After you restart the Image Service, you can use the following syntax to view the image's location information:

$ glance --os-image-api-version=2 image-show imageID

For example, using the image ID shown above, you would issue the command as follows:

$ glance --os-image-api-version=2 image-show 2d9bb53f-70ea-4066-a68b-67960eaae673

 Create or update an image (glance)

To create an image, use glance image-create:

$ glance image-create imageName

To update an image by name or ID, use glance image-update:

$ glance image-update imageName

The following table lists the optional arguments that you can use with the create and update commands to modify image properties. For more information, refer to Image Service chapter in the OpenStack Command-Line Interface Reference.

--name NAME

The name of the image.

--disk-format DISK_FORMAT

The disk format of the image. Acceptable formats are ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso.

--container-format CONTAINER_FORMAT

The container format of the image. Acceptable formats are ami, ari, aki, bare, and ovf.

--owner TENANT_ID

The tenant who should own the image.

--size SIZE

The size of image data, in bytes.

--min-disk DISK_GB

The minimum size of the disk needed to boot the image, in gigabytes.

--min-ram DISK_RAM

The minimum amount of RAM needed to boot the image, in megabytes.

--location IMAGE_URL

The URL where the data for this image resides. For example, if the image data is stored in swift, you could specify swift://account:[email protected]/container/obj.

--file FILE

Local file that contains the disk image to be uploaded during the update. Alternatively, you can pass images to the client through stdin.

--checksum CHECKSUM

Hash of image data to use for verification.

--copy-from IMAGE_URL

Similar to --location in usage, but indicates that the image server should immediately copy the data and store it in its configured image store.

--is-public [True|False]

Makes an image accessible for all the tenants.

--is-protected [True|False]

Prevents an image from being deleted.

--property KEY=VALUE

Arbitrary property to associate with image. This option can be used multiple times.

--purge-props

Deletes all image properties that are not explicitly set in the update request. Otherwise, those properties not referenced are preserved.

--human-readable

Prints the image size in a human-friendly format.

The following example shows the command that you would use to upload a CentOS 6.3 image in qcow2 format and configure it for public access:

$ glance image-create --name centos63-image --disk-format=qcow2 \
  --container-format=bare --is-public=True --file=./centos63.qcow2

The following example shows how to update an existing image with a properties that describe the disk bus, the CD-ROM bus, and the VIF model:

$ glance image-update \
    --property hw_disk_bus=scsi \
    --property hw_cdrom_bus=ide \
    --property hw_vif_model=e1000 \
    f16-x86_64-openstack-sda

Currently the libvirt virtualization tool determines the disk, CD-ROM, and VIF device models based on the configured hypervisor type (libvirt_type in /etc/nova/nova.conf). For the sake of optimal performance, libvirt defaults to using virtio for both disk and VIF (NIC) models. The disadvantage of this approach is that it is not possible to run operating systems that lack virtio drivers, for example, BSD, Solaris, and older versions of Linux and Windows.

If you specify a disk or CD-ROM bus model that is not supported, see Table 2.2, “Disk and CD-ROM bus model values”. If you specify a VIF model that is not supported, the instance fails to launch. See Table 2.3, “VIF model values”.

The valid model values depend on the libvirt_type setting, as shown in the following tables.

Table 2.2. Disk and CD-ROM bus model values
libvirt_type setting Supported model values
qemu or kvm

  • virtio

  • scsi

  • ide

  • virtio

xen
  • xen

  • ide

Table 2.3. VIF model values
libvirt_type setting Supported model values
qemu or kvm

  • virtio

  • ne2k_pci

  • pcnet

  • rtl8139

  • e1000

xen
  • netfront

  • ne2k_pci

  • pcnet

  • rtl8139

  • e1000

vmware

  • VirtualE1000

  • VirtualPCNet32

  • VirtualVmxnet

 Create an image (nova)

You can use the nova client to take a snapshot of a running instance to create an image.

To minimize the potential for data loss and ensure that you create an accurate image, you should shut down the instance before you take a snapshot.

You cannot create a snapshot from an instance that has an attached volume. Detach the volume, create the image, and remount the volume.

  1. Write any buffered data to disk.

    For more information, see Taking Snapshots in the OpenStack Operations Guide.

  2. List instances to get the server name:

    $ nova list
    +--------------------------------------+----------------------+--------+------------+-------------+------------------+
    | ID                                   | Name                 | Status | Task State | Power State | Networks         |
    +--------------------------------------+----------------------+--------+------------+-------------+------------------+
    | 84c6e57d-a6b1-44b6-81eb-fcb36afd31b5 | myCirrosServer       | ACTIVE | None       | Running     | private=10.0.0.3 |
    +--------------------------------------+----------------------+--------+------------+-------------+------------------+

    In this example, the server is named myCirrosServer.

  3. Use this server to create a snapshot:

    $ nova image-create myCirrosServer myCirrosImage

    The command creates a qemu snapshot and automatically uploads the image to your repository. Only the tenant that creates the image has access to it.

  4. Get details for your image to check its status:

    $ nova image-show myCirrosImage
    +-------------------------------------+--------------------------------------+
    | Property                            | Value                                |
    +-------------------------------------+--------------------------------------+
    | metadata owner_id                   | 66265572db174a7aa66eba661f58eb9e     |
    | minDisk                             | 0                                    |
    | metadata instance_type_name         | m1.small                             |
    | metadata instance_type_id           | 5                                    |
    | metadata instance_type_memory_mb    | 2048                                 |
    | id                                  | 7e5142af-1253-4634-bcc6-89482c5f2e8a |
    | metadata instance_type_root_gb      | 20                                   |
    | metadata instance_type_rxtx_factor  | 1                                    |
    | metadata ramdisk_id                 | 3cf852bd-2332-48f4-9ae4-7d926d50945e |
    | metadata image_state                | available                            |
    | metadata image_location             | snapshot                             |
    | minRam                              | 0                                    |
    | metadata instance_type_vcpus        | 1                                    |
    | status                              | ACTIVE                               |
    | updated                             | 2013-07-22T19:46:42Z                 |
    | metadata instance_type_swap         | 0                                    |
    | metadata instance_type_vcpu_weight  | None                                 |
    | metadata base_image_ref             | 397e713c-b95b-4186-ad46-6126863ea0a9 |
    | progress                            | 100                                  |
    | metadata instance_type_flavorid     | 2                                    |
    | OS-EXT-IMG-SIZE:size                | 14221312                             |
    | metadata image_type                 | snapshot                             |
    | metadata user_id                    | 376744b5910b4b4da7d8e6cb483b06a8     |
    | name                                | myCirrosImage                        |
    | created                             | 2013-07-22T19:45:58Z                 |
    | metadata instance_uuid              | 84c6e57d-a6b1-44b6-81eb-fcb36afd31b5 |
    | server                              | 84c6e57d-a6b1-44b6-81eb-fcb36afd31b5 |
    | metadata kernel_id                  | df430cc2-3406-4061-b635-a51c16e488ac |
    | metadata instance_type_ephemeral_gb | 0                                    |
    +-------------------------------------+--------------------------------------+

    The image status changes from SAVING to ACTIVE. Only the tenant who creates the image has access to it.

To launch an instance from your image, include the image ID and flavor ID, as in the following example:

$ nova boot newServer --image 7e5142af-1253-4634-bcc6-89482c5f2e8a \
   --flavor 3
+-------------------------------------+--------------------------------------+
| Property                            | Value                                |
+-------------------------------------+--------------------------------------+
| OS-EXT-STS:task_state               | scheduling                           |
| image                               | myCirrosImage                        |
| OS-EXT-STS:vm_state                 | building                             |
| OS-EXT-SRV-ATTR:instance_name       | instance-00000007                    |
| flavor                              | m1.medium                            |
| id                                  | d7efd3e4-d375-46d1-9d57-372b6e4bdb7f |
| security_groups                     | [{u'name': u'default'}]              |
| user_id                             | 376744b5910b4b4da7d8e6cb483b06a8     |
| OS-DCF:diskConfig                   | MANUAL                               |
| accessIPv4                          |                                      |
| accessIPv6                          |                                      |
| progress                            | 0                                    |
| OS-EXT-STS:power_state              | 0                                    |
| OS-EXT-AZ:availability_zone         | nova                                 |
| config_drive                        |                                      |
| status                              | BUILD                                |
| updated                             | 2013-07-22T19:58:33Z                 |
| hostId                              |                                      |
| OS-EXT-SRV-ATTR:host                | None                                 |
| key_name                            | None                                 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None                                 |
| name                                | newServer                            |
| adminPass                           | jis88nN46RGP                         |
| tenant_id                           | 66265572db174a7aa66eba661f58eb9e     |
| created                             | 2013-07-22T19:58:33Z                 |
| metadata                            | {}                                   |
+-------------------------------------+--------------------------------------+

 Troubleshoot image creation

If you encounter problems in creating an image in Image Service or Compute, the following information may help you troubleshoot the creation process.

  • You cannot create a snapshot from an instance that has an attached volume. Detach the volume, create the image, and re-mount the volume.

  • Ensure that the version of qemu you are using is version 0.14 or later. Earlier versions of qemu result in an unknown option -s error message in the nova-compute.log file.

  • Examine the /var/log/nova-api.log and /var/log/nova-compute.log log files for error messages.

Questions? Discuss on ask.openstack.org
Found an error? Report a bug against this page

loading table of contents...