Questions about creating Server Profiles and Snapshot tags in Satellite

Latest response

Does anyone know if there is a way to create server profiles for all members of a system group in satellite rather than selecting each server in that group and creating the profile on a server by server basis? 

 

Same question for creating snapshot tags as well

 

If there isn't a way to do it within Satellite GUI, is there a command line solution where we could script the creation of server profiles and snapshot tags?

Responses

Hello Cary,

 

Under the Web-ui, I don't see any option to create a server profile (i.e package profile) or tags for all members in the group. But yes there are API's which can help you do it.

Method: createPackageProfile
Description:
Create a new stored Package Profile from a systems installed package list.
Parameters:
    string sessionKey
    int serverId
    string profileLabel
    string description
Returns:
    int - 1 on success, exception thrown otherwise.

You can use this API to create the package profile for all the system in a group. As this API needs input of systemId and profileLabel you can use systemgroup.listSystems

Also for the snapshot tag, we have :

Method: tagLatestSnapshot
Description:
Tags latest system snapshot
Parameters:
    string sessionKey
    int serverId
    string tagName
Returns:
    int - 1 on success, exception thrown otherwise.

Complete set of API's is documented on https://<satellite-fqdn>/rhn/apidoc/index.jsp or on your satellite go to Help -> API section . For details on how to write an API script you can refer API Overview document.

Let us know if this information helps you get started with APIs and serve your purpose.

Paresh

Thanks for the feedback Paresh,  I'm still having some problems understanding the syntax of the API.  I am using the following perl code from the spacewalk api example site, but I am having problems getting consistent output, and I'm still a little hazy on how to create the syntax for a forloop to create the systemtag and server profiles I need.

 

#!/usr/bin/perl
use strict;
use Frontier::Client;
use Data::Dumper;

my $HOST = 'my.sat.server';
my $user = 'xxxx';
my $pass = 'xxxx';
my $client = new Frontier::Client(url => "http://$HOST/rpc/api");
my $session = $client->call('auth.login',$user, $pass);
my $TAGNAME = 'TEST_SS_TAG'

# this part works as expected:

my $systems = $client->call('system.listSystems', $session);

print Dumper $systems;

# when I try a slightly different API call I have problems i.e.

my $usersystems=$client->call(system.listUserSystems', $session);

print Dumper $usersystems;

$client->call('auth.logout', $session);

Error Output from "listUserSystems": Fault returned from XML RPC Server, fault code -1: redstone.xmlrpc.XmlRpcFault: Could not find method: listUserSystems in class: com.redhat.rhn.frontend.xmlrpc.systemgroup.ServerGroupHandler with params: [java.lang.String]

I'm not sure what I'm doing wrong there...

my $usersystems=$client->call(system.listUserSystems', $session);

                                                     ^ missing single quote mark

Otherwise this script works for me (Satellite Version: 5.4.0  API Version: 10.11).  Your XMLRPC fault indicates that you called the "systemgroup" class but line 19 shows you called "system"...  Are you sure this is the same script you ran...?

Changing class to "systemgroup" produces your error:

Fault returned from XML RPC Server, fault code -1: redstone.xmlrpc.XmlRpcFault: Could not find method: listUserSystems in class: com.redhat.rhn.frontend.xmlrpc.systemgroup.ServerGroupHandler with params: [java.lang.String]

 

Thanks Mark,

 

Knew it had to be something simple I was overlooking.

 

--Cary