10.6. Satellite API を使用したレポートテンプレートのインポート
Satellite API を使用して、レポートテンプレートを Satellite にインポートできます。Satellite API を使用してレポートテンプレートをインポートすると、レポートテンプレートのメタデータが自動的に解析され、組織とロケーションが割り当てられます。Satellite API の使用に関する詳細は、API ガイド を参照してください。
前提条件
.erb
構文を使用してテンプレートを作成するか、別の Satellite からテンプレートをエクスポートしておく。テンプレートの作成に関する詳細は、付録A テンプレート作成の参照 を参照してください。
Satellite からのテンプレートのエクスポートに関する詳細は、「Satellite API を使用したレポートテンプレートのエクスポート」 を参照してください。
手順
以下の例を使用して、
.json
ファイルにインポートするテンプレートをフォーマットします。# cat Example_Template.json { "name": "Example Template Name", "template": " Enter ERB Code Here " }
ERB テンプレートを含む JSON ファイルの例:
{ "name": "Hosts - complete list", "template": " <%# name: Hosts - complete list snippet: false template_inputs: - name: host required: false input_type: user advanced: false value_type: plain resource_type: Katello::ActivationKey model: ReportTemplate -%> <% load_hosts(search: input('host')).each_record do |host| -%> <% report_row( 'Server FQND': host.name ) -%> <% end -%> <%= report_render %> " }
以下のリクエストを使用して、テンプレートをインポートします。
$ curl --insecure --user admin:redhat \ --data @Example_Template.json --header "Content-Type:application/json" \ --request POST --config https://satellite.example.com/api/report_templates/import
以下のリクエストを使用して、レポートテンプレートのリストを取得し、Satellite でテンプレートを表示できることを確認します。
$ curl --insecure --user admin:redhat \ --request GET --config https://satellite.example.com/api/report_templates | json_reformat