Using Python with RHN API

Why use RHN API ?

  • RHN APU can be used to automate tasks for managing systems .
  • Connect to the Satellite server via XML-RPC library

See example below to get started, here is sample Python script :


Sample Python Script
#!/usr/bin/python
import xmlrpclib
URL = "https://satellite.example.com/rpc/api"
user = "rhn-username"
pswd = "rhn-password"
client = xmlrpclib.Server(URL, verbose=0)
session = client.auth.login(user, pswd)
list = client.user.list_assigned_system_groups(session, user)
for group in list:
print group.get('name')
client.auth.logout(session)

Advertisements