Using Glance

Using Glance

Glance is the basic tool for image manipulation.  Here are some of the most common usages. Most of these usages depend on the uuid of an image. The uuid can be found by clicking on an image’s name on the Images tab of the dashboard.

Glance Commands

glance show <uuid> - Displays all the information about an image.

$ glance show feafb7fd-ed42-4363-a441-123ab4f88c2 
URI: http://<internal_glance_service_address>/v1/images/feafb7fd-ed42-4363-a441-123ab24f88c2 Id: feafb7fd-ed42-4363-a441-123ab24f88c2 
Public: Yes 
Protected: No 
Name: <Image Name> 
Status: active Size: 80530636800 
Disk format: raw 
Container format: bare 
Minimum Ram Required (MB): 0 Minimum Disk Required (GB): 0 
Owner: 912412bd8793c818a95490d0776f8026b

glance image-update <uuid> <args> - Updates information about an image. This is the command used to rename images as well as changing their visibility.  The example below will set a new name for the image as well as making it publicly usable by all users. There are a few caveats for glance image-update. One highlighted below is that the Public: field as shown by glance show is manipulated by is-public on the command line. Another is that any additional properties set on an image and dropped and replaced by only what is specified in the glance image-update command.

$ glance image-update b99265fe-1263-4ba8-9e9d-745eb2b5f099 --name Windows XP Professional x86 v2 --is-public True

glance image-create - Adds a new image to the system. Below is an example of the process our technical team has been using for Windows images.  For AMI-based images there are actually three images that need to be uploaded.  Please reference the AMI section below for additional information.

$ glance image-create --name "Windows XP x86" --disk_format raw --container_format bare --is-public False < operating_system_image-flat.vmdk

One useful option for glance image-create is the --copy_from argument which allows for a remote source (http, S3, or swift) to be specified for the image source.  

$ glance image-create --name ”Image name” --disk_format qcow2 --container_format bare --is-public False --copy_from ”http://your.web.server/path/to/image”

glance (index|details) - Index and Details return brief or detailed information about the images in the glance database.

glance image-delete <uuid> - Deletes an image from the glance database.  This can also be done from the dashboard.

Member Commands

Member commands are used to control access to images in a manner that is more fine-grained than the global is_public metadata flag.

glance member-list <image uuid> - Displays the sharing permissions by image or tenant.

glance member-create <image uuid> <member id> - Grants a member access to an image.

glance member-delete <image uuid> <member id> -  Revokes a member’s access to an image

Working with AMIs

AMI-based images are actually three distinct images: the kernel image (AKI), the ramdisk image (ARI), and the disk image itself (AMI). Looking at an AMI image, you will see the AKI and ARI associated with that AMI listed as additional properties.

$ glance show 84bd2ab9-9a38-4216-9ce2-2c32df9f1369
URI: http://<glance_api_host>:9292/v1/images/84bd2ab9-9a38-4216-9ce2-2c32df9f1369
Id: 84bd2ab9-9a38-4216-9ce2-2c32df9f1369
Public: Yes
Protected: No
Name: centos_image
Status: active
Size: 53687091200
Disk format: ami
Container format: ami
Minimum Ram Required (MB): 0
Minimum Disk Required (GB): 0
Owner: c23f8331bfc14a728c9f98bba1a42e26
Property 'ramdisk_id': 985dae83-18b8-4da4-acbf-cbd4f20fcbe8
Property 'kernel_id': d403e607-13ab-4afb-8c5a-8fcaafd0a469

When using the glance image-update command to manipulate an AMI-based image, it is important to remember to always include these properties as part of the command, or they will be removed.

$ glance image-update 84bd2ab9-9a38-4216-9ce2-2c32df9f1369 --is-public False --property ramdisk_id=’985dae83-18b8-4da4-acbf-cbd4f20fcbe8’ --property kernel_id=’d403e607-13ab-4afb-8c5a-8fcaafd0a469’

When adding AMIs, add the three images separately and link the ARI and AKI to the AMI when you add the AMI.

