How to delete Content Host using API on Red Hat Satellite 6?

Solution Verified - Updated

Environment

  • Red Hat Satellite 6
  • API

Issue

  • How to delete Content Host using API on Red Hat Satellite 6 ?
  • How to unsubscribe Content Host using API on Red Hat Satellite 6?
  • How to unregister Content Host using API on Red Hat Satellite 6?
  • Content Host unregistration API call stopped working after Satellite 6.2 upgrade.

Resolution

First of all, ensure that the user that you are using belongs to the location which you want to work with.

NOTE: All API calls below must use a content host's numeric ID instead of their hostname e.g. 42 instead of client1.example.com. Only some older Satellite versions allow FQDN as well. To get the ID of a given host:

curl -L -u $ADMINUSER:$PASSWORD http://$(hostname -f)/api/v2/hosts/client1.example.com | json_reformat | grep -m1 \"id\"
  • To get details of a content host you can use the API call below (the json_reformat command is optional and is part of the yajl package):
$ curl -X GET -s -k -u $ADMINUSER:$PASSWORD https://satellite.example.com/api/v2/hosts/42 | json_reformat
  • To unsubscribe/unregister i.e. remove all subscriptions from this content host you can use this API call:
$ curl -X DELETE -s -k -u $ADMINUSER:$PASSWORD https://satellite.example.com/api/v2/hosts/42/subscriptions | json_reformat
  • Disassociate the client Host if already associated with compute resource:
$ curl -X PUT -s -k -u $ADMINUSER:$PASSWORD https://satellite.example.com/api/v2//hosts/42/disassociate | json_reformat
  • To unmanage the Host:
curl -X PUT --user ${user}:${password} --header 'Accept:application/json' --header 'Content-Type:application/json' -d '{"host":{"managed":"false"}}' https://satellite.example.com/api/v2/hosts/$delid | json_reformat
  • To completely remove i.e. delete this content host from Satellite, use this API call:
$ curl -X DELETE -s -k -u $ADMINUSER:$PASSWORD https://satellite.example.com/api/v2/hosts/42 | json_reformat

For further information about Satellite 6.7 API, please refer to the official Satellite 6.7 API Guide documentation.

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.