Now I've changed:
my @chanel = <FILE2>;
...
And
$client->call('system.config.addChannels', $session, $record, \@chanel,
$client->boolean($isDir));
And the error is:
Fault returned from XML RPC Server, fault code -1: redstone.xmlrpc.XmlRpcFault:
unhandled internal exception: Could not find config channel with
label=Spacewalk_cli2.6_RH6_64
But that is the channel label......sniff
Cumprimentos,
Tânia Marques Valente
Serviço Unix
SSI UOS4 - Gestão de Sistemas Distríbuidos
Grupo Caixa Geral de Depósitos
Tel: (351) 217619271
Ext: 559271
[email protected]<mailto:[email protected]>
From: Tânia Agulhas Marques Valente [EE] (SSI)
Sent: 18 de dezembro de 2017 10:48
To: '[email protected]' <[email protected]>
Subject: 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
_______________________________________________
Spacewalk-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-list