[Spacewalk-list] Using rpc api via a proxy - 1.0

Tom Brown tom at ng23.net
Tue Jul 27 14:26:27 UTC 2010


> All works fine unless i try to run it through a proxy - When going via
> the proxy i get the following
>
> 500 Bad chunk-size in HTTP response: <?xml version="1.0"
> encoding="UTF-8"?><methodResponse><params><param><value><array><data><value><struct><member><name>id</name><value><i4>1000010309</i4></value></member>

and the script may help ....

#!/usr/bin/perl -w
# This is used to check via the spacewalk API to see if this host
# exists and if it does delete it so that we dont get a dupe on
# re-registration. If the hostname has changed as a result of the
# rebuild then the system will manually need deleting as the host
# is in effect a different host.

use Frontier::Client;
use strict;

open(PASS,'< /etc/sysconfig/spacewalk') || die "There is an error $!";
my @login=<PASS>;
my @credencial=split(/,/,$login[3]);

foreach (@credencial) {
$_=~s/"//g;
}

my $HOST=$ENV{COBBLER_SERVER};

open (F,'/etc/sysconfig/network') || die "$!";
while (<F>) {
        if ($_ =~/HOSTNAME/) {
        my @host=split(/=/,$_);
        chomp($host[1]);
        print "$host[1]\n";

        # Connect to Spacewalk #
        my $client = new Frontier::Client(url => "https://$HOST/rpc/api");
        my $session = $client->call('auth.login',$credencial[0],
$credencial[1]);

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

                # For each system check if registered if yes remove it
                foreach my $system (@$systems) {

                        if ($system->{'name'} eq $host[1]) {

                        print "The systen: $host[1] is registered\n";
                        my $systems =
$client->call('system.deleteSystems', $session,$system->{'id'});
                        print "The systen has now been removed from
Spacewalk\n";
                        last;
                        }
                }

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

thanks




More information about the Spacewalk-list mailing list