- OpenStack Cloud Computing Cookbook(Third Edition)
- Kevin Jackson Cody Bunch Egle Sigler
- 522字
- 2021-07-16 20:39:16
Using image metadata
We can set arbitrary metadata to help describe images and how they are associated to other OpenStack components. This specific data that is set during image creation or updated at a later time can be used to enable specific functionality in other OpenStack services or to simply allow a custom description of the images.
Getting ready
To begin with, ensure you are logged in to our Ubuntu client where we can run the glance
tool. This can be installed using the following command:
sudo apt-get update sudo apt-get install python-glanceclient
Ensure that you have your environment variable set up correctly with our admin
user and password, as created in the previous chapter:
export OS_TENANT_NAME=cookbook export OS_USERNAME=admin export OS_PASSWORD=openstack export OS_AUTH_URL=https://192.168.100.200:5000/v2.0/ export OS_NO_CACHE=1 export OS_KEY=/vagrant/cakey.pem export OS_CACERT=/vagrant/ca.pem
How to do it...
Image metadata can be added, updated, and deleted, as well as used for host scheduling.
Carry out the following steps to update the metadata on the image:
- We first get the image ID for which we want to update metadata. We do this as follows:
glance image-list
- Add metadata to the image and set the
image_state
andos_distro
properties:glance image-update db02ab51-f9a1-4e38-8c3d-22b367962154 --property image_state=available \ --property os_distro=ubuntu
- We get the following output:
Carry out the following steps to delete image properties:
- We first get the image ID for which we want to delete metadata. We do this as follows:
glance image-list
- To remove all the metadata, enter the following command:
glance image-update db02ab51-f9a1-4e38-8c3d-22b367962154 \ --purge-props
Carry out the following steps to delete image properties:
- We first get the image ID for which we want to delete metadata. We do this as follows:
glance image-list
- To remove specific metadata, we need to specify which properties to keep during the update. In this example, we will remove the
image_state
property and any others that might have been set, but we keep theos_distro
property. Note that user-added properties are removed if not specified. The code is as follows:glance image-update db02ab51-f9a1-4e38-8c3d-22b367962154 \ --purge-props --property os_distro=ubuntu
Metadata can be used to determine the scheduling of hosts. For example, if you have hosts with different hypervisor types, you can specify properties to identify on which hypervisor the image may be deployed. Carry out the following steps to enable scheduling based on image metadata:
- We first need to edit the
/etc/nova/nova.conf
file to update the scheduler property:# Scheduler scheduler_default_filters=ImagePropertiesFilter
- Restart
nova
scheduler:sudo stop nova-scheduler sudo start nova-scheduler
- Get the image ID for which we want to update metadata:
glance image-list
- Set
architecture
andhypervisor
type properties, bothkvm
andqemu
will have theqemu
hypervisor type:glance image-update db02ab51-f9a1-4e38-8c3d-22b367962154 \ --property architecture=arm \ --property hypervisor_type=qemu
How it works...
The glance image-update
option in the glance
command allows us to add, modify, and remove custom image properties. The syntax is as follows:
glance image-create [other options] --property <key=value> glance image-update IMAGE_ID --property <key=value>
See also
- Chapter 4, Nova – OpenStack Compute
- Oracle Exadata性能優化
- 神經網絡編程實戰:Java語言實現(原書第2版)
- TypeScript實戰指南
- SQL基礎教程(視頻教學版)
- 軟件架構:Python語言實現
- Mastering Apache Maven 3
- 碼上行動:用ChatGPT學會Python編程
- Mastering Android Development with Kotlin
- Haskell Data Analysis Cookbook
- Android傳感器開發與智能設備案例實戰
- Building Apple Watch Projects
- Pandas入門與實戰應用:基于Python的數據分析與處理
- Django 2.0 入門與實踐
- Opa Application Development
- 區塊鏈技術與智能服務應用