[Spacewalk-list] Question about perl with API
Tânia Agulhas Marques Valente [EE] (SSI)
tania.marques.valente at cgd.pt
Mon Dec 18 10:48:19 UTC 2017
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20171218/7a39914e/attachment.htm>
More information about the Spacewalk-list
mailing list