Este contenido no está disponible en el idioma seleccionado.
Chapter 4. Exporting inventory data
You can use the export service for inventory to export a list of systems and their data from your Insights inventory. You can specify CSV or JSON as the output format. The export process takes place asynchronously, so it runs in the background.
The service is available in both the Insights UI and through the export service API.
The exported content includes the following information about each system in your inventory:
-
host_id -
fqdn(Fully Qualified Domain Name) -
display_name -
group_id -
group_name -
state -
os_release -
updated -
subscription_manager_id -
satellite_id -
tags -
host_type
The export service currently exports information about all systems in your inventory. Support for filters will be available in a future release.
The Inventory export service works differently from the export function in other services, such as Advisor. Some of the differences are:
- Inventory export operates asynchronously
- Exports the entire inventory to one continuous file (no pagination in the export file)
- Retains generated files for 7 days
- Uses token-based service accounts for authorization if using the export service API
Your RBAC permissions affect the system information you can export. You must have inventory:hosts:read permission for a system to export system information.
4.1. Inventory data files Copiar enlaceEnlace copiado en el portapapeles!
The inventory export process creates and downloads a zip file. The zip file contains the following files:
-
id.suffix— the export data file, with the file name format ofid.jsonfor JSON files, orid.csvfor CSV files. For example:f26a57ac-1efc-4831-9c26-c818b6060ddf.json -
README.md— the export manifest for the JSON/CSV file, which lists the downloaded files, any errors, and instructions for obtaining help -
meta.json— describes the export operation — requestor, date, Organization ID, and file metadata (such as the filename of the JSON/CSV file)
4.2. Exporting system inventory from the Insights UI Copiar enlaceEnlace copiado en el portapapeles!
You can export inventory data from the Insights UI. The inventory data export service works differently from the export service for other Insights services, such as Advisor.
Prerequisites
RBAC permissions for the systems you want to view and export
- Inventory:hosts:read (inventory:hosts:read * for all systems in inventory)
- A User Access role for workspaces. For more information about User Access roles, see User access to workspaces.
Procedure
- Navigate to Inventory > Systems. The list of systems displays.
- Click the Export icon next to the options icon (⋮). The drop-down menu displays.
-
Select CSV or JSON as the export format. A status message displays:
Preparing export. Once complete, your download will start automatically.
When the download completes, a browser window automatically opens to display the results.
If you remain on the Systems page after requesting the download, status messages from Insights appear with updates on the progress of the export operation.
4.3. Exporting system inventory by using the export API Copiar enlaceEnlace copiado en el portapapeles!
You can use the Export API to export your inventory data. Use the REST API entry point: http://console.redhat.com/api/export/v1.
The Export Service API supports the GET, POST, and DELETE HTTP methods. The API offers the following services:
- POST /exports
- GET /exports
- GET /exports/id
- DELETE /exports/id
- GET /exports/id/status
The API works asynchronously. You can submit the POST /exports request for export from the Export API and receive a reply with an ID for that export. You can then use that ID to monitor the progress of the export operation with the GET /exports/id/status request. When the generated export is complete, you can download it (GET /exports/id) or delete it (DELETE /exports/id).
Successful requests return the following responses:
- 200 — Success
- 202 — Successfully deleted (for the DELETE method)
For more information about the operations, schemas, and objects, see Consoledot Export Service.
4.3.1. Requesting the system inventory export Copiar enlaceEnlace copiado en el portapapeles!
Before you can request the exported data file, you need to obtain a unique ID for the download. To obtain the ID, issue a POST request. The server returns a response that includes the ID. Use the ID in any request that requires the id parameter, such as GET /exports/id.
Prerequisites
- Token-based service account with the appropriate permissions for your systems
RBAC permissions for the systems you want to view and export
- Inventory:hosts:read (inventory:hosts:read * for all systems in inventory)
- A User Access role for workspaces. For more information about User Access roles, see User access to workspaces.
Procedure
Create a request for the export service, or use this sample request code:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can request CSV or JSON as your export format.
In the Hybrid Cloud Console, navigate to the API documentation page.
NoteYou can use the API documentation to experiment and run queries against the API before writing your own custom client and/or use the APIs in your automation.
- Select POST /exports.
- Remove the existing sample code in the Request Body window and paste the request code into the window.
- Click Execute. This request initiates the export process. The curl request and server response appear, along with the result codes for the POST operation.
- Look for the id field in the server response. Copy and save the string value for id. Use this value for id in your requests.
- Optional. Issue the GET /exports request. The server returns the curl request, request URL, and response codes.
- Optional. To request the status of the export request, issue the GET /exports/id/status request.
- When the export has completed, issue the GET /exports/id request, with the ID string that you copied in place of id. The server returns a link to download the export file (the payload).
- Click Download File. When the download completes, a notification message displays in your browser.
- Click the browser notification to locate the downloaded zip file.
The server retains export files for 7 days.
4.3.2. Deleting export files Copiar enlaceEnlace copiado en el portapapeles!
To delete exported files, issue the DELETE /exports/id request.
Additional resources
- Knowledge Base article about inventory export: Ability to export a list of registered inventory systems
- Export service API for multiple sources: https://developers.redhat.com/api-catalog/api/export-service
- Export service API doc within the console: https://console.redhat.com/docs/api/export
- For the latest OpenAPI specifications, see https://swagger.io/specification/
4.3.3. Automating inventory export using Ansible playbooks Copiar enlaceEnlace copiado en el portapapeles!
You can use an Ansible playbook to automate the inventory export process. The playbook is a generic playbook for the export service that uses token-based service accounts for authentication.
Procedure
- Navigate to https://github.com/jeromemarc/insights-inventory-export .
- Download the inventory-export.yml playbook.
- Run the playbook. The playbook does everything from requesting the export id, to requesting download status, to requesting the downloaded payload.
Additional resources
For more information about service accounts, refer to the KB article: Transition of Red Hat Hybrid Cloud Console APIs from basic authentication to token-based authentication via service accounts.
4.3.4. Using the inventory export service for multiple Insights services Copiar enlaceEnlace copiado en el portapapeles!
You can use the inventory export service for multiple services within the same request, such as inventory and notifications. To request multiple services, include source information for each service that you want to request in your POST /exports request. For example:
The POST /exports request returns a unique id for each export.
The GET /exports request returns a ZIP file that includes several JSON or CSV files, one for each service that you request.