リソースタグ

リソースタグ

いくつかの仮想ネットワークリソースは、外部のシステムや Networking サービス API のクライアントが使用できるタグをサポートしています。

The currently supported resources are:

  • networks
  • subnets
  • subnetpools
  • ports
  • routers

ユースケース

The following use cases refer to adding tags to networks, but the same can be applicable to any other supported Networking service resource:

  1. 別の場所にある OpenStack 上の別々のネットワークを論理的な 1 つのネットワークにマッピングする (マルチサイト OpenStack 用)。
  2. 混在環境で、別の管理システムやオーケストレーションシステムが割り当てた ID を OpenStack ネットワークにマッピングする。例えば、 Kuryr プロジェクトでは、 Docker のネットワーク ID が Neutron ネットワーク ID にマッピングされます。
  3. デプロイメントツールがタグを利用する。
  4. プロバイダーネットワークに関する情報をタグ付けする (例えば、広帯域、低遅延など)。

タグによるフィルタリング

この API では、 GET /v2.0/networks API で検索やフィルタリングが可能です。以下の問い合わせパラメーターが使用できます。

  • tags
  • tags-any
  • not-tags
  • not-tags-any

あるタグを持つネットワークの一覧を取得するには、 tags 引数に所望のタグ名を指定します。例:

GET /v2.0/networks?tags=red

2 つ以上のタグを持つネットワークの一覧を取得するには、 tags 引数にタグのリストをコンマ区切りで指定します。この場合、指定されたすべてのタグを持つネットワークが問い合わせの結果として返されます。 “red” と “blue” のタグを持つネットワーク一覧を取得する例:

GET /v2.0/networks?tags=red,blue

指定されたタグのいずれかを持つネットワークの一覧を取得するには、 tags-any 引数にタグのリストをコンマ区切りで指定します。この場合、指定されたタグが 1 つでもあれば、そのネットワークは問い合わせの結果として返されます。 “red” か “blue” のタグを持つネットワーク一覧を取得する例:

GET /v2.0/networks?tags-any=red,blue

指定された 1 つ以上のタグを持たないネットワークの一覧を取得するには、 not-tags 引数にタグのリストをコンマ区切りで指定します。この場合、指定されたタグのいずれかを持たないネットワークだけが問い合わせの結果として返されます。 “red” と “blue” のタグのどちらかを持たないネットワーク一覧を取得する例:

GET /v2.0/networks?not-tags=red,blue

指定されたタグのいずれも持たないネットワークの一覧を取得するには、 not-tags-any 引数にタグのリストをコンマ区切りで指定します。この場合、指定されたタグのいずれも持たないネットワークだけが問い合わせの結果として返されます。 “red” と “blue” のタグのどちらも持たないネットワーク一覧を取得する例:

GET /v2.0/networks?not-tags-any=red,blue

tags, tags-any, not-tags, not-tags-any 引数は組み合わせて、もっと複雑な問い合わせを構成することもできます。例:

GET /v2.0/networks?tags=red,blue&tags-any=green,orange

上記の例では、 “red” と “blue” の両方のタグを持ち、かつ “green” と “orange” のタグの少なくとも 1 つが設定されているネットワークの一覧を取得しています。

複雑な問い合わせでは、矛盾するパラメーターを指定することもできます。例:

GET /v2.0/networks?tags=blue&not-tags=blue

この場合、 Networking サービスにこのようなネットワークを検索させることになります。明らかに、このようなネットワークは存在しないので、空のリストが返されます。

ユーザーのワークフロー

リソースにタグを付与します。

$ neutron tag-add --resource-type network --resource ab442634-1cc9-49e5-bd49-0dac9c811f69 --tag red
$ neutron net-show net
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | True                                 |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| id                      | ab442634-1cc9-49e5-bd49-0dac9c811f69 |
| ipv4_address_scope      |                                      |
| ipv6_address_scope      |                                      |
| mtu                     | 1450                                 |
| name                    | net                                  |
| port_security_enabled   | True                                 |
| router:external         | False                                |
| shared                  | False                                |
| status                  | ACTIVE                               |
| subnets                 |                                      |
| tags                    | red                                  |
| tenant_id               | e6710680bfd14555891f265644e1dd5c     |
+-------------------------+--------------------------------------+

リソースからタグを削除します。

