Show Table of Contents
3.2. Python Example
The following example demonstrates the
user.listUsers call. The example prints the name of each group.
#!/usr/bin/python
import xmlrpclib
SATELLITE_URL = "http://satellite.example.com/rpc/api"
SATELLITE_LOGIN = "username"
SATELLITE_PASSWORD = "password"
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
list = client.user.list_users(key)
for user in list:
print user.get('login')
client.auth.logout(key)
The following example shows how to use date-time parameters. This code schedules the installation of package
rhnlib-2.5.22.9.el6.noarch to system with id 1000000001.
#!/usr/bin/python
from datetime import datetime
import time
import xmlrpclib
SATELLITE_URL = "http://satellite.example.com/rpc/api"
SATELLITE_LOGIN = "username"
SATELLITE_PASSWORD = "password"
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
package_list = client.packages.findByNvrea(key, 'rhnlib', '2.5.22', '9.el6', '', 'noarch')
today = datetime.today()
earliest_occurrence = xmlrpclib.DateTime(today)
client.system.schedulePackageInstall(key, 1000000001, package_list[0]['id'], earliest_occurrence)
client.auth.logout(key)

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.