Using image metadata

Images have properties known as metadata that help describe the image and how it relates to other OpenStack components. The metadata that is applied to an image can be used to enable specific functionality in other OpenStack services or to determine the scheduling of an instance to a host based on CPU architectures or features, and more.

Setting image metadata

Image metadata in OpenStack can be manipulated using the openstack image set command. The --property argument can be used to set additional properties using the key=value pairs.

Getting ready

When setting image metadata, ensure that you are authenticated as an administrator or are the owner of the image. You will need the following details, at a minimum:

  • Image name or ID
  • Property name and value

For our examples, the following will be used:

  • Image name: COOKBOOK_UBUNTU_IMAGE
  • Property name and value: architecture=m68k, os_distro=ubuntu

How to do it…

With the OpenStack client installed on our system, we are now able to set image metadata with the following command:

openstack image set COOKBOOK_UBUNTU_IMAGE 
--property architecture=m68k 
--property os_distro=ubuntu

No output is returned if the operation is successful. However, using openstack image show will reveal that the properties have been set:

How to do it…

How it works...

When image metadata is set in OpenStack, the properties have an impact on how the system handles instances using that image. Properties such as hypervisor_type and architecture affect how an instance is scheduled to a host, while other properties such as hw_disk_bus and hw_cdrom_bus affect how virtual devices are connected to the instance.

Note

In order to schedule instances based on image metadata, be sure to include the 'ImagePropertiesFilter' filter in the enabled_filters list in /etc/nova/nova.conf. This is a default in most OpenStack installations, including the environment built in this book.

In this environment, booting an instance using the modified image requiring an architecture of m68k (Motorola 68000) should result in the following error:

NoValidHost: No valid host was found. There are not enough hosts available.

Modifying the image to require x86_64 or removing the property altogether should allow the instance to be scheduled according to other defined metadata or environmental defaults.

A current list of image metadata properties at time of writing can be found at the following location:

https://docs.openstack.org/python-glanceclient/latest/cli/property-keys.html

Removing image metadata

Image metadata in OpenStack can be removed using the openstack image unset command. The --property argument can be used to unset individual properties.

Getting ready

When removing image metadata, ensure that you are authenticated as an administrator or are the owner of the image. You will need the following details, at a minimum:

  • Image name or ID
  • Property name

For our examples, the following will be used:

  • Image name: COOKBOOK_UBUNTU_IMAGE
  • Property name: architecture

How to do it…

With the OpenStack client installed on our system, we are now able to unset image metadata with the following command:

openstack image unset COOKBOOK_UBUNTU_IMAGE 
--property architecture

No output is returned if the operation is successful. To verify that the property has been removed, use the openstack image show command.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.246.247