Images

OpenStack images can often be thought of as "virtual machine templates." Images can also be standard installation media such as ISO images. Essentially, they contain bootable file systems that are used to launch instances.

 Adding Images

Several premade images exist and can easily be imported into the Image Service. A common image to add is the CirrOS image, which is very small and used for testing purposes. To add this image, simply do:

$ wget http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img
$ glance image-create --name='cirros image' --is-public=true \
    --container-format=bare --disk-format=qcow2 < cirros-0.3.1-x86_64-disk.img

The glance image-create command provides a large set of options for working with your image. For example, the min-disk option is useful for images that require root disks of a certain size (for example, large Windows images). To view these options, do:

$ glance help image-create

The location option is important to note. It does not copy the entire image into the Image Service, but references an original location where the image can be found. Upon launching an instance of that image, the Image Service accesses the image from the location specified.

The copy-from option copies the image from the location specified into the /var/lib/glance/images directory. The same thing is done when using the STDIN redirection with < such as shown in the example.

Run the following command to view the properties of existing images:

$ glance details

 Sharing Images Between Projects

In a multitenant cloud environment, users sometimes want to share their personal images or snapshots with other projects. This can be done on the command line with the glance tool by the owner of the image.

To share an image or snapshot with another project, do the following:

  1. Obtain the UUID of the image:

    $ glance image-list
  2. Obtain the UUID of the project with which you want to share your image. Unfortunately, nonadmin users are unable to use the keystone command to do this. The easiest solution is to obtain the UUID either from an administrator of the cloud or from a user located in the project.

  3. Once you have both pieces of information, run the glance command:

    $ glance member-create <image-uuid> <project-uuid>

    For example:

    $ glance member-create 733d1c44-a2ea-414b-aca7-69decf20d810 \
        771ed149ef7e4b2b88665cc1c98f77ca

    Project 771ed149ef7e4b2b88665cc1c98f77ca will now have access to image 733d1c44-a2ea-414b-aca7-69decf20d810.

 Deleting Images

To delete an image, just execute:

$ glance image-delete <image uuid>
[Note]Note

Deleting an image does not affect instances or snapshots that were based on the image.

 Other CLI Options

A full set of options can be found using:

$ glance help

or the OpenStack Image Service CLI Guide. (http://docs.openstack.org/cli/quick-start/content/glance-cli-reference.html)

 The Image Service and the Database

The only thing that the Image Service does not store in a database is the image itself. The Image Service database has two main tables:

  • images

  • image_properties

Working directly with the database and SQL queries can provide you with custom lists and reports of images. Technically, you can update properties about images through the database, although this is not generally recommended.

 Example Image Service Database Queries

One interesting example is modifying the table of images and the owner of that image. This can be easily done if you simply display the unique ID of the owner. This example goes one step further and displays the readable name of the owner:

mysql> select glance.images.id,
                glance.images.name, keystone.tenant.name, is_public from
                glance.images inner join keystone.tenant on
                glance.images.owner=keystone.tenant.id;

Another example is displaying all properties for a certain image:

mysql> select name, value from
                image_properties where id = <image_id>
Questions? Discuss on ask.openstack.org
Found an error? Report a bug against this page

loading table of contents...