I tried this script, and also converted it to Python just for fun.  Using both 
versions, I get the following error message:

xmlrpclib.Fault: <Fault -23: 'redstone.xmlrpc.XmlRpcFault: You do not have 
permissions to perform this action.'>

The message in the server log is similar:

redstone.xmlrpc.XmlRpcFault: You do not have permissions to perform this action.
        at 
com.redhat.rhn.frontend.xmlrpc.BaseHandler.invoke(BaseHandler.java:124)
        at redstone.xmlrpc.XmlRpcDispatcher.dispatch(XmlRpcDispatcher.java:123)
        ... (error continues)

This is when obtainReactivationKey is called.  The call to list_user_systems is 
successful.

Can anyone help me understand what this error is telling me? The user I'm using to access the API has all permissions enabled.

Thanks much,

Ed


Sascha Bendix wrote:
Hi,

inspired by the solution which was posted by Tom I took a closer look at
the xmlrpc interface.

To make long story short: The following cgi script returns a
reactivation key for the machine you are coming from. When registring
with this key the problem of duplicates is avoided.

<code|/var/www/cgi-bin/getreactivationkey.cgi>
#!/usr/bin/perl

use strict;
use RHNSession;

my $system_name = $ENV{'REMOTE_HOST'};

$system_name =~ s/\..*$//;

print 'Content-type: text/plain'."\n\n";

my ($client, $session) = RHNSession::Session;
my $systems = $client->call('system.list_user_systems', $session);

for my $system (@{$systems}) {
    if ($system->{'name'} eq $system_name) {
        print $client->call('system.obtainReactivationKey',
$session,$system->{'id'});
        last;
    }
}
</code>

Additionally you will need my variant of the RHNSession Module:

<code|/usr/lib/perl5/vendor_perl/5.8.8/RHNSession.pm>
package RHNSession;

use strict;
use Exporter;
use Frontier::Client;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

$VERSION     = 0.01;
@ISA         = qw(Exporter);
@EXPORT      = ();
@EXPORT_OK   = qw(Session);
%EXPORT_TAGS = ( DEFAULT => [qw(&Session)] );

sub Session {
  open(IN, "/etc/satellite_api.conf") or die "Couldn't open file for
reading: $!";
  $_ = <IN>;
  my ($HOST, $USER, $PASS) = (split);
  close(IN);

  my $client = new Frontier::Client(url => "https://$HOST/rpc/api";);
  my $session = $client->call('auth.login', $USER, $PASS);

  return ($client, $session);
}

1;
</code>

the packages perl-IO-Socket-SSL and perl-Frontier-RPC and a file
/etc/satellite_api.conf with the following content:
<spacewalk-fqdn> <spacewalk-user> <spacewalk-userpassword>

To the developers: Thanks for the wunderful xmlrpc interface :-)

Regards,

Sascha

_______________________________________________
Spacewalk-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-list


_______________________________________________
Spacewalk-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-list

Reply via email to