$ glance image-create --container_format aki --disk_format aki --name "my_aki" < /path/to/aki
$ glance image-create --container_format ari --disk_format ari --name "my_ari" < /path/to/ari
$ glance image-create --property kernel_id=<aki image uuid> --property ramdisk_id=<ari image uuid> --container_format ami --disk_format ami --name "my_ami" < /path/to/ami

Snapshots

Snapshots are also images, but have a few extra properties assigned to them.  Looking at a snapshot with the glance show command:

$ glance show 8ff21a3c-1234-4a3f-95b4-afc1d6c0748a
URI: http://<internal_glance_service_address>/v1/images/8ff21a3c-1234-4a3f-95b4-afc1d6c0748a
Id: 8ff21a3c-1234-4a3f-95b4-afc1d6c0748a
Public: No
Protected: No
Name: test1
Status: active
Size: 80530636800
Disk format: raw
Container format: bare
Minimum Ram Required (MB): 0
Minimum Disk Required (GB): 0
Owner: 912406c31056426c95490d0776f8026b
Property 'instance_uuid': 5744a049-1234-4c68-bf1d-405cee6fb9db
Property 'image_location': snapshot
Property 'image_state': available
Property 'user_id': 3371840cb22d401234ac5ab3397cd71a
Property 'image_type': snapshot
Property 'owner_id': 912406c31243123495490d0776f8026b

One caveat of the glance image-update command is that it does not retain the extra Property fields.  This means you need to explicitly set each property field when using glance image-update on a snapshot.  For example, to rename the snapshot above:

$ glance image-update 8ff21a3c-c515-4a3f-95b4-afc1d6c0748a --name "RenamedTestSnapshot" --property instance_uuid="5744a049-2385-4c68-bf1d-405cee6fb9db" --property image_location="snapshot" --property image_state="available" --property user_id="3371840cb22d405ca9ac5ab3397cd71a" --property image_type="snapshot" --property owner_id="912406c31056426c95490d0776f8026b"

To verify the change with glance show:

$ glance show 8ff21a3c-c515-4a3f-95b4-afc1d6c0748a
URI: http://<internal_glance_service_address>/v1/images/8ff21a3c-c515-4a3f-95b4-afc1d6c0748a
Id: 8ff21a3c-c515-4a3f-95b4-afc1d6c0748a
Public: No
Protected: No
Name: RenamedTestSnapshot
Status: active
Size: 80530636800
Disk format: raw
Container format: bare
Minimum Ram Required (MB): 0
Minimum Disk Required (GB): 0
Owner: 912406c31056426c95490d0776f8026b
Property 'instance_uuid': 5744a049-2385-4c68-bf1d-405cee6fb9db
Property 'image_location': snapshot
Property 'image_state': available
Property 'user_id': 3371840cb22d405ca9ac5ab3397cd71a
Property 'image_type': snapshot
Property 'owner_id': 912406c31056426c95490d0776f8026b

To promote a snapshot to an image, we can take advantage of the automatic dropping of properties and run a glance update without adding the properties to the command line:

$ glance image-update 8ff21a3c-c515-4a3f-95b4-afc1d6c0748a

This causes glance to drop all of the additional properties, and the snapshot is now treated as an image.  Remember, if you are doing this with an AMI-based snapshot, you need to preserve the kernel_id and ramdisk_id properties by including them on the command line.

$ glance show 8ff21a3c-c515-4a3f-95b4-afc1d6c0748a
URI: http://<internal_glance_service_address>/v1/images/8ff21a3c-c515-4a3f-95b4-afc1d6c0748a Id: 8ff21a3c-c515-4a3f-95b4-afc1d6c0748a Public: No Protected: No Name: RenamedTestSnapshot Status: active Size: 80530636800 Disk format: raw Container format: bare Minimum Ram Required (MB): 0 Minimum Disk Required (GB): 0 Owner: 912406c31056426c95490d0776f8026b
Have more questions? Submit a request
Powered by Zendesk