Advanced Examples of OpenStack Image Service (Glance) Usage

If you haven’t tried it already, get a free on-demand trial for Mirantis OpenStack Express, now available.

Glance can be used from the command line to do more than just add an image to a cluster. Here are some examples of what you can do with it.

  • Add an image to glance

glance image-create --name test --min-disk 1 --min-ram 768 --file \ centos-6.5-20140117.0.x86_64.qcow2 --is-public True --property net_model=e1000 --property \ disk_bus=ide --disk-format=qcow2 --container-format ovf --progress

This example makes use of the following arguments:

  --id <IMAGE_ID>    ID of image to reserve.
 --name <NAME>      Name of image.
 --store <STORE>    Store to upload image to.
  --id <IMAGE_ID>    ID of image to reserve.
 --name <NAME>      Name of image.
 --store <STORE>    Store to upload image to.
 --disk-format <DISK_FORMAT>
                    Disk format of image. Acceptable formats: ami,
ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso.
 --container-format <CONTAINER_FORMAT>
                    Container format of image. Acceptable formats:
ami,ari, aki, bare, and ovf.
 --owner <TENANT_ID>   Tenant who should own image.
 --size <SIZE>      Size of image data (in bytes). Only used with
'--location' and '--copy_from'.
 --min-disk <DISK_GB>  Minimum size of disk needed to boot image (in
 --min-ram <DISK_RAM>  Minimum amount of ram needed to boot image
(in megabytes).
 --location <IMAGE_URL>
                    URL where the data for this image already
                    resides. For example, if the image data is
                    stored in swift, you could specify
 --file <FILE>      Local file that contains disk image to be uploaded
                    during creation. Alternatively, images can be passed
                    to the client via stdin.
 --checksum <CHECKSUM>
                    Hash of image data used Glance can use for
                    verification. Provide a md5 checksum here.
 --copy-from <IMAGE_URL>
                    Similar to '--location' in usage, but this indicates
                    that the Glance server should immediately copy the
                    data and store it in its configured image store.
 --is-public [True|False]
                    Make image accessible to the public.
 --is-protected [True|False]
                    Prevent image from being deleted.
 --property <key=value>
                    Arbitrary property to associate with image. May be
                    used multiple times.
 --human-readable   Print image size in a human-friendly format.
 --progress       Show upload progress bar.

It’s possible to set any arbitrary property with the –property flag. This property then appears in the image information:

glance image-show test

To get list of images use the command:

glance image-list

You can find more information on adding images in the official OpenStack documentation.

Other Examples:

  • Creating an image

glance image-create --name "Window Server 2008 R2" --is-public=true --disk-format=qcow2 --container-format=ovf --file WIN2K8R2.qcow2
  • Transferring an image

glance image-create --name MSE-kl-test --disk-format=raw --container-format=bare --is-public=True --property hw_vif_model=e1000 --property hw_disk_bus=ide --file=MSE.raw

When transferring an image from other virtualization platforms, it’s often necessary to maintain non-OpenStack parameters through the –property argument.  For example, this technique can be useful if the image is taken from another platform such as VMware, which in this case includes these values:


These values are saved in the glance database for transfer to the VM parameters when an instances is launched from the image.

  • Delete an image

image-delete {image name}
  • Convert an image to another format

qemu-img convert -f {initial format} -O {target format}  {source file}  {destination file}


qemu-img convert -f vmdk -O qcow2 VM.vmdk VM.qcow2

Want to read more?  This article is an excerpt from our new guide, Mirantis OpenStack Express: Application On-boarding Guide (currently in beta).  Please let us know what you think.

Subscribe to Our Newsletter

Latest Tweets

Suggested Content

Mirantis Application Platform with Spinnaker
How to Increase the Probability of a VNF Working with Your Cloud