System information
This section provides a total of five different ways to achieve the same result; two examples for
Satellite 5 and three examples for Satellite 6.
A Satellite 5 Python script
A Satellite 6 Python script
A Satellite 6 Ruby script
A Satellite 5 spacecmd example
A Satellite 6 hammer example
Note
The spacecmd command is not a supported feature in Satellite 5.6. It is planned for release
and support with Satellite 5.7, and is shown here for the sake of completeness.
A total of 10 examples are provided. The first examples cover the simpler use cases of listing systems
and hosts, followed by the more complex examples covering users and roles.
Report a bug
4.1.1 .1 . List ing Syst e m s and Ho st s
The examples in this section describe different ways to list systems and hosts available to the user
who logged in.
Usin g Pyt h o n t o List Available Syst ems on Satellite 5
This example uses a Python script to connect to Satellite 5, authenticate, and retrieve a list of
available systems.
#!/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 systems available to user
list = client.system.listSystems(key)
for system in list:
print system.get('id')
print system.get('name')
# Logout
client.auth.logout(key)
Red Hat Sat ellit e 6 .0 T ransit ion G uid e
4 4