8.6. Satellite API を使用したレポートテンプレートのインポート

Satellite API を使用して、レポートテンプレートを Satellite にインポートできます。Satellite API を使用してレポートテンプレートをインポートすると、レポートテンプレートのメタデータが自動的に解析され、組織とロケーションが割り当てられます。Satellite API の使用に関する詳細は、API Guide を参照してください。

前提条件

手順

  1. 以下の例を使用して、.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 %>
    "
    }

  2. 以下のリクエストを使用して、テンプレートをインポートします。

    $ 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
  3. 以下のリクエストを使用して、レポートテンプレートの一覧を取得し、Satellite でテンプレートを表示できることを確認します。

    $ curl --insecure --user admin:redhat \
     --request GET --config https://satellite.example.com/api/report_templates | json_reformat