System information

The examples in this section describe different ways to locate, create, and delete users.
Usin g Pyt h o n t o Man age Users on Sat ellite 5
This example uses a Python script to connect to and authenticate against a Satellite 5 server. It then
goes on to search for a specific user (exampl e), to delete that user if it exists, and then recreate it
with Administrator privileges.
#!/usr/bin/python
import xmlrpclib
# Define Satellite location and login details
SATELLITE_URL = "http://localhost/rpc/api"
SATELLITE_LOGIN = "admin"
SATELLITE_PASSWORD = "password"
client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
# Authenticate and get session key
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
# Get list of users
list = client.user.list_users(key)
print "Existing users in Satellite:"
for user in list:
print user.get('login')
# Look for user example and if found, delete the user
for user in list:
if user.get('login') == 'example':
deleteuser = client.user.delete(key, 'example')
if deleteuser == 1:
print "User example deleted"
# Create a user called example
createuser = client.user.create(key, 'example', 'password', 'Example',
'User', "root@ localhost")
if createuser == 1:
print "User example created"
# Admin Org Admin role to the example user
adminrole = client.user.addRole(key, 'example', 'org_admin')
if adminrole == 1:
print "Made example an Org Admin"
# Logout
client.auth.logout(key)
Usin g Pyt h o n t o Man age Users on Sat ellite 6
This example performs the same task as the previous example. That is, it uses a Python script to
connect to and authenticate against a Satellite 6 server, search for a specific user, delete that user if
it exists, and then recreate it with Administrator privileges.
#!/usr/bin/python
Chapt er 4 . Advanced T ransit ioning
4 7