Help with API calls for systems registered with Red Hat Subscription Management
Environment
- Systems registered with Red Hat Subscription Management
Issue
- There exists an API for RHSM and for Red Hat Satellite
- Where can I find documentation on the Subscription Manager API, especially for obtaining subscription management info from the Customer Portal?
Resolution
- There is no supported API method yet. However, RHSM is backed by the Candlepin API.
-
REST API provides RHSM users a possible automation solution for virtual data centres and organizations that cycle through instances often.
-
So, by referring to the Candlepin REST API for the API calls and documentation on how to use it with the portal for the URL part, we can create the API as mentioned in the diagnostic steps.
NOTE Some of the calls will not work since they are filtered, but some of the calls will work because we do consume some of the candlepin endpoints.
Diagnostic Steps
A couple of simple examples of using curl to retrieve JSON data from the API
- Retrieve info about a consumer (authenticating using RHSM username/password):
$ curl -s -u <rhsm_username> -k https://subscription.rhsm.redhat.com/subscription/consumers/<consumer_uuid> | python -mjson.tool
- Retrieve info about the entitlements for a consumer (authenticating using RHSM username/password):
$ curl -s -u <rhsm_username> -k https://subscription.rhsm.redhat.com/subscription/consumers/<consumer_uuid>/entitlements | python -mjson.tool
- Retrieve all subscriptions for a consumer (authenticating using consumer cert/key):
$ curl --cert /etc/pki/consumer/cert.pem --key /etc/pki/consumer/key.pem -k 'https://subscription.rhsm.redhat.com/subscription/pools?consumer=<consumer_uuid>&listall=true' | python -mjson.tool
Note In all the above cases the request is a GET request. The response is encoded in JSON format can be be processed further if desired. POST requests can be created with curl using the –data option (and in wget by using the –post-data option).
- Delete the systems from portal
$ curl -i -X DELETE http://subscription.rhsm.redhat.com/subscription/consumers/<consumer_uuid>
- Update the entitlement information
$ curl -i POST http://subscription.rhsm.redhat.com/subscription/entitlements/<entitlement_id>
- Attach subscription to a system
$ curl -vku <rhsm_username> -X POST 'https://subscription.rhsm.redhat.com/subscription/consumers/<consumer_uuid>/entitlements?pool=<subscription pool_id>&quantity=1'
- Download manifest
curl -vku <rhsm_username> 'https://subscription.rhsm.redhat.com/subscription/consumers/<consumer_uuid>/export' > manifest.zip
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.
Comments