$ neutron tag-remove --resource-type network --resource ab442634-1cc9-49e5-bd49-0dac9c811f69 --tag red
$ neutron net-show net
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | True                                 |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| id                      | ab442634-1cc9-49e5-bd49-0dac9c811f69 |
| ipv4_address_scope      |                                      |
| ipv6_address_scope      |                                      |
| mtu                     | 1450                                 |
| name                    | net                                  |
| port_security_enabled   | True                                 |
| router:external         | False                                |
| shared                  | False                                |
| status                  | ACTIVE                               |
| subnets                 |                                      |
| tags                    |                                      |
| tenant_id               | e6710680bfd14555891f265644e1dd5c     |
+-------------------------+--------------------------------------+

リソースのタグをすべて置き換えます。

$ neutron tag-replace --resource-type network --resource ab442634-1cc9-49e5-bd49-0dac9c811f69 --tag red --tag blue
$ neutron net-show net
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | True                                 |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| id                      | ab442634-1cc9-49e5-bd49-0dac9c811f69 |
| ipv4_address_scope      |                                      |
| ipv6_address_scope      |                                      |
| mtu                     | 1450                                 |
| name                    | net                                  |
| port_security_enabled   | True                                 |
| router:external         | False                                |
| shared                  | False                                |
| status                  | ACTIVE                               |
| subnets                 |                                      |
| tags                    | red                                  |
|                         | blue                                 |
| tenant_id               | e6710680bfd14555891f265644e1dd5c     |
+-------------------------+--------------------------------------+

リソースのタグをクリアします。

$ neutron tag-remove --resource-type network --resource ab442634-1cc9-49e5-bd49-0dac9c811f69 --all
$ neutron net-show net
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | True                                 |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| id                      | ab442634-1cc9-49e5-bd49-0dac9c811f69 |
| ipv4_address_scope      |                                      |
| ipv6_address_scope      |                                      |
| mtu                     | 1450                                 |
| name                    | net                                  |
| port_security_enabled   | True                                 |
| router:external         | False                                |
| shared                  | False                                |
| status                  | ACTIVE                               |
| subnets                 |                                      |
| tags                    |                                      |
| tenant_id               | e6710680bfd14555891f265644e1dd5c     |
+-------------------------+--------------------------------------+

タグフィルターを使ってネットワークの一覧を取得できます。以下の例では、 test-net1 にはタグ “red”、 test-net2 にはタグ “red” と “blue”、 test-net3 にはタグ “red”, “blue”, “green”、 test-net4 にはタグ “green” が付与されています。

tags フィルターを使ってリソース一覧を取得します。

$ neutron net-list --tags red,blue
+--------------------------------------+-----------+---------+
| id                                   | name      | subnets |
+--------------------------------------+-----------+---------+
| 8ca3b9ed-f578-45fa-8c44-c53f13aec05a | test-net3 |         |
| e736e63d-42e4-4f4c-836c-6ad286ffd68a | test-net2 |         |
+--------------------------------------+-----------+---------+

tags-any フィルターを使ってリソース一覧を取得します。

$ neutron net-list --tags-any red,blue
+--------------------------------------+-----------+---------+
| id                                   | name      | subnets |
+--------------------------------------+-----------+---------+
| 30491224-3855-431f-a688-fb29df004d82 | test-net1 |         |
| 8ca3b9ed-f578-45fa-8c44-c53f13aec05a | test-net3 |         |
| e736e63d-42e4-4f4c-836c-6ad286ffd68a | test-net2 |         |
+--------------------------------------+-----------+---------+

not-tags フィルターを使ってリソース一覧を取得します。

$ neutron net-list --not-tags red,blue
+--------------------------------------+-----------+---------+
| id                                   | name      | subnets |
+--------------------------------------+-----------+---------+
| 30491224-3855-431f-a688-fb29df004d82 | test-net1 |         |
| cdb3ed08-ca63-4090-ba12-30b366372993 | test-net4 |         |
+--------------------------------------+-----------+---------+

not-tags-any フィルターを使ってリソース一覧を取得します。

$ neutron net-list --not-tags-any red,blue
+--------------------------------------+-----------+---------+
| id                                   | name      | subnets |
+--------------------------------------+-----------+---------+
| cdb3ed08-ca63-4090-ba12-30b366372993 | test-net4 |         |
+--------------------------------------+-----------+---------+

制限事項

名前にコンマが入ったタグによるリソースのフィルタリングには対応していません。したがって、コンマが入ったタグ名をリソースに付与しないでください。

今後の予定

In future releases, the Networking service may support setting tags for additional resources.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.