Obtaining system lists using the RHN API
Jan. 29, 2012, 6:40 p.m.
Overview
RedHat's RHN offering is extremely powerful, but the web front end does not offer a way to get an export of all systems that are being managed. This article briefly explains how to get a list of systems that exist in RedHat's RHN using the API provided by RedHat with Python.
The script
#!/usr/bin/python
import xmlrpclib
SATELLITE_URL = "https://rhn.redhat.com/rpc/api"
SATELLITE_LOGIN = "youruser"
SATELLITE_PASSWORD = "yourpassword"
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
list = client.system.listUserSystems(key)
for group in list:
print group.get('name')
client.auth.logout(key)
Python will connect to SATELLITE_URL using the SATELLITE_LOGIN and SATELLITE_PASSWORD to authenticate and then request listUserSystems from the system class. Then we iterate through the returned information to show a list of servers.
API information
More information about the RHN API can be found here.
