How to remove OpenSCAP reports using API in Red Hat Satellite 6?

Solution Verified - Updated

Environment

  • Red Hat Satellite 6

Issue

  • What API can be used to remove OpenSCAP reports in Red Hat Satellite 6?

Resolution

  • The following steps can be followed to collect report ids and delete them using the API in Red Hat Satellite 6:

    • List all OpenSCAP reports using the following API:

      # curl --insecure --request GET --user username:password --header "Content-Type:application/json" -k https://satellite.example.com/api/v2/compliance/arf_reports| python3 -m json.tool
      
    • Note the report id from the output of the above API as in following example output:

      ...
      ...
       "results": [
           {
               "created_at": "2024-04-30 19:36:09 UTC",
               "updated_at": "2024-04-30 19:36:09 UTC",
               "reported_at": "2024-04-30 19:36:08 UTC",
               "id": 4086,                                    <<<< Report Id
               "passed": 0,
               "failed": 0,
               "othered": 0,
      ...
      ...
      
    • Use the following API to delete the OpenSCAP report, replacing $id with the noted report id from the above example:

      # curl --insecure --request DELETE --user username:password --header "Content-Type:application/json" -k https://satellite.example.com/api/v2/compliance/arf_reports/$Id | python3 -m json.tool
      
  • If it is required to clean all OpenSCAP reports, following foreman-rake command can be used on the Satellite server:

    # foreman-rake reports:expire report_type=ForemanOpenscap::ArfReport days=0
    
    • where report_type targets OpenSCAP data and days=0 means keeping nothing.

For more KB articles/solutions related to Red Hat Satellite 6.x OpenSCAP Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x OpenSCAP Issues

For more KB articles/solutions related to Red Hat Satellite 6.x API Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x API Issues

SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.