はじめに

OpenStack Compute のクラウドは、仮想マシンイメージ (「仮想アプライアンス」と言う人もいます) がなければ、あまり便利ではありません。このガイドでは、OpenStack と互換性のある仮想マシンイメージを取得、作成、編集する方法を説明します。

簡単のため、「仮想マシンイメージ」の代わりに「イメージ」という言葉をときどき使用します。

仮想マシンイメージとは何でしょうか?

仮想マシンイメージは、ブート可能なオペレーティングシステムがインストールされた仮想ディスクを格納した、単一のファイルです。

イメージのディスク形式とコンテナー形式

Virtual machine images come in different formats. A format describes the way the bits making up a file are arranged on the storage medium. Knowledge of a format is required in order for a consumer to interpret the content of the file correctly (rather than to simply view it as a bunch of bits).

When considering a stored virtual machine image, there are two types of format that can come into play.

コンテナーフォーマット

The stored file may be a container that contains the virtual disk. For example, the virtual disk may be contained in a tar file which must be opened before the disk can be retrieved. It's possible, however, that the virtual disk is not contained in a file, but is just stored as-is by the Image Service.

ディスクフォーマット

The virtual disk itself has its bits arranged in some format. A consuming service must know what this format is before it can effectively use the virtual disk.

イメージメタデータ

Image metadata (also known as "image properties") provide information about the virtual disk stored by the Image service. The metadata is stored as part of the image record associated with the image data by the Image service. Image metadata can help end users determine the nature of an image, and is used by associated OpenStack components and drivers which interface with the Image service.

So that image consumers can easily identify the container and disk format of images, the image service has set aside particular metadata keys for these. Not surprisingly, these are named container_format and disk_format. The legal values for each of these are specified in the Image service's Image schema, which you can obtain in any OpenStack installation by making the following API call:

GET /v2/schemas/image

The supported formats may vary across OpenStack clouds. The formats accepted by a particular cloud will be specified in that cloud's get-schema response to the Images API.

注釈

The image schema lists the legal identifiers for container and disk formats. To understand what these identifiers refer to, consult the Disk and Container Formats section of the Glance User Guide.

Image metadata can also determine the scheduling of hosts. If specific metadata are set on an image (possible metadata are architecture, hypervisor type, and virtual machine mode), and Compute is configured so that the ImagePropertiesFilter scheduler filter is enabled (default), then the scheduler only considers compute hosts that satisfy the specified properties.

注釈

Compute's ImagePropertiesFilter value is specified in the enabled_filters value in the [filter_scheduler] section of the /etc/nova/nova.conf file.

Other Compute scheduler filters may also be affected by image metadata. For a complete list of valid property keys and values, refer to the Useful image properties section of the Glance Administration Guide.

Adding metadata to an image

openstack image createopenstack image set コマンドに --property key=value パラメーターを使用することにより、Image サービスのイメージにメタデータを追加できます。複数のプロパティを指定できます。例:

$ openstack image set --property architecture=arm \
  --property hypervisor_type=qemu image_name_or_id

Common image properties are also specified in the /etc/glance/schema-image.json file. Other useful property keys and values, are listed in the Useful image properties section of the Glance Administration Guide.

すべての関連するイメージのプロパティーは、openstack image show コマンドを使用して表示できます。例:

$ openstack image show cirros
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6                     |
| container_format | bare                                                 |
| created_at       | 2016-04-15T13:57:38Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/55f0907f-70a5-4376-a346-432e4ec509ed/file |
| id               | 55f0907f-70a5-4376-a346-432e4ec509ed                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | cirros                                               |
| owner            | f9574e69042645d6b5539035cb8c00bf                     |
| properties       | architecture='arm', hypervisor_type='qemu'           |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 13287936                                             |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2016-04-15T13:57:57Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+

注釈

Volume-from-Image プロパティ

Block Storage のボリュームをイメージから作成した場合、イメージのプロパティを設定することを考慮します。イメージの主要プロパティを変更する場合、Block Storage の設定も更新すべきです。すべてのコントローラーノードで /etc/cinder/cinder.conf ファイルの glance_core_properties を修正して、Image Service に設定した主要プロパティを一致させます。

Metadata definition (metadefs) service

Images are not the only OpenStack resource that can have metadata associated with them. Many other resources (for example, volumes) support setting metadata on the resources. As with images, the metadata may be consumed by humans to understand something about the resource, or may be used by other OpenStack services so that they can make efficient use of the resource (for example, the nova filter scheduler using the image architecture property to determine an appropriate host on which to build an instance from that image). Thus it is important that there be a discoverable way for people and services to determine what metadata properties and values are available throughout an OpenStack cloud.

To facilitate this, Glance (the OpenStack Image service) hosts a metadata definition service, which is also known as the OpenStack metadefs catalog.

このサービスを用いると、以下の項目を定義できます。

名前空間
  • メタデータ定義を含みます。

  • 名前空間に定義されている全項目に対するアクセス権を指定します。これらのアクセス制御は、名前空間において定義できる人、使用できる人を決定します。

  • 定義をさまざまなリソースの種別と関連づけます。

プロパティー

シングルプロパティーと主制約。各プロパティーは、プリミティブ形式のみになれます。例えば、string、integer、number、boolean、array。

オブジェクト

1 対多のプロパティーのグループとその主制約を説明します。グループの各プロパティーは、プリミティブ形式のみになれます。例えば、string、integer、number、boolean、array。

オブジェクトは、オブジェクトを使用する場合、すべての必要なプロパティーを提供すべき意味的な解釈の下で、必要なプロパティーをオプションとして定義できます。

リソース種別の割り当て

リソース種別と名前空間に適用できる関係性を指定します。この情報は、ドライブ UI と CLI ビューのために使用されます。例えば、同じ名前空間のオブジェクト、プロパティー、タグが、イメージ、スナップショット、ボリューム、フレーバーのために使用できます。または、名前空間がイメージのみに適用される可能性があります。

Image サービスは、メタデータ定義カタログのために、事前定義された名前空間を持ちます。データベースの中に、このディレクトリーからファイルをロードするために、次を実行します。

$ glance-manage db_load_metadefs

データベースからファイルを取り出します。

$ glance-manage db_unload_metadefs

定義を JSON 形式でエクスポートします。

$ glance-manage db_export_metadefs

注釈

デフォルトで、ファイルは Image service の /etc/glance /metadefs ディレクトリーから読み込まれ、そこに書き込まれます。

There is no special relationship between the Image service and the Metadefs service. If you want to apply the keys and values defined in the Metadefs service to images, you must use the Image service API or client tools just as you would for any other OpenStack service.

For more information about the OpenStack Metadefs catalog, see: