Sample Scripts
Perl example:
This Perl example shows the system.listUserSystems call being used to get a list of systems a user has access to. In the example below, the name of each system will be printed.
The Frontier::Client Perl module can be found in the "perl-Frontier-RPC" rpm contained in the newest Satellite channel on http://rhn.redhat.com.
#!/usr/bin/perl
use Frontier::Client;
my $HOST = 'satellite.example.com';
my $user = 'username';
my $pass = 'password';
my $client = new Frontier::Client(url => "http://$HOST/rpc/api");
my $session = $client->call('auth.login',$user, $pass);
my $systems = $client->call('system.listUserSystems', $session);
foreach my $system (@$systems) {
print $system->{'name'}."\n";
}
$client->call('auth.logout', $session);
Python example:
Below is an example of the user.listUsers call being used. Only the login name of each group is printed.
#!/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)
For more examples visit the Spacewalk community page.