API ガイド
Red Hat Satellite の Representational State Transfer (REST) API 使用ガイド
Red Hat Satellite Documentation Team
satellite-doc-list@redhat.com概要
第1章 はじめに
Red Hat Satellite には Representational State Transfer (REST) API が含まれています。ソフトウェア開発者やシステム管理者は、この API を使用することで、標準の Web インターフェース以外で Red Hat Satellite 環境を制御できるようになります。REST API は、Red Hat Satellite の機能と、HTTP 経由で API にアクセスする外部アプリケーションやカスタムスクリプトと統合することを目的とする開発者や管理者には便利です。
1.1. Red Hat Satellite API の概要
REST API の使用すると、以下のようなメリットがあります。
- 幅広いクライアントサポート: HTTP プロトコルをサポートする各種プログラミング言語、フレームワークまたはシステムで API を使用できます。
- 自己記述型: 詳しい情報の多くはランタイム時に確認できるので、クライアントアプリケーションでは、必要な Red Hat Satellite インフラストラクチャーの情報は最小限で済みます。
- リソースベースのモデル: リソースベースの REST モデルにより仮想化プラットフォームを自然な形で管理することが可能です。
REST API を使用して、以下のタスクを実行できます。
- エンタープライズ IT システムとの統合
- サードパーティー製のアプリケーションとの統合
- 自動メンテナンスやエラーチェックなどのタスクの実行
- スクリプトによる反復タスクの自動化
1.2. Hammer CLI ツールと Satellite API の比較
多くのタスクで、Hammer および Satellite API の両方を使用できます。Hammer は、Satellite API への使いやすいインターフェースとして使用できます。たとえば、API 呼び出しへの応答をテストしてからスクリプトに適用するには、--debug オプションを使用して対象の Hammer の問題 (hammer --debug organization list) が含まれる API 呼び出しを検出します。
各 Hammer コマンドは、バックグラウンドで、先に API へのバインドを確立してから、要求を送信します。これは、API で直接通信するスクリプトとは対照的に、大量の Hammer コマンドを順番に実行する場合には、パフォーマンスに影響が出る可能性があります。そのため API を使用するスクリプトは手動で更新する必要はありますが、Hammer では API の変更は自動的に反映されます。詳しい情報は『Hammer CLI ガイド』を参照してください。
第2章 API リファレンス
包括的な API リファレンスは、お使いの Satellite Server でご確認いただけます (https://satellite6.example.com/apidoc/v2.html)。Satellite 6 API のバージョン 1 と 2 が利用できますが、Red Hat ではバージョン 2 のみをサポートする点に注意してください。
2.1. API 構文の理解
Satellite に含まれている API リファレンスは、HTTP 動詞の後に API ルートまたはパスを記載します。
HTTP_VERB API_ROUTE
API を使用するには、curl コマンド構文と当リファレンスドキュメントの API ルートを使用して、コマンドを構築します。
$ curl --request HTTP_VERB \ 1 --insecure \ 2 --user sat_username:sat_password \ 3 --data @file.json \ 4 --header "Accept:application/json,version=2" \ 5 --header"Content-Type:application/json" \ 6 API_ROUTE \ 7 | python -m json.tool 8
- 1
- API 呼び出しに
curlを使用するには、HTTP 動詞に--requestオプションを指定します (例:--request POST)。 - 2
--insecureオプションを追加して、SSL ピア証明書の検証確認をスキップします。- 3
--userオプションを使用してユーザー認証を指定します。- 4
- 5 6
--dataオプションを指定して JSON データを渡す場合は、--headerオプションを指定して以下のヘッダーを指定する必要があります。詳細情報は、「API 要求への JSON データの指定」を参照してください。- 7
https://satellite6.example.com/katello/api/activation_keys形式の API ルートを使用します。Satellite 6 では、API バージョン 2 がデフォルトであるため、API 呼び出しの URL にv2を使用する必要はありません。- 8
- Python
json.toolモジュールを使用して出力をパイプし、結果のセクションの可読性を高めます。
2.1.1. HTTP 動詞 (GET) の使用
HTTP 動詞 (GET) を使用して、既存のエントリーまたはリソースに関するデータを API から取得します。
例
この例では、Satellite ホストの数を要求します。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/hosts | python -m json.tool
応答例:
{
"total": 2,
"subtotal": 2,
"page": 1,
"per_page": 20,
"search": null,
"sort": {
"by": null,
"order": null
},
"results":
output truncatedAPI からの応答により、結果数が合計 2 つ、これらは結果の 1 ページ目に表示され、ページごとの最大結果数は 20 に設定されていることが分かります。詳しい情報は「JSON 応答形式の理解」を参照してください。
2.1.2. HTTP 動詞 (POST) の使用
HTTP 動詞 (POST) を使用して、データを API に送信してエントリーまたはリソースを作成します。JSON 形式でデータを送信する必要があります。詳細情報は、「API 要求への JSON データの指定」を参照してください。
例
この例では、アクティベーションキーを作成します。
以下のコンテンツを含めて、
activation-key.jsonなどのテストファイルを作成します。{"organization_id":1, "name":"TestKey", "description":"Just for testing"}activation-key.jsonファイルにデータを適用してアクティベーションキーを作成します。要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request POST \ --user sat_username:sat_password --insecure \ --data @activation-key.json \ https://satellite6.example.com/katello/api/activation_keys \ | python -m json.tool
応答例:
{ "id": 2, "name": "TestKey", "description": "Just for testing", "unlimited_hosts": true, "auto_attach": true, "content_view_id": null, "environment_id": null, "usage_count": 0, "user_id": 3, "max_hosts": null, "release_version": null, "service_level": null, "content_overrides": [ ], "organization": { "name": "Default Organization", "label": "Default_Organization", "id": 1 }, "created_at": "2017-02-16 12:37:47 UTC", "updated_at": "2017-02-16 12:37:48 UTC", "content_view": null, "environment": null, "products": null, "host_collections": [ ], "permissions": { "view_activation_keys": true, "edit_activation_keys": true, "destroy_activation_keys": true } }- 新しいアクティベーションキーが存在することを確認します。Satellite Web UI で、コンテンツ > アクティベーションキー に移動して、アクティベーションキーを表示します。
2.1.3. HTTP 動詞 (PUT) の使用
HTTP 動詞 (PUT) を使用して、既存の値を変更するか、既存のリソースに追加します。JSON 形式でデータを送信する必要があります。詳細情報は、「API 要求への JSON データの指定」を参照してください。
例
この例では、1 つ前の例で作成した TestKey アクティベーションキーを更新します。
先ほど作成した
activation-key.jsonファイルを以下のように編集します。{"organization_id":1, "name":"TestKey", "description":"Just for testing","max_hosts":"10" }JSON ファイルの変更を適用します。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request PUT \ --user sat_username:sat_password --insecure \ --data @activation-key.json \ https://satellite6.example.com/katello/api/activation_keys/2 \ | python -m json.tool
応答例:
{ "id": 2, "name": "TestKey", "description": "Just for testing", "unlimited_hosts": false, "auto_attach": true, "content_view_id": null, "environment_id": null, "usage_count": 0, "user_id": 3, "max_hosts": 10, "release_version": null, "service_level": null, "content_overrides": [ ], "organization": { "name": "Default Organization", "label": "Default_Organization", "id": 1 }, "created_at": "2017-02-16 12:37:47 UTC", "updated_at": "2017-02-16 12:46:17 UTC", "content_view": null, "environment": null, "products": null, "host_collections": [ ], "permissions": { "view_activation_keys": true, "edit_activation_keys": true, "destroy_activation_keys": true } }- Satellite Web UI で、コンテンツ > アクティベーションキー に移動して、変更を確認します。
2.1.4. HTTP 動詞 (DELETE) の使用
リソースを削除するには、削除するリソース ID を含む API ルートと DELETE 動詞を使用します。
例
この例では、ID が 2 の TestKey アクティベーションキーを削除します。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request DELETE \ --user sat_username:sat_password --insecure \ https://satellite6.example.com/katello/api/activation_keys/2 \ | python -m json.tool
応答例:
output omitted "started_at": "2017-02-16 12:58:17 UTC", "ended_at": "2017-02-16 12:58:18 UTC", "state": "stopped", "result": "success", "progress": 1.0, "input": { "activation_key": { "id": 2, "name": "TestKey" output truncated
2.1.5. API エラーメッセージと API リファレンスの関連付け
API はエラーの表示に RAILS 形式を使用します。
Nested_Resource.Attribute_Name
これは、API リファレンスで使用する以下の形式に変換されます。
Resource[Nested_Resource_attributes][Attribute_Name_id]
2.2. JSON 応答形式の理解
API への呼び出しは、JSON 形式の結果を返します。API 呼び出しは、単一オプションの応答または、応答コレクションの結果を返します。
単一オブジェクトの JSON 応答形式
単一オブジェクトで作業するには、単一オブジェクトの JSON 応答を使用します。単一のオブジェクトに対する API 要求では、オブジェクトの一位識別子 :id が必要です。
これは、ID が 23 の Satellite ドメインに対する単一オブジェクトの形式例です。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/domains/23 | python -m json.tool
応答例:
{
"id": 23,
"name": "qa.lab.example.com",
"fullname": "QA",
"dns_id": 10,
"created_at": "2013-08-13T09:02:31Z",
"updated_at": "2013-08-13T09:02:31Z"
}コレクション用の JSON 応答形式
コレクションは、ホストとドメインなどのオブジェクト一覧です。JSON 応答コレクションの形式は、メタデータのフィールドセクションと結果セクションで構成されます。
以下は、Satellite ドメイン一覧のコレクション要求の形式例です。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/domains | python -m json.tool
応答例:
{
"total": 3,
"subtotal": 3,
"page": 1,
"per_page": 20,
"search": null,
"sort": {
"by": null,
"order": null
},
"results": [
{
"id": 23,
"name": "qa.lab.example.com",
"fullname": "QA",
"dns_id": 10,
"created_at": "2013-08-13T09:02:31Z",
"updated_at": "2013-08-13T09:02:31Z"
},
{
"id": 25,
"name": "sat.lab.example.com",
"fullname": "SATLAB",
"dns_id": 8,
"created_at": "2013-08-13T08:32:48Z",
"updated_at": "2013-08-14T07:04:03Z"
},
{
"id": 32,
"name": "hr.lab.example.com",
"fullname": "HR",
"dns_id": 8,
"created_at": "2013-08-16T08:32:48Z",
"updated_at": "2013-08-16T07:04:03Z"
}
]
}応答メタデータフィールド
API 応答は、以下のメタデータフィールドを使用します。
-
total: 検索パラメーターなしのオブジェクトの合計数 -
subtotal: 検索パラメーターを指定して返されたオブジェクト数 (検索がない場合には、累計は合計と同じになります) -
page: ページ数 -
per_page: ページごとに返す最大オブジェクト数 -
limit: コレクションの応答で返すオブジェクトの指定数 -
offset: コレクションを返す前に省略するオブジェクト数 -
search:scoped_scoped構文をもとにした検索文字列 sort-
by: API がコレクションをソートするフィールド別に指定します。 -
order」: ソート順 (ASC は昇順、DESC は降順)
-
-
results: オブジェクトのコレクション
第3章 API 呼び出しの認証
Satellite API との対話には、Satellite Server の CA 証明書で SSL 認証するか、有効な Satellite ユーザー認証情報で認証する必要があります。本章では、使用可能な認証方法について説明します。
3.1. SSL 認証の概要
Red Hat Satellite は HTTPS を使用して、Red Hat Satellite Server との通信時に、一定の暗号化およびアイデンティティーの検証を行います。Satellite 6.5 では、SSL 以外の通信はサポートしません。
Red Hat Satellite Server はそれぞれ、自己署名証明書を使用します。この証明書は、暗号化キーを検証するサーバー証明書および、Satellite Server のアイデンティティーを信頼する証明局の役割を果たします。
3.1.1. SSL 認証の設定
以下の手順を使用して、Satellite Server に対する API 要求の SSL 認証を設定します。
手順
以下のオプションのいずれかを使用して、通信に使用する Satellite Server から証明書を取得します。
リモートサーバーからコマンドを実行する場合は、SSH を使用して証明書を取得します。
$ scp root@satellite6.example.com:/var/www/html/pub/katello-server-ca.crt ./Satellite Server で直接コマンドを実行する場合は、証明書を現在のディレクトリーにコピーします。
$ cp /var/www/html/pub/katello-server-ca.crt ./
--cacert katello-server-ca.crtオプションを指定した API 要求を使用し、Satellite Server のアイデンティティーを検証します。$ curl --request GET \ --user sat_username:sat_password \ --header "Accept:application/json" \ --cacert katello-server-ca.crt \ https://satellite6.example.com/katello/api/organizations \ | python -m json.tool
Network Security Services (NSS) データベースを作成して
katello-server-ca.crt証明書を保存します。$ certutil -N -d sql:$HOME/.pki/nssdb
NSS データベースに永続的に証明書を追加します。
$ certutil -d sql:$HOME/.pki/nssdb -A -t TC -n "Red Hat Satellite" \ -i katello-server-ca.crt
--cacertオプションを指定せずに API 要求を入力して、証明書が NSS データベースに存在することを確認します。$ curl --request GET \ --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts
3.2. HTTP 認証の概要
Satellite API への要求には必ず、有効な Satellite ユーザー名とパスワードが必要です。API は HTTP の Basic 認証を使用して、これらの認証情報を暗号化して、Authorization ヘッダーに追加します。Basic 認証に関する詳細情報は、RFC 2617 HTTP Authentication: Basic and Digest Access Authentication を参照してください。要求に適切な Authorization ヘッダーが含まれていない場合には、API は 401 Authorization Required エラーを返します。
Basic 認証では、パスワードをプレーンテキストで送信するなど、機密情報が含まれている可能性のある情報を扱います。REST API には、プレーンテキストの要求をトランスポートレベルで暗号化する HTTPS が必要です。
base64 ライブラリーによっては、暗号化された認証情報を複数行に分け、行末には改行文字を付けることがあります。そのような場合には、ヘッダーが破損し、要求に問題が発生します。認証ヘッダーには、エンコードされた認証情報がヘッダー内に一行で記載されている必要があります。
3.3. OAuth 認証の概要
Basic 認証の代わりに、制限のある OAuth 1.0 認証をサポートしています。これは、プロトコルのバージョン 1.0a の 1-legged OAuth と呼ばれることもあります。
OAuth の設定を確認するには、Satellite Web UI で 管理 > 設定 > 認証 に移動します。OAuth コンシューマーキー は全 OAuth クライアントが使用するトークンです。
Satellite は、OAuth 設定を /etc/foreman/settings.yaml ファイルに保存します。Satellite はアップグレード時にこのファイルへの手動の変更を上書きするので、これらの設定を行うには、satellite-installer スクリプトを使用します。
3.3.1. OAuth の認証
OAuth 設定を変更するには、必要なオプションを指定して satellite-installer を入力します。以下のコマンドを入力して、OAuth 関連のインストーラーオプションすべてを表示します。
# satellite-installer --full-help | grep oauth
OAuthのマッピングの有効化
デフォルトでは、Satellite は、ビルトインの匿名 API 管理者アカウントで、全 OAuth API 要求を認可するため、API 応答には全 Satellite データが含まれます。ただし、要求を行う Foreman ユーザーを指定して、対象ユーザーにデータへのアクセスを制限することも可能です。
OAuth ユーザーマッピングを有効にするには、以下のコマンドを入力します。
# satellite-installer --foreman-oauth-map-users true
Satellite は OAuth 要求のヘッダーを署名しません。有効なコンシューマーキーのあるユーザーは、Foreman ユーザーへのなりすましができてしまいます。
3.3.2. OAuth 要求の形式
OAuth クライアントライブラリーを使用して、全 OAuth パラメーターを構築します。全 OAuth API 要求には、以下の形式で、既存の Foreman ユーザーのログインを指定した FOREMAN-USER ヘッダーと、Authorization ヘッダーが必要です。
--header 'FOREMAN-USER: sat_username' \ --header 'Authorization: OAuth oauth_version="1.0",oauth_consumer_key="secretkey",oauth_signature_method="hmac-sha1",oauth_timestamp=1321473112,oauth_signature=Il8hR8/ogj/XVuOqMPB9qNjSy6E='
例
以下の例では、認証に OAuth を使用したアーキテクチャーが表示されます。この要求では、FOREMAN-USER ヘッダーに sat_username ユーザー名を使用します。--foreman-oauth-map-users を true に設定すると、要求には、そのユーザーに対して表示権限が割り当てられたアーキテクチャーのみが含まれます。署名は、全パラメーター、HTTP メソッドおよび URI 変更を反映します。
要求例:
$ curl 'https://satellite6.example.com/api/architectures' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json,version=2' \ --header 'FOREMAN-USER: sat_username' \ --header 'Authorization: OAuth oauth_version="1.0",oauth_consumer_key="secretkey",oauth_signature_method="hmac-sha1",oauth_timestamp=1321473112,oauth_signature=Il8hR8/ogj/XVuOqMPB9qNjSy6E='
第4章 異なる言語での API 要求
本章では、curl、Ruby および Python を使用して Red Hat Satellite に API 要求を送信する方法を、例と併せて説明します。
4.1. curl を使用した API 要求
本セクションでは、Satellite API で curl を使用して、さまざまなタスクを実行する方法を説明します。
Red Hat Satellite は HTTPS と、デフォルトではホストの識別用に証明書を使用する必要があります。「SSL 認証の概要」の記載どおりに Satellite サーバーの証明書を追加していない場合には、--insecure オプションを使用して証明書チェックを省略することができます。
ユーザー認証の場合は、--user オプションを指定して、--user username:password 形式で、Satellite ユーザー認証情報を指定します。または、パスワードを含めない場合には、コマンドでパスワードを入力するようにプロンプトが表示されます。セキュリティーリスクを軽減するには、コマンドの一部としてパスワードを入力すると、シェルの履歴の一部として残ってしまうので、入力しないようにしてください。本セクションの例では、簡素化の目的でのみ、パスワードを含めています。
--silent オプションを使用する場合は、curl で進捗メーターやエラーメッセージは表示されない点に注意してください。
本章の例では、Python json.tool モジュールを使用して出力をフォーマットしています。
4.1.1. API 要求への JSON データの指定
データを API 要求で Satellite Server に渡すことができます。このデータは、JSON 形式でなければなりません。--data オプションで、JSON データを指定する場合には、--header オプションを使用して、以下の HTTP ヘッダーを設定する必要があります。
--header "Accept:application/json,version=2" \ --header "Content-Type:application/json"
以下のオプションのいずれかを使用して、--data オプションでデータを追加します。
The quoted JSON formatted data enclosed in curly braces
{}. When passing a value for a JSON type parameter, you must escape quotation marks"with backslashes\. For example, within curly braces, you must format"Example JSON Variable"as\"Example JSON Variable\":--date {"id":44, "smart_class_parameter":{"override":"true", "parameter_type":"json", "default_value":"{\"GRUB_CMDLINE_LINUX\": {\"audit\":\"1\",\"crashkernel\":\"true\"}}"}}引用符なしの JSON 形式のデータは、
@マークとファイル名を指定します。--data @_file_.json
JSON 形式データの外部ファイルを使用すると、以下のような利点があります。
- 任意のテキストエディターを使用できる
- 構文チェッカーを使用してミスを特定し、回避できる
- ツールを使用して JSON データの妥当性を確認して、再フォーマットができる
JSON ファイルの検証
json_verify ツールを使用して、JSON ファイルの妥当性を確認します。
$ json_verify < test_file.json4.1.2. リソース一覧の取得
本セクションは、 Satellite 6 API で curl を使用して、Satellite デプロイメントから情報を要求する方法を説明します。これらの例には、要求と応答の両方が含まれます。デプロイメントごとに、異なる結果が得られることが想定されます。
ユーザーの一覧表示
以下の例は、Satellite リソース (今回の例では、Satellite ユーザー) の一覧を返す基本的な要求です。このような要求では、メタデータでラップされたデータ一覧を返しますが、他の要求タイプでは実際のオブジェクトが返されます。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/users | python -m json.tool
応答例:
{
"page": 1,
"per_page": 20,
"results": [
{
"admin": false,
"auth_source_id": 1,
"auth_source_name": "Internal",
"created_at": "2018-09-21 08:59:22 UTC",
"default_location": null,
"default_organization": null,
"description": "",
"effective_admin": false,
"firstname": "",
"id": 5,
"last_login_on": "2018-09-21 09:03:25 UTC",
"lastname": "",
"locale": null,
"locations": [],
"login": "test",
"mail": "example@domain.com",
"organizations": [
{
"id": 1,
"name": "Default Organization"
}
],
"ssh_keys": [],
"timezone": null,
"updated_at": "2018-09-21 09:04:45 UTC"
},
{
"admin": true,
"auth_source_id": 1,
"auth_source_name": "Internal",
"created_at": "2018-09-20 07:09:41 UTC",
"default_location": null,
"default_organization": {
"description": null,
"id": 1,
"name": "Default Organization",
"title": "Default Organization"
},
"description": "",
"effective_admin": true,
"firstname": "Admin",
"id": 4,
"last_login_on": "2018-12-07 07:31:09 UTC",
"lastname": "User",
"locale": null,
"locations": [
{
"id": 2,
"name": "Default Location"
}
],
"login": "admin",
"mail": "root@example.com",
"organizations": [
{
"id": 1,
"name": "Default Organization"
}
],
"ssh_keys": [],
"timezone": null,
"updated_at": "2018-11-14 08:19:46 UTC"
}
],
"search": null,
"sort": {
"by": null,
"order": null
},
"subtotal": 2,
"total": 2
}4.1.3. リソースの作成および変更
本章では、Satellite 6 API で curl を使用して Satellite Server のリソースを操作する方法を説明します。これらの API 呼び出しでは、API 呼び出しの json 形式でデータを渡す必要があります。詳細情報は、「API 要求への JSON データの指定」を参照してください。
ユーザーの作成
以下の例では、--data オプションを使用してユーザーを作成し、必要な情報を指定します。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request POST \ --user sat_username:sat_password --insecure \ --data "{\"firstname\":\"Test Name\",\"mail\":\"test@example.com\",\"login\":\"test_user\",\"password\":\"password123\",\"auth_source_id\":1}" \ https://satellite6.example.com/api/users | python -m json.tool
ユーザーの変更
以下の例では、「ユーザーの作成」で作成した test_user のログインと名前を変更します。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request PUT \ --user sat_username:sat_password --insecure \ --data "{\"firstname\":\"New Test Name\",\"mail\":\"test@example.com\",\"login\":\"new_test_user\",\"password\":\"password123\",\"auth_source_id\":1}" \ https://satellite6.example.com/api/users/8 | python -m json.tool
4.2. Ruby を使用した API 要求
本セクションでは、Satellite API で Ruby を使用して、さまざまなタスクを実行する方法を説明します。
以下は、スクリプトおよびコマンドの例です。以下のスクリプトを慎重にレビューしてから使用するようにしてください。変数、ユーザー名、パスワード、その他の情報は、お使いのデプロイメントに適した値に置き換えてください。
4.2.1. Ruby を使用したオブジェクトの作成
以下のスクリプトは Red Hat Satellite 6 API と接続して、組織を作成し、その新規組織内に 3 つの環境を作成します。組織がすでに存在する場合には、このスクリプトはその組織を使用します。組織内に環境が 1 つでも存在する場合は、スクリプトによりエラーが送出されて、スクリプトは終了します。
#!/usr/bin/ruby
require 'rest-client'
require 'json'
url = 'https://satellite6.example.com/api/v2/'
katello_url = "#{url}/katello/api/v2/"
$username = 'admin'
$password = 'changeme'
org_name = "MyOrg"
environments = [ "Development", "Testing", "Production" ]
# Performs a GET using the passed URL location
def get_json(location)
response = RestClient::Request.new(
:method => :get,
:url => location,
:user => $username,
:password => $password,
:headers => { :accept => :json,
:content_type => :json }
).execute
JSON.parse(response.to_str)
end
# Performs a POST and passes the data to the URL location
def post_json(location, json_data)
response = RestClient::Request.new(
:method => :post,
:url => location,
:user => $username,
:password => $password,
:headers => { :accept => :json,
:content_type => :json},
:payload => json_data
).execute
JSON.parse(response.to_str)
end
# Creates a hash with ids mapping to names for an array of records
def id_name_map(records)
records.inject({}) do |map, record|
map.update(record['id'] => record['name'])
end
end
# Get list of existing organizations
orgs = get_json("#{katello_url}/organizations")
org_list = id_name_map(orgs['results'])
if !org_list.has_value?(org_name)
# If our organization is not found, create it
puts "Creating organization: \t#{org_name}"
org_id = post_json("#{katello_url}/organizations", JSON.generate({"name"=> org_name}))["id"]
else
# Our organization exists, so let's grab it
org_id = org_list.key(org_name)
puts "Organization \"#{org_name}\" exists"
end
# Get list of organization's lifecycle environments
envs = get_json("#{katello_url}/organizations/#{org_id}/environments")
env_list = id_name_map(envs['results'])
prior_env_id = env_list.key("Library")
# Exit the script if at least one life cycle environment already exists
environments.each do |e|
if env_list.has_value?(e)
puts "ERROR: One of the Environments is not unique to organization"
exit
end
end
# Create life cycle environments
environments.each do |environment|
puts "Creating environment: \t#{environment}"
prior_env_id = post_json("#{katello_url}/organizations/#{org_id}/environments", JSON.generate({"name" => environment, "organization_id" => org_id, "prior_id" => prior_env_id}))["id"]
end4.2.2. Ruby での Apipie バインディングの使用
Apipie バインディングは、apipie で記述された API 呼び出しの Ruby バインディングです。このバインディングは、Satellite から API 定義を取得してキャッシュし、オンデマンドで API 呼び出しを生成します。以下の例では、組織を作成し、その新規組織内に 3 つの環境を作成します。組織がすでに存在する場合には、このスクリプトはその組織を使用します。組織内に環境が 1 つでも存在する場合は、スクリプトによりエラーが送出されて、スクリプトは終了します。
#!/usr/bin/tfm-ruby
require 'apipie-bindings'
org_name = "MyOrg"
environments = [ "Development", "Testing", "Production" ]
# Create an instance of apipie bindings
@api = ApipieBindings::API.new({
:uri => 'https://satellite6.example.com/',
:username => 'admin',
:password => 'changeme',
:api_version => 2
})
# Performs an API call with default options
def call_api(resource_name, action_name, params = {})
http_headers = {}
apipie_options = { :skip_validation => true }
@api.resource(resource_name).call(action_name, params, http_headers, apipie_options)
end
# Creates a hash with IDs mapping to names for an array of records
def id_name_map(records)
records.inject({}) do |map, record|
map.update(record['id'] => record['name'])
end
end
# Get list of existing organizations
orgs = call_api(:organizations, :index)
org_list = id_name_map(orgs['results'])
if !org_list.has_value?(org_name)
# If our organization is not found, create it
puts "Creating organization: \t#{org_name}"
org_id = call_api(:organizations, :create, {'organization' => { :name => org_name }})['id']
else
# Our organization exists, so let's grab it
org_id = org_list.key(org_name)
puts "Organization \"#{org_name}\" exists"
end
# Get list of organization's life cycle environments
envs = call_api(:lifecycle_environments, :index, {'organization_id' => org_id})
env_list = id_name_map(envs['results'])
prior_env_id = env_list.key("Library")
# Exit the script if at least one life cycle environment already exists
environments.each do |e|
if env_list.has_value?(e)
puts "ERROR: One of the Environments is not unique to organization"
exit
end
end
# Create life cycle environments
environments.each do |environment|
puts "Creating environment: \t#{environment}"
prior_env_id = call_api(:lifecycle_environments, :create, {"name" => environment, "organization_id" => org_id, "prior_id" => prior_env_id })['id']
end4.3. Python を使用した API 要求
本セクションでは、Satellite API で Python を使用して、さまざまなタスクを実行する方法を説明します。
以下は、スクリプトおよびコマンドの例です。以下のスクリプトを慎重にレビューしてから使用するようにしてください。変数、ユーザー名、パスワード、その他の情報は、お使いのデプロイメントに適した値に置き換えてください。
本セクションのスクリプト例では、REST API との対話に SSL 検証を使用しません。
4.3.1. Python を使用したオブジェクトの作成
以下のスクリプトは Red Hat Satellite 6 API と接続して、組織を作成し、その新規組織内に 3 つの環境を作成します。組織がすでに存在する場合には、このスクリプトはその組織を使用します。組織内に環境が 1 つでも存在する場合は、スクリプトによりエラーが送出されて、スクリプトは終了します。
#!/usr/bin/python
import json
import sys
try:
import requests
except ImportError:
print "Please install the python-requests module."
sys.exit(-1)
# URL to your Satellite 6 server
URL = "https://satellite6.example.com"
# URL for the API to your deployed Satellite 6 server
SAT_API = "%s/katello/api/v2/" % URL
# Katello-specific API
KATELLO_API = "%s/katello/api/" % URL
POST_HEADERS = {'content-type': 'application/json'}
# Default credentials to login to Satellite 6
USERNAME = "admin"
PASSWORD = "changeme"
# Ignore SSL for now
SSL_VERIFY = False
# Name of the organization to be either created or used
ORG_NAME = "MyOrg"
# Name for life cycle environments to be either created or used
ENVIRONMENTS = ["Development", "Testing", "Production"]
def get_json(location):
"""
Performs a GET using the passed URL location
"""
r = requests.get(location, auth=(USERNAME, PASSWORD), verify=SSL_VERIFY)
return r.json()
def post_json(location, json_data):
"""
Performs a POST and passes the data to the URL location
"""
result = requests.post(
location,
data=json_data,
auth=(USERNAME, PASSWORD),
verify=SSL_VERIFY,
headers=POST_HEADERS)
return result.json()
def main():
"""
Main routine that creates or re-uses an organization and
life cycle environments. If life cycle environments already
exist, exit out.
"""
# Check if our organization already exists
org = get_json(SAT_API + "organizations/" + ORG_NAME)
# If our organization is not found, create it
if org.get('error', None):
org_id = post_json(
SAT_API + "organizations/",
json.dumps({"name": ORG_NAME}))["id"]
print "Creating organization: \t" + ORG_NAME
else:
# Our organization exists, so let's grab it
org_id = org['id']
print "Organization '%s' exists." % ORG_NAME
# Now, let's fetch all available life cycle environments for this org...
envs = get_json(
SAT_API + "organizations/" + str(org_id) + "/environments/")
# ... and add them to a dictionary, with respective 'Prior' environment
prior_env_id = 0
env_list = {}
for env in envs['results']:
env_list[env['id']] = env['name']
prior_env_id = env['id'] if env['name'] == "Library" else prior_env_id
# Exit the script if at least one life cycle environment already exists
if all(environment in env_list.values() for environment in ENVIRONMENTS):
print "ERROR: One of the Environments is not unique to organization"
sys.exit(-1)
# Create life cycle environments
for environment in ENVIRONMENTS:
new_env_id = post_json(
SAT_API + "organizations/" + str(org_id) + "/environments/",
json.dumps(
{
"name": environment,
"organization_id": org_id,
"prior": prior_env_id}
))["id"]
print "Creating environment: \t" + environment
prior_env_id = new_env_id
if __name__ == "__main__":
main()4.3.2. Python を使用した APIからの情報要求
以下は、さまざまな API 要求に Pythonを使用するスクリプト例です。
#!/usr/bin/python
import json
import sys
try:
import requests
except ImportError:
print "Please install the python-requests module."
sys.exit(-1)
SAT_API = 'https://satellite6.example.com/api/v2/'
USERNAME = "admin"
PASSWORD = "password"
SSL_VERIFY = False # Ignore SSL for now
def get_json(url):
# Performs a GET using the passed URL location
r = requests.get(url, auth=(USERNAME, PASSWORD), verify=SSL_VERIFY)
return r.json()
def get_results(url):
jsn = get_json(url)
if jsn.get('error'):
print "Error: " + jsn['error']['message']
else:
if jsn.get('results'):
return jsn['results']
elif 'results' not in jsn:
return jsn
else:
print "No results found"
return None
def display_all_results(url):
results = get_results(url)
if results:
print json.dumps(results, indent=4, sort_keys=True)
def display_info_for_hosts(url):
hosts = get_results(url)
if hosts:
for host in hosts:
print "ID: %-10d Name: %-30s IP: %-20s OS: %-30s" % (host['id'], host['name'], host['ip'], host['operatingsystem_name'])
def main():
host = 'satellite6.example.com'
print "Displaying all info for host %s ..." % host
display_all_results(SAT_API + 'hosts/' + host)
print "Displaying all facts for host %s ..." % host
display_all_results(SAT_API + 'hosts/%s/facts' % host)
host_pattern = 'example'
print "Displaying basic info for hosts matching pattern '%s'..." % host_pattern
display_info_for_hosts(SAT_API + 'hosts?search=' + host_pattern)
environment = 'production'
print "Displaying basic info for hosts in environment %s..." % environment
display_info_for_hosts(SAT_API + 'hosts?search=environment=' + environment)
model = 'RHEV Hypervisor'
print "Displaying basic info for hosts with model name %s..." % model
display_info_for_hosts(SAT_API + 'hosts?search=model="' + model + '"')
if __name__ == "__main__":
main()第5章 Red Hat Satellite API の使用
本章では、Red Hat Satellite API を使用して各種タスクを実行する方法をさまざまな例を挙げて説明します。Satellite Server で API を使用するには、ポート 43 の HTTPS を、Capsule Server で API を使用するには、ポート 8443 の HTTPS を使用します。
スクリプト自体で、異なるポートの要件に対応することができます。たとえば、Ruby では Satellite および Capsule の URL を以下のように指定することができます。
url = 'https://satellite6.example.com/api/v2/' capsule_url = 'https://capsule.example.com:8443/api/v2/' katello_url = 'https://satellite6.example.com/katello/api/v2/'
ホストが Satellite Server または Capsule Server にサブスクライブしている場合は、/etc/rhsm/rhsm.conf の [server] セクションのポートエントリーをもとに、API へのアクセスに必要な、正しいポートを判断できます。これらの値を使用してスクリプトを完全に自動化し、使用するポートを検証する必要性をなくします。
本章では、curl を使用して API 要求を送信します。詳細情報は、「curl を使用した API 要求」を参照してください。
本章の例では、Python json.tool モジュールを使用して出力をフォーマットしています。
5.1. ホストの使用方法
ホストのリスト
以下の例では、Satellite ホストのリストを返します。
要求例:
$ curl -request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts | python -m json.tool
応答例:
{
...
"total" => 2,
"subtotal" => 2,
"page" => 1,
"per_page" => 1000,
"search" => nil,
"sort" => {
"by" => nil,
"order" => nil
},
"results" => [
...
}ホストの情報要求
この要求は、satellite6.example.com ホストの情報を返します。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts/satellite6.example.com \ | python -m json.tool
応答例:
{
"all_puppetclasses": [],
"architecture_id": 1,
"architecture_name": "x86_64",
"build": false,
"capabilities": [
"build"
],
"certname": "satellite6.example.com",
"comment": null,
"compute_profile_id": null,
...
}ホストのファクト表示
この要求は、satellite6.example.com ホストの全ファクトを返します。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts/satellite6.example.com/facts \ | python -m json.tool
応答例:
{
...
"results": {
"satellite6.example.com": {
"augeasversion": "1.0.0",
"bios_release_date": "01/01/2007",
"bios_version": "0.5.1",
"blockdevice_sr0_size": "1073741312",
"facterversion": "1.7.6",
...
}パターンが一致するホストの検索
以下のクエリーは、「example」というパターンと一致するホストをすべて返します。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts?search=example \ | python -m json.tool
応答例:
{
...
"results": [
{
"name": "satellite6.example.com",
...
}
],
"search": "example",
...
}環境でのホストの検索
以下のクエリーは、production 環境内の全ホストを返します。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts?search=environment=production \ | python -m json.tool
応答例:
{
...
"results": [
{
"environment_name": "production",
"name": "satellite6.example.com",
...
}
],
"search": "environment=production",
...
}特定のファクト値を含むホストの検索
以下のクエリーでは、RHEV Hypervisor というモデル名のホストがすべて返されます。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts?search=model=\"RHEV+Hypervisor\" \ | python -m json.tool
応答例:
{
...
"results": [
{
"model_id": 1,
"model_name": "RHEV Hypervisor",
"name": "satellite6.example.com",
...
}
],
"search": "model=\"RHEV Hypervisor\"",
...
}ホストの削除
この要求は、名前が host1.example.com のホストを削除します。
要求例:
curl --request DELETE --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts/host1.example.com \ | python -m json.tool
5.2. ライフサイクル環境との作業
Satellite は、アプリケーションのライフサイクルを、ライフサイクル環境に分割します。ライフサイクル環境は、アプリケーションのライフサイクルの各ステージを表します。ライフサイクル環境は、環境パスからリンクされます。リンクされたライフサイクル環境を API で作成するには、prior_id パラメーターを使用します。
https://satellite6.example.com/apidoc/v2/lifecycle_environments.html で、ライフサイクル環境に関する、同梱の API リファレンスを確認できます。API ルートには /katello/api/environments および /katello/api/organizations/:organization_id/environments が含まれます。
ライフサイクル環境の表示
以下の API 呼び出しを使用して、Satellite にある ID が1 のデフォルトの組織に対する現在の全ライフサイクル環境を表示します。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request GET --user sat_username:sat_password --insecure \ https://satellite6.example.com/katello/api/organizations/1/environments \ | python -m json.tool`
応答例:
output omitted "description": null, "id": 1, "label": "Library", "library": true, "name": "Library", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": false, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": null, "successor": null, output truncated
ライフサイクル環境のリンク作成
以下の例を使用して、ライフサイクル環境のパスを作成します。
以下の手順では、ID が 1 のデフォルトのライブラリー環境が、ライフサイクル環境作成の開始点として使用されています。
開始点として使用する既存のライフサイクル環境を選択します。その ID を使用して環境を表示します。今回の例では、ID が
1の環境を使用します。要求例:
$ curl --request GET --user sat_username:sat_password --insecure \ https://satellite6.example.com/katello/api/environments/1 \ | python -m json.tool
応答例:
output omitted "id": 1, "label": "Library", output omitted "prior": null, "successor": null, output truncated
以下のコンテンツを含めて、
life-cycle.jsonなどの JSON ファイルを作成します。{"organization_id":1,"label":"api-dev","name":"API Development","prior":1}priorオプションを1に設定して、ライフサイクル環境を作成します。要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request POST --user sat_username:sat_password --insecure \ --data @life-cycle.json \ https://satellite6.example.com/katello/api/environments \ | python -m json.tool
応答例:
output omitted "description": null, "id": 2, "label": "api-dev", "library": false, "name": "API Development", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 1, "name": "Library" }, output truncated
以下のコマンドの出力では、ライフサイクル環境の ID が
2で、その 1 つ前のライフサイクル環境は1であると分かります。ID が2のライフサイクル環境を使用して、この環境の後継を作成します。以前作成した
life-cycle.jsonファイルを編集して、label、name、priorの値を更新します。{"organization_id":1,"label":"api-qa","name":"API QA","prior":2}priorオプションを2に設定して、ライフサイクル環境を作成します。要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request POST --user sat_username:sat_password --insecure \ --data @life-cycle.json \ https://satellite6.example.com/katello/api/environments \ | python -m json.tool
応答例:
output omitted "description": null, "id": 3, "label": "api-qa", "library": false, "name": "API QA", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 2, "name": "API Development" }, "successor": null, output truncated
以下のコマンドの出力では、ライフサイクル環境の ID が
3で、その 1 つ前のライフサイクル環境は1であると分かります。
ライフサイクル環境の更新
PUT コマンドを使用して、ライフサイクル環境を更新できます。
以下の要求例では、ID が 3 のライフサイクル環境の説明を更新します。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request POST --user sat_username:sat_password --insecure \ --data '{"description":"Quality Acceptance Testing"}' \ https://satellite6.example.com/katello/api/environments/3 \ | python -m json.tool
応答例:
output omitted "description": "Quality Acceptance Testing", "id": 3, "label": "api-qa", "library": false, "name": "API QA", "organization": { "id": 1, "label": "Default_Organization", "name": "Default Organization" }, "permissions": { "destroy_lifecycle_environments": true, "edit_lifecycle_environments": true, "promote_or_remove_content_views_to_environments": true, "view_lifecycle_environments": true }, "prior": { "id": 2, "name": "API Development" }, output truncated
ライフサイクル環境の削除
後継がない前提でライフサイクル環境を削除できます。このような理由から、以下の形式のコマンドを使用して、逆順にライフサイクル環境を削除します。
要求例:
$ curl --request DELETE --user sat_username:sat_password --insecure \ https://satellite6.example.com/katello/api/environments/:id
5.3. Satellite サーバーへのコンテンツのアップロード
以下のセクションでは、Satellite 6 API を使用して Satellite Server に大容量のファイルをアップグレードしてインポートする方法を説明します。このプロセスでは、4 つの手順が含まれます。
- アップロード要求の作成
- コンテンツのアップロード
- コンテンツのインポート
- アップロード要求の削除
The maximum file size that you can upload is 2MB. For information about uploading larger content, see Uploading Content Larger than 2 MB.
手順
アップロード要求を作成します。デプロイメントに適したサンプルパラメーターを変更するようにしてください。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request POST --insecure \ --user sat_username:sat_password --data "{}" \ https://satellite6.example.com/katello/api/repositories/3/content_uploads
以下のコマンドは、
upload_idを返します。応答例:
{"upload_id":"0be156b1-f373-4cad-89d0-924f8f4491d2","_href":"/pulp/api/v2/content/uploads/0be156b1-f373-4cad-89d0-924f8f4491d2/"}コンテンツのアップロード用に
upload_idをメモします。コンテンツをアップロードします。データのアップロード時には、正しい MIME タイプを使用していることを確認します。この API では、Satellite 6 に対する要求にほぼ、
application/jsonの MIME タイプが使用します。upload_idと MIME タイプ、他のパラメーターを組み合わせてコンテンツをアップロードします。要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:multipart/form-data" \ --request PUT --insecure --user sat_username:sat_password \ --data-urlencode "content@/home/sat6user/rpmbuild/RPMS/noarch/python-scripttest-1.1.1-1.fc21.noarch.rpm" \ --data-urlencode offset=0 \ https://satellite6.example.com/katello/api/repositories/3/content_uploads/0be156b1-f373-4cad-89d0-924f8f4491d2
Satellite Server にコンテンツをアップロードした後に、適切なリポジトリーにそのコンテンツをインポートする必要があります。この手順を完了するまで、Satellite Server ではこの新しいコンテンツは認識されません。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request PUT --insecure \ --user sat_username:sat_password \ --data "{\"upload_ids\":[\"0be156b1-f373-4cad-89d0-924f8f4491d2\"]}" \ https://satellite6.example.com/katello/api/repositories/3/import_uploads
コンテンツのアップロードおよびインポートが正常に完了したら、アップロード要求を削除することができます。削除することで、アップロード中にデータが使用した一時的なディスク領域を解放することができます。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request DELETE --insecure \ --user sat_username:sat_password --data "{}" \ https://satellite6.example.com/katello/api/repositories/3/content_uploads/0be156b1-f373-4cad-89d0-924f8f4491d2
Uploading Content Larger than 2 MB
以下の例では、大容量のファイルを複数のチャンクに分割して、アップロード要求の作成、個別ファイルのアップロード、Satellite へのインポートを行ってから、アップロード要求を削除する方法を説明しています。この例は、サンプルのコンテンツ、ホスト名、ユーザー名、ファイル名を使用している点に注意してください。
Use the following example to split your file into 2MB chunks:
$ split --bytes 2MB --numeric-suffixes --suffix-length=1 \ theforeman-foreman-5.0.1.tar.gz foreman_module.
結果ファイルを表示します。
$ ls -la theforeman-foreman-5.0.1.tar.gz foreman_module.* -rw-r--r--. 1 root root 50000 Nov 4 04:42 foreman_module.0 -rw-r--r--. 1 root root 32928 Nov 4 04:42 foreman_module.1 -rw-r--r--. 1 root root 82928 Nov 4 04:41 theforeman-foreman-5.0.1.tar.gz
アップロード要求の作成
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request POST --insecure --user sat_username:sat_password --data "{}" \ https://ibm-vm01.example.com/katello/api/repositories/2/content_uploads応答例:
{"upload_id":"9585528f-07ad-4bb1-9c80-ccece249b2b7","_href":"/pulp/api/v2/content/uploads/9585528f-07ad-4bb1-9c80-ccece249b2b7/"}コンテンツのアップロード用に
upload_idをメモします。Satellite Server に、ファイルのチャンクをアップロードします。以下の例で
offsetパラメーターを使用して、ファイルサイズと関連付けている点に注意してください。要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:multipart/form-data" \ --request PUT --insecure --user sat_username:sat_password \ --data-urlencode "content@foreman_module.0" \ --data-urlencode offset=0 \ https://ibm-vm01.example.com/katello/api/repositories/2/content_uploads/9585528f-07ad-4bb1-9c80-ccece249b2b7
完全なアップロードをリポジトリーにインポートします。
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request PUT --insecure --user sat_username:sat_password \ --data "{\"upload_ids\":[\"9585528f-07ad-4bb1-9c80-ccece249b2b7\"]}" \ https://ibm-vm01.example.com/katello/api/repositories/2/import_uploadsアップロード要求を削除します。
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request DELETE --insecure --user sat_username:sat_password --data "{}" \ https://ibm-vm01.example.com/katello/api/repositories/2/content_uploads/9585528f-07ad-4bb1-9c80-ccece249b2b7Satellite Server で、転送したファイルを確認します。
# ls -la /var/lib/pulp/content/puppet_module/theforeman-foreman-5.0.1.tar.gz -rw-r--r--. 1 apache apache 82928 Nov 4 04:55 /var/lib/pulp/content/puppet_module/theforeman-foreman-5.0.1.tar.gz
元のファイルと転送したファイルを比較して、同じであることを確認します。
$ cmp /var/lib/pulp/content/puppet_module/theforeman-foreman-5.0.1.tar.gz \ theforeman-foreman-5.0.1.tar.gz
5.4. エラータのホストまたはホストコレクションへの適用
API を使用して、エラータをホスト、ホストグループ、またはホストコレクションに適用することができます。以下は、PUT 要求の基本的な構文です。
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request PUT \ --user sat_username:sat_password --insecure \ --data json-formatted-data https://satellite7.example.com
同梱の API ドキュメントを参照して、エラータ適用に使用する URL を検索します。Satellite Web UI で、検索クエリーの形式を確認できます。ホスト > ホストコレクション に移動して、ホストコレクションを選択します。コレクションアクション > エラータのインストール に移動して、検索クエリーボックスの内容を確認します。たとえば、my-collection と呼ばれるホストコレクションの場合は、検索ボックスに host_collection="my-collection" が含まれます。
ホストへのエラータの適用
以下の例では、/katello/api/hosts/bulk/install_content 一括アクションの API URL を使用して、単純な検索に必要な形式を表示します。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request PUT \ --user sat_username:sat_password --insecure \ --data "{\"organization_id\":1,\"included\":{\"search\":\"my-host\"},\"content_type\":\"errata\",\"content\":[\"RHBA-2016:1981\"]}" \ https://satellite6.example.com/api/v2/hosts/bulk/install_content
ホストコレクションへのエラータの適用
以下の例では、Satellite Web UI に表示されているように、検索文字列 host_collection="my-collection" を渡すのに必要なエスケープレベルに注目してください。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request PUT \ --user sat_username:sat_password --insecure \ --data "{\"organization_id\":1,\"included\":{\"search\":\"host_collection=\\\"my-collection\\\"\"},\"content_type\":\"errata\",\"content\":[\"RHBA-2016:1981\"]}" \ https://satellite6.example.com/api/v2/hosts/bulk/install_content
5.5. 詳細検索の使用
Web UI で、クエリーの構築に使用可能な検索用語を判断することができます。Satellite 6 は、範囲内の検索や自動補完機能をサポートします。
たとえば、オペレーティングシステム別にホストを検索するには ホスト > すべてのホスト の順に移動して、検索 テキストボックスをクリックして検索用語の一覧を表示します。オペレーティングシステムの検索用語の一例は os_description で、以下のように API クエリーで使用することができます。
要求例:
$ curl --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/v2/hosts?search=os_description=\"RHEL+Server+6.6\" \ | python -m json.tool
応答例:
{
...
"results": [
{
"name": "satellite6.example.com",
"operatingsystem_id": 1,
"operatingsystem_name": "RHEL Server 6.6",
...
}
],
"search": "os_description=\"RHEL Server 6.6\"",
}5.6. ページネーション制御のある検索の使用
per_page および page ページネーションパラメーターを使用して、API 検索クエリーが返した検索結果を絞り込むことができます。per_page パラメーターは、ページごとに表示する結果数を指定し、page パラメーターは per_page パラメーターの計算に合わせて、どのページを返すかを指定します。
ページネーションパラメーターを指定しない場合に、返す項目数のデフォルト値を 1000 に設定しますが、page パラメーターが指定されている場合には per_page のデフォルト値は 20 が適用されます。
コンテンツビューの表示
以下の例では、複数ページにわたるコンテンツビューの一覧を返します。このリストでは、ページごとにキー 10 個が含まれており、3 ページ目を返します。
要求例:
$ curl --request GET --user sat_username:sat_password \
https://satellite6.example.com/katello/api/content_views?per_page=10&page=3アクティベーションキーの表示
以下の例では、ID が 1 の組織のアクティベーションキー一覧を複数ページで返します。この一覧には、ページごとにキーが 30 個含まれており、2 ページ目が返されます。
要求例:
$ curl --request GET --user sat_username:sat_password \
https://satellite6.example.com/katello/api/activation_keys?organization_id=1&per_page=30&page=2複数ページを返す設定
for loop 構造を使用して、複数ページにわたる結果を取得します。
以下の例では、ページごとに 5 件ずつ表示するコンテンツビュー 3 ページ分の 1 ページを返します。
$ for i in seq 1 3; do \
curl --request GET --user sat_username:sat_password \
https://satellite6.example.com/katello/api/content_views?per_page=5&page=$i; \
done5.7. スマートクラスのオーバーライド
API を使用してスマートパラメーターを検索し、値を指定してクラスのスマートパラメーターを上書きすることができます。変更可能な属性の完全一覧は、https://satellite6.example.com/apidoc/v2/smart_class_parameters/update.html にある同梱の API リファレンスで確認できます。
変更するスマートクラスパラメーターの ID を検索します。
スマートクラスパラメーターすべてを表示します。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/smart_class_parameters
5 など、Puppet クラス ID が分かる場合には、範囲を絞り込むことができます。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/puppetclasses/5/smart_class_parameters
どちらの呼び出しも検索パラメーターに対応します。Satellite Web UI で検索可能なフィールドの全一覧を表示できます。設定 > スマート変数 に移動して、検索クエリーボックスをクリックし、フィールドの一覧を表示します。
特に検索パラメーターで便利なのは、
puppetclass_nameとkeyの 2 つで、特定のパラメーターの検索が可能になります。たとえば、--dataオプションを使用して URL のエンコードデータを渡すことができます。要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ --data 'search=puppetclass_name = access_insights_client and key = authmethod' \ https://satellite6.example.com/api/smart_class_parameters
Satellite は、標準のスコープ指定の検索構文をサポートします。
パラメーターの ID が見つかると、現在の上書き値など、全詳細が表示されます。
要求例:
$ curl --request GET --insecure --user sat_username:sat_password \ https://satellite6.example.com/api/smart_class_parameters/63
パラメーターの値の上書きの有効化
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request PUT --insecure --user sat_username:sat_password \ --data '{"smart_class_parameter":{"override":true}}' \ https://satellite6.example.com/api/smart_class_parameters/63
パラメーターを手動で作成または削除できない点に注意してください。属性の変更のみが可能です。Satellite は、パラメーターは、プロキシーからクラスをインポートすることでのみ作成、削除されます。
カスタムの override matcher を追加します。
要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request PUT --insecure --user sat_username:sat_password \ --data '{"smart_class_parameter":{"override_value":{"match":"hostgroup=Test","value":"2.4.6"}}}' \ https://satellite6.example.com/api/smart_class_parameters/63
上書きの値に関する情報は、
https://satellite6.example.com/apidoc/v2/override_values.htmlを参照してください。上書きの値を削除します。
要求例:
$ curl --request DELETE --user sat_username:sat_password \ https://satellite6.example.com/api/smart_class_parameters/63/override_values/3
5.8. 外部ファイルを使用したスマートクラスパラメーターの変更
外部ファイルを使用すると、JSON データでの作業が簡素化されます。構文が強調されるエディターを使用するので、間違いを回避し、特定しやすくなります。
外部ファイルを使用したスマートクラスパラメーターの変更
以下の例では、MOTD Puppet マニフェストを使用します。
今回の例では、
motdという名前で Puppet クラスを検索します。要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request GET --user sat_user:sat_password --insecure \ https://satellite6.example.com/api/smart_class_parameters?search=puppetclass_name=motd \ | python -m json.tool
以下の出力を検証します。スマートクラスのパラメーターにはそれぞれ、同じ Satellite インスタンスでグローバルとなる ID が割り当てられています。Satellite Server では、
motdクラスのcontentパラメーターはid=3となっています。Puppet クラス名の前に表示される Puppet クラス ID と混同しないようにしてください。応答例:
{ "avoid_duplicates": false, "created_at": "2017-02-06 12:37:48 UTC", # Remove this line. "default_value": "", # Add a new value here. "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": false, # Set the override value totrue. "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values": [], # Remove this line. "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "updated_at": "2017-02-07 11:56:55 UTC", # Remove this line. "use_puppet_default": false, "validator_rule": null, "validator_type": "" }パラメーター ID
3を使用して、motdパラメーター固有の情報を取得して、出力を output_file.json などのファイルにリダイレクトします。要求例:
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" --request GET \ --user sat_user:sat_password --insecure \` https://satellite6.example.com/api/smart_class_parameters/3 \ | python -m json.tool > output_file.json
1 つ前の手順で作成したファイルを、新しいファイル (例:
changed_file.json) にコピーして編集します。:$ cp output_file.json changed_file.json
ファイルで、必要な値を変更します。以下の例では、
motdモジュールのコンテンツパラメーターを変更しますが、これには、overrideオプションをfalseからtrueに変更する必要があります。{ "avoid_duplicates": false, "created_at": "2017-02-06 12:37:48 UTC", # Remove this line. "default_value": "", # Add a new value here. "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": false, # Set the override value totrue. "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values": [], # Remove this line. "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "updated_at": "2017-02-07 11:56:55 UTC", # Remove this line. "use_puppet_default": false, "validator_rule": null, "validator_type": "" }ファイルの編集後に、以下のようになっていることを確認して、変更を保存します。
{ "avoid_duplicates": false, "default_value": "No Unauthorized Access Allowed", "description": "", "hidden_value": "", "hidden_value?": false, "id": 3, "merge_default": false, "merge_overrides": false, "override": true, "override_value_order": "fqdn\nhostgroup\nos\ndomain", "override_values_count": 0, "parameter": "content", "parameter_type": "string", "puppetclass_id": 3, "puppetclass_name": "motd", "required": false, "use_puppet_default": false, "validator_rule": null, "validator_type": "" }Satellite Server への変更を適用します。
$ curl --header "Accept:application/json,version=2" \ --header "Content-Type:application/json" \ --request PUT --user sat_username:sat_password --insecure \ --data @changed_file.json \ https://satellite6.example.com/api/smart_class_parameters/3
5.9. OpenSCAP レポートの削除
Satellite Server で、1 つまたは複数の OpenSCAP レポートを削除できます。ただし、レポートの削除には、一度に 1 ページずつしか削除できません。すべての Openscap レポートを削除する場合には、以下のバッシュスクリプトを使用してください。
OpenSCAP レポートの削除
OpenSCAP レポートを削除するには、次の手順を実行します。
全 OpenSCAP レポートを表示します。削除するレポートの ID をメモしてください。
要求例:
curl --insecure --user username:_password_ \ https://satellite.example.com/api/v2/compliance/arf_reports/ | python -m json.tool
応答例:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3252 0 3252 0 0 4319 0 --:--:-- --:--:-- --:--:-- 4318 { "page": 1, "per_page": 20, "results": [ { "created_at": "2017-05-16 13:27:09 UTC", "failed": 0, "host": "host1.example.com", "id": 404, "othered": 0, "passed": 0, "updated_at": "2017-05-16 13:27:09 UTC" }, { "created_at": "2017-05-16 13:26:07 UTC", "failed": 0, "host": "host2.example.com, "id": 405, "othered": 0, "passed": 0, "updated_at": "2017-05-16 13:26:07 UTC" }, { "created_at": "2017-05-16 13:25:07 UTC", "failed": 0, "host": "host3.example.com", "id": 406, "othered": 0, "passed": 0, "updated_at": "2017-05-16 13:25:07 UTC" }, { "created_at": "2017-05-16 13:24:07 UTC", "failed": 0, "host": "host4.example.com", "id": 407, "othered": 0, "passed": 0, "updated_at": "2017-05-16 13:24:07 UTC" }, ], "search": null, "sort": { "by": null, "order": null }, "subtotal": 29, "total": 291 つ前の手順で取得した ID を使用して、OpenSCAPレポートを削除します。削除する ID ごとに同様の手順を繰り返します。
要求例:
# curl --insecure --user username:_password_ \ --header "Content-Type: application/json" \ --request DELETE https://satellite.example.com/api/v2/compliance/arf_reports/405
応答例:
HTTP/1.1 200 OK Date: Thu, 18 May 2017 07:14:36 GMT Server: Apache/2.4.6 (Red Hat Enterprise Linux) X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff Foreman_version: 1.11.0.76 Foreman_api_version: 2 Apipie-Checksum: 2d39dc59aed19120d2359f7515e10d76 Cache-Control: max-age=0, private, must-revalidate X-Request-Id: f47eb877-35c7-41fe-b866-34274b56c506 X-Runtime: 0.661831 X-Powered-By: Phusion Passenger 4.0.18 Set-Cookie: request_method=DELETE; path=/ Set-Cookie: _session_id=d58fe2649e6788b87f46eabf8a461edd; path=/; secure; HttpOnly ETag: "2574955fc0afc47cb5394ce95553f428" Status: 200 OK Vary: Accept-Encoding Transfer-Encoding: chunked Content-Type: application/json; charset=utf-8
全 OpenSCAP レポートを削除する Bash スクリプトの例
以下の Bash スクリプトを使用して、全 OpenSCAP レポートを削除します。
#!/bin/bash #this script removes all the arf reports from the satellite server #settings USER=username PASS=password URI=https://satellite.example.com #check amount of reports while [ $(curl --insecure --user $USER:$PASS $URI/api/v2/compliance/arf_reports/ | python -m json.tool | grep \"\total\": | cut --fields=2 --delimiter":" | cut --fields=1 --delimiter"," | sed "s/ //g") -gt 0 ]; do #fetch reports for i in $(curl --insecure --user $USER:$PASS $URI/api/v2/compliance/arf_reports/ | python -m json.tool | grep \"\id\": | cut --fields=2 --delimiter":" | cut --fields=1 --delimiter"," | sed "s/ //g") #delete reports do curl --insecure --user $USER:$PASS --header "Content-Type: application/json" --request DELETE $URI/api/v2/compliance/arf_reports/$i done done
付録A API 応答コード
Red Hat Satellite 6 API には、API 呼び出しの HTTP 応答ステータスコードがあります。以下のコードは、Satellite API の全リソースに共通します。
表A.1 API 応答コード
| 応答 | 説明 |
|---|---|
|
200 OK |
show、index、update、delete (GET、PUT、DELETE 要求) などの要求アクションに成功した場合 |
|
201 Created |
create アクション (POST 要求) に成功した場合 |
|
301 Moved Permanently |
Satellite が HTTPS しか使用できないように制限されているにも拘らず、HTTP が試行された時にリダイレクトされる場合 |
|
400 Bad Request |
必要なパラメーターがないか、検索クエリーに無効な構文が含まれている場合 |
|
401 Unauthorized |
ユーザー認証に失敗した場合 (認証情報が不正な場合など) |
|
403 Forbidden |
ユーザーにアクションの実行、リソースの読み込みなど、十分なパーミッションがないか、アクション自体がサポートされていない場合 |
|
404 Not Found |
指定の ID のレコードが存在しない場合。要求のレコードが存在しない場合には show または delete アクションに、関連のレコードの 1 つが存在しない場合には create、update、delete アクションに表示されることがあります。 |
|
409 Conflict |
既存の依存関係が原因でレコードを削除できない場合 (例: ホストのあるホストグループなど) |
|
415 Unsupported Media Type |
HTTP 要求のコンテンツタイプが JSON でない場合 |
|
422 Unprocessable Entity |
バリデーションエラーが原因でエンティティーの作成に失敗した場合。アクションの作成または更新にのみ適用されます。 |
|
500 Internal Server Error |
予期しないサーバーエラーが発生した場合 |
|
503 Service Unavailable |
サーバーが実行されていない場合 |
付録B API パーミッションの表
Red Hat Satellite 6 API は、さまざまなアクションをサポートしますが、それぞれのアクションには固有のパーミッションが必要です。以下の表では、API パーミッション名、そのパーミッションに関連付けられたアクションとリソースタイプを紹介しています。
表B.1 API パーミッションの表
| パーミッション名 | アクション | リソースタイプ |
|---|---|---|
|
view_activation_keys |
|
Katello::ActivationKey |
|
create_activation_keys |
|
Katello::ActivationKey |
|
edit_activation_keys |
|
Katello::ActivationKey |
|
destroy_activation_keys |
|
Katello::ActivationKey |
|
logout |
| |
|
view_architectures |
| |
|
create_architectures |
| |
|
edit_architectures |
| |
|
destroy_architectures |
| |
|
view_audit_logs |
| |
|
view_authenticators |
| |
|
create_authenticators |
| |
|
edit_authenticators |
| |
|
destroy_authenticators |
| |
|
view_bookmarks |
| |
|
create_bookmarks |
| |
|
edit_bookmarks |
| |
|
destroy_bookmarks |
| |
|
download_bootdisk |
| |
|
manage_capsule_content |
|
SmartProxy |
|
view_capsule_content |
|
SmartProxy |
|
view_compute_profiles |
| |
|
create_compute_profiles |
| |
|
edit_compute_profiles |
| |
|
destroy_compute_profiles |
| |
|
view_compute_resources |
| |
|
create_compute_resources |
| |
|
edit_compute_resources |
| |
|
destroy_compute_resources |
| |
|
view_compute_resources_vms |
| |
|
create_compute_resources_vms |
| |
|
edit_compute_resources_vms |
| |
|
destroy_compute_resources_vms |
| |
|
power_compute_resources_vms |
| |
|
console_compute_resources_vms |
| |
|
view_config_groups |
| |
|
create_config_groups |
| |
|
edit_config_groups |
| |
|
destroy_config_groups |
| |
|
view_config_reports |
| |
|
destroy_config_reports |
| |
|
upload_config_reports |
| |
|
view_containers |
|
Container |
|
commit_containers |
|
Container |
|
create_containers |
|
Container |
|
destroy_containers |
|
Container |
|
power_compute_resources_vms |
|
ComputeResource |
|
view_content_hosts |
|
Katello::System |
|
create_content_hosts |
|
Katello::System |
|
edit_content_hosts |
|
Katello::System |
|
destroy_content_hosts |
|
Katello::System |
|
view_content_views |
|
Katello::ContentView |
|
create_content_views |
|
Katello::ContentView |
|
edit_content_views |
|
Katello::ContentView |
|
destroy_content_views |
|
Katello::ContentView |
|
publish_content_views |
|
Katello::ContentView |
|
promote_or_remove_content_views |
|
Katello::ContentView |
|
export_content_views |
|
Katello::ContentView |
|
access_dashboard |
| |
|
view_discovered_hosts |
|
Host |
|
submit_discovered_hosts |
|
Host |
|
auto_provision_discovered_hosts |
|
Host |
|
provision_discovered_hosts |
|
Host |
|
edit_discovered_hosts |
|
Host |
|
destroy_discovered_hosts |
|
Host |
|
view_discovery_rules |
|
DiscoveryRule |
|
create_discovery_rules |
|
DiscoveryRule |
|
edit_discovery_rules |
|
DiscoveryRule |
|
execute_discovery_rules |
|
DiscoveryRule |
|
destroy_discovery_rules |
|
DiscoveryRule |
|
view_domains |
| |
|
create_domains |
| |
|
edit_domains |
| |
|
destroy_domains |
| |
|
view_environments |
| |
|
create_environments |
| |
|
edit_environments |
| |
|
destroy_environments |
| |
|
import_environments |
| |
|
view_external_usergroups |
| |
|
create_external_usergroups |
| |
|
edit_external_usergroups |
| |
|
destroy_external_usergroups |
| |
|
view_external_variables |
| |
|
create_external_variables |
| |
|
edit_external_variables |
| |
|
destroy_external_variables |
| |
|
view_facts |
| |
|
upload_facts |
| |
|
view_filters |
| |
|
create_filters |
| |
|
edit_filters |
| |
|
destroy_filters |
| |
|
view_arf_reports |
| |
|
destroy_arf_reports |
| |
|
create_arf_reports |
| |
|
view_policies |
|
ForemanOpenscap::Policy |
|
edit_policies |
|
ForemanOpenscap::Policy |
|
create_policies |
|
ForemanOpenscap::Policy |
|
destroy_policies |
|
ForemanOpenscap::Policy |
|
assign_policies |
|
ForemanOpenscap::Policy |
|
view_scap_contents |
|
ForemanOpenscap::ScapContent |
|
view_scap_contents |
|
ForemanOpenscap::ScapContent |
|
edit_scap_contents |
|
ForemanOpenscap::ScapContent |
|
create_scap_contents |
|
ForemanOpenscap::ScapContent |
|
destroy_scap_contents |
|
ForemanOpenscap::ScapContent |
|
edit_hosts |
|
Host |
|
edit_hostgroups |
|
Host |
|
view_job_templates |
|
JobTemplate |
|
create_job_templates |
|
JobTemplate |
|
edit_job_templates |
| |
|
edit_job_templates |
| |
|
edit_remote_execution_features |
|
RemoteExecutionFeature |
|
destroy_job_templates |
|
JobTemplate |
|
lock_job_templates |
|
JobTemplate |
|
create_job_invocations |
|
JobInvocation |
|
view_job_invocations |
|
JobInvocation |
|
execute_template_invocation |
TemplateInvocation | |
|
filter_autocompletion_for_template_invocation |
|
TemplateInvocation |
|
view_foreman_tasks |
|
ForemanTasks::Task |
|
edit_foreman_tasks |
|
ForemanTasks::Task |
|
create_recurring_logics |
ForemanTasks::RecurringLogic | |
|
view_recurring_logics |
|
ForemanTasks::RecurringLogic |
|
edit_recurring_logics |
|
ForemanTasks::RecurringLogic |
|
view_globals |
| |
|
create_globals |
| |
|
edit_globals |
| |
|
destroy_globals |
| |
|
view_gpg_keys |
|
Katello::GpgKey |
|
create_gpg_keys |
|
Katello::GpgKey |
|
edit_gpg_keys |
|
Katello::GpgKey |
|
destroy_gpg_keys |
|
Katello::GpgKey |
|
view_host_collections |
|
Katello::HostCollection |
|
create_host_collections |
|
Katello::HostCollection |
|
edit_host_collections |
|
Katello::HostCollection |
|
destroy_host_collections |
|
Katello::HostCollection |
|
edit_classes |
| |
|
create_params |
| |
|
edit_params |
| |
|
destroy_params |
| |
|
view_hostgroups |
| |
|
create_hostgroups |
| |
|
edit_hostgroups |
| |
|
destroy_hostgroups |
| |
|
view_hosts |
| |
|
create_hosts |
| |
|
edit_hosts |
| |
|
destroy_hosts |
| |
|
build_hosts |
| |
|
power_hosts |
| |
|
console_hosts |
| |
|
ipmi_boot |
| |
|
puppetrun_hosts |
| |
|
search_repository_image_search |
|
Docker/ImageSearch |
|
view_images |
| |
|
create_images |
| |
|
edit_images |
| |
|
destroy_images |
| |
|
view_lifecycle_environments |
|
Katello::KTEnvironment |
|
create_lifecycle_environments |
|
Katello::KTEnvironment |
|
edit_lifecycle_environments |
|
Katello::KTEnvironment |
|
destroy_lifecycle_environments |
|
Katello::KTEnvironment |
|
promote_or_remove_content_views_to_environments |
Katello::KTEnvironment | |
|
view_locations |
| |
|
create_locations |
| |
|
edit_locations |
| |
|
destroy_locations |
| |
|
assign_locations |
| |
|
view_mail_notifications |
| |
|
view_media |
| |
|
create_media |
| |
|
edit_media |
| |
|
destroy_media |
| |
|
view_models |
| |
|
create_models |
| |
|
edit_models |
| |
|
destroy_models |
| |
|
view_operatingsystems |
| |
|
create_operatingsystems |
| |
|
edit_operatingsystems |
| |
|
destroy_operatingsystems |
| |
|
view_organizations |
| |
|
create_organizations |
| |
|
edit_organizations |
| |
|
destroy_organizations |
| |
|
assign_organizations |
| |
|
view_ptables |
| |
|
create_ptables |
| |
|
edit_ptables |
| |
|
destroy_ptables |
| |
|
lock_ptables |
| |
|
view_plugins |
| |
|
view_products |
|
Katello::Product |
|
create_products |
|
Katello::Product |
|
edit_products |
|
Katello::Product |
|
destroy_products |
|
Katello::Product |
|
sync_products |
|
Katello::Product |
|
export_products |
|
Katello::Product |
|
view_provisioning_templates |
| |
|
create_provisioning_templates |
| |
|
edit_provisioning_templates |
| |
|
destroy_provisioning_templates |
| |
|
deploy_provisioning_templates |
| |
|
lock_provisioning_templates |
| |
|
user_logout |
| |
|
my_account |
| |
|
api_status |
| |
|
view_puppetclasses |
| |
|
create_puppetclasses |
| |
|
edit_puppetclasses |
| |
|
destroy_puppetclasses |
| |
|
import_puppetclasses |
| |
|
view_realms |
| |
|
create_realms |
| |
|
edit_realms |
| |
|
destroy_realms |
| |
|
view_search |
| |
|
view_cases |
| |
|
attachments |
| |
|
設定 |
| |
|
app_root |
| |
|
view_log_viewer |
| |
|
ログ |
| |
|
rh_telemetry_api |
| |
|
rh_telemetry_view |
| |
|
rh_telemetry_configurations |
| |
|
view_registries |
|
DockerRegistry |
|
view_registries |
|
DockerRegistry |
|
create_registries |
|
DockerRegistry |
|
destroy_registries |
|
DockerRegistry |
|
view_roles |
| |
|
create_roles |
| |
|
edit_roles |
| |
|
destroy_roles |
| |
|
access_settings |
| |
|
view_smart_proxies |
| |
|
create_smart_proxies |
| |
|
edit_smart_proxies |
| |
|
destroy_smart_proxies |
| |
|
view_smart_proxies_autosign |
| |
|
create_smart_proxies_autosign |
| |
|
destroy_smart_proxies_autosign |
| |
|
view_smart_proxies_puppetca |
| |
|
edit_smart_proxies_puppetca |
| |
|
destroy_smart_proxies_puppetca |
| |
|
view_statistics |
| |
|
view_subnets |
| |
|
create_subnets |
| |
|
edit_subnets |
| |
|
destroy_subnets |
| |
|
import_subnets |
| |
|
view_subscriptions |
|
Organization |
|
attach_subscriptions |
|
Organization |
|
unattach_subscriptions |
|
Organization |
|
import_manifest |
|
Organization |
|
delete_manifest |
|
Organization |
|
view_sync_plans |
|
Katello::SyncPlan |
|
create_sync_plans |
|
Katello::SyncPlan |
|
edit_sync_plans |
|
Katello::SyncPlan |
|
destroy_sync_plans |
|
Katello::SyncPlan |
|
view_tasks |
| |
|
view_trends |
| |
|
create_trends |
| |
|
edit_trends |
| |
|
destroy_trends |
| |
|
update_trends |
| |
|
my_organizations |
| |
|
view_usergroups |
| |
|
create_usergroups |
| |
|
edit_usergroups |
| |
|
destroy_usergroups |
| |
|
view_users |
| |
|
create_users |
| |
|
edit_users |
| |
|
destroy_users |
|