5.9. OpenSCAP レポートの削除

Satellite Server で、1 つまたは複数の OpenSCAP レポートを削除できます。ただし、レポートは、一度に 1 ページずつしか削除できません。すべての Openscap レポートを削除する場合には、以下のバッシュスクリプトを使用してください。

注記

以下の要求例とスクリプト例では、python3 を使用して Satellite Server からの応答をフォーマットしています。RHEL 7 およびそれ以前の一部のシステムでは、python3 の代わりに python を使用する必要があります。

OpenSCAP レポートの削除

OpenSCAP レポートを削除するには、次の手順を実行します。

  1. 全 OpenSCAP レポートを表示します。削除するレポートの ID をメモしてください。

    要求例:

    curl --insecure --user username:_password_ \
    https://satellite.example.com/api/v2/compliance/arf_reports/ | python3 -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": 29
  2. 1 つ前の手順で取得した 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/ | python3 -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/ | python3 -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