[Spacewalk-list] Spacewalk RPC API - Perl

L.A.Hurst at lboro.ac.uk L.A.Hurst at lboro.ac.uk
Wed Feb 25 09:35:35 UTC 2009


Hello,
(N.B. This is not a request for help, it's the solution to a problem I
had in the hope that it may be useful to someone else.)
I've been writing a script which, amongst other things, uses the RPC API
to search for a package with 'packages.findByNvrea'. I based my call to
the API on the reference script on RH's website [0]. The problem I had
was that the script would fail to find a package I knew existed on the
Spacewalk server (specifically libdhcp-1.20-5.el5_2.1.i386.rpm). No
amount of debugging of my script or manually searching the database
could determine where the problem lay (manually searching the database,
I was able to find it). In the end, using a packet sniffer to view the
traffic being sent from my script to the Spacewalk server I discovered
that the version number of the package, '1.20' was being converted by
Frontier::Client from a string to a float. It appears that
Frontier::Client tries to do "the right thing" (by inferring types in a
dynamically typed language from the format of the data) and, in this
case, gets is wrong. The solution, once I'd figured this out was simply
to force the client to send the data as a string (i.e.
"$client->call('method', $session, $client->string($variable));" ).

Hopefully the above information will save someone else from having to
spend so much time and effort tracking down this issue when using the
RPC API from Perl.

[0] http://www.redhat.com/spacewalk/documentation/api/0.4/scripts.html

regards
-- 
Laurence Hurst




More information about the Spacewalk-list mailing list