Good morning, Tânia.

Somebody else can correct me if I'm wrong, but IIRC, 
'system.config.addChannels' is referring to a configuration channel.  That's 
not a child channel, those are different constructs.  Config channels contain 
configuration files, child channels contain RPMs and are subordinate to base 
distribution channels.  I suspect the function call you're really looking for 
is system.setChildChannels.  That will also require getting the set from 
system.getChildChannels and add your new value to the set.

Secondly, that sort of error usually indicates that there's an error in 
arguments.  The function call processing uses argument types to route function 
calls based on arguments lists.

$systemInChanel = $client->call('system.config.addChannels', $session, $record, 
$chanel, $client->boolean($isDir));

Arg1 is good, that's your basic function call.
Arg2 is your session set, also good.
Arg3... based on the docs I'm looking at, it should be an array, ot a solitary 
value, of system IDs.
Arg4... also should be an array, of configuration channel labels.
Arg5, good, Boolean value.

Try this:

$systemInChanel = $client->call('system.config.addChannels', $session, ( 
$record ), ( $chanel ), $client->boolean($isDir));

to set arg3 and arg4 into a list prior to passing the argument list.

Jeff Kalchik
Systems Engineering
Land O'Lakes

From: spacewalk-list-boun...@redhat.com 
[mailto:spacewalk-list-boun...@redhat.com] On Behalf Of Tânia Agulhas Marques 
Valente [EE] (SSI)
Sent: Monday, December 18, 2017 4:48 AM
To: spacewalk-list@redhat.com
Subject: [Spacewalk-list] Question about perl with API

Hello

I am trying to make a perl script to add a child channel to a client system in 
Spacewalk.
I am relatively new with perl , managed to already make some that really help 
me a lot and I wanted to go further.

But I am getting an error and it seems I am not getting nowhere. Maybe someone 
can help me.

The script is:

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


my $num_args = $#ARGV + 1;
if ( $num_args < 2 ){

print "\nInsufficient Arguments !AddSystemToChannel.pl ficheiro_com_systems_IDs 
channel\n" ;
exit;
}

my $HOST = 'spaceserver';
my $user = 'username';
my $pass = 'user_pass';

my $file=$ARGV[0];
my $channel=$ARGV[1];
my $client = new Frontier::Client(url => "http://$HOST/rpc/api";);
my $session = $client->call('auth.login',$user, $pass);
my $isDir = 1;



open (FILE, $file) or print "O ficheiro $file não existe";
open (FILE2, $channel) or print "O ficheiro $channel não existe";

while (!eof(FILE) and !eof(FILE2)) {
my $record = <FILE>;
my $chanel = <FILE2>;

#$bb = $client->call('channel.listMyChannels', $session);
#foreach my $chanelsAll (@$bb) {
#my $label = $chanelsAll->{'label'};
#my $idchanels = $chanelsAll->{'id'};




$systemInChanel = $client->call('system.config.addChannels', $session, $record, 
$chanel, $client->boolean($isDir));
&checkRetVal("Set config channel (s): $record",$systemInChanel);



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


I pass two arguments, that are files. Just for test "file" has a client ID 
(1000010378) and "file2" has the name of the chilchanel 
(spacewalk_cli2.6_rh6_64).

The error I get is:

Fault returned from XML RPC Server, fault code -1: 
com.redhat.rhn.common.translation.TranslationException: Could not find 
translator for class java.lang.String to interface java.util.List

I assumed there is something wrong with $chanel, since that is the string and 
$record is an integer. Both must be arrays, and that's why I make a list in a 
file and pass it on command line (even though this test only have an entry on 
each file/list), I have used this before in other scripts and it worked, so I 
am getting to a dead end I believe because of my lack of knowledge in perl. But 
you must have an objective to write a script so I am learning when I need it.

Maybe someone already used this API call and can help me.


Thank you



This message may contain confidential material from Land O'Lakes, Inc. (or its 
subsidiary) for the sole use of the intended recipient(s) and may not be 
reviewed, disclosed, copied, distributed or used by anyone other than the 
intended recipient(s). If you are not the intended recipient, please contact 
the sender by reply email and delete all copies of this message.
_______________________________________________
Spacewalk-list mailing list
Spacewalk-list@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-list

Reply via email to