Scripted remote removal of server from Satellite 5

Latest response

I am looking for a scripted/automated remote method of removing a server from Satellite, basically the reverse of rhnreg_ks

This is to be executed as part of the teardown stage of life cycle management and can either be executed from the host before it is 'torn down' or alternatively can be executed from one of the orchestration servers. In both instances, the servers making the call are 'remote' (ie. not the Satellite server)

Currently I am looking at a using a spacecmd call from either the server or the orchestration infrastructure with an API call using spacecmd:

spacecmd system_delete <hostname>

Can anyone think of a better/more elegant solution?
Is anyone else doing automated removal remotely? (rather than cleaning up unresponsive hosts on the Satellite server itself)

Responses

To follow this up, I wrote this orchestration script in Python using the Spacewalk API.
http://spacewalk.redhat.com/documentation/api/1.7/scripts.html

spacecmd also worked, but python was there and ready to go.

Hello - the most straightforward and supported way (spacemd is not yet supported as of Satellite 5.6) would be to use the Satellite API such as deleteSystem() or deleteSystems() calls in the systems namespace: https://access.redhat.com/documentation/en-US/Red_Hat_Satellite/5.6/html/API_Overview/chap-system.html - should be a trivial python or perl script to write.

Hope this helps

I do use spacecdmd on satellite 5.6 routinely. I did find that if/when it did fail, I'd have to wait a full hour before doing a deletion again via spacecmd. I'll see if I can find the reference I found that I believe I put someplace in the discussion area a while back.

UPDATE: found some of what I documented (regarding a one-hour delay due to clearing a cache, see this link here at this discussion https://access.redhat.com/discussions/1130053.

Pixel, it appears possible, and I suspect I can have a working example when I dig into it a bit more. I found one API Perl script example I posted here at https://access.redhat.com/discussions/723333 which when altered and matched with https://YOURSATSERVER.fqdn/rhn/apidoc/handlers/SystemHandler.jsp#deleteSystem may prove a valid example when merged properly. Will work in this - must go for the day.

-R Hinton

R Hinton / Xixi D,

Thanks for the posts.

As I posted above I resolved this by writing a short Python script using the Spacewalk API (xmlrpc). Spacecmd worked, but I preferred not to have to install the spacecmd package on the orchestration servers.

Unfortunately due to the environment I can't post the full script, but essentially the logic follows:
1. Check host exists by IP using client.system.search.ip
2. Extract the 'id' from the search result
3. Delete system using client.system.deleteSystem

Glad to hear it worked out for you Pixeldrift

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.