On 08/05/2009 10:06 PM, Derek Yarnell wrote:
So I was trying to do some XMLRPC perl programming and I was reading
the 'pydoc cobbler.remote' page.
get_profiles(self, page=None, results_per_page=None, token=None, **rest)
Returns all cobbler profiles as an array of hashes.
I was trying to utilize this RPC call and I seem to get something
different back that doesn't make sense. Array of hashes means to me
that we should get back a array of hashes but that does not seem to be
what I am getting out.
Well, with the double dereference printing out the names of the types is
new to me in Perl, but it's been a while.
Perhaps you could try printing the results out with Data::Dumper ?
The minimal python is:
import xmlrpclib
s = xmlrpclib.Server("http://127.0.0.1/cobbler_api")
print(s.get_profiles())
This gives me an list/array of hashes, each hash/dict describing a
different profile.
Here is the code that I think this should give back me the profiles
but I think I am missing something,
---- Code
#!/usr/bin/perl
use strict;
use XMLRPC::Lite;
# Build the connection
my $xmlrpc = XMLRPC::Lite ->
proxy('https://mica.umiacs.umd.edu/cobbler_api')
;
# Login to cobbler xmlrpm and get session token back.
my $token = $xmlrpc->login($username, $password)->result();
my @profiles = $xmlrpc->get_profiles($token);
my $k;
my $p;
foreach $p (@profiles) {
foreach $k (keys %$p) {
print $k."=".$$p{$k}."\n";
}
}
---- Output
_content=ARRAY(0x17f694a0)
_context=XMLRPC::Lite=HASH(0x17a6aa00)
_current=ARRAY(0x17e6b150)
---- Cobbler output
# cobbler profile list
redhat_4.8_as-i386
redhat_4.8_as-x86_64
redhat_4.8_as-xen-i386
redhat_4.8_as-xen-x86_64
redhat_4_as-i386
redhat_4_as-x86_64
redhat_5.3_client-i386
redhat_5.3_client-x86_64
redhat_5.3_client-xen-i386
redhat_5.3_client-xen-x86_64
redhat_5.3_server-i386
redhat_5.3_server-x86_64
redhat_5.3_server-xen-i386
redhat_5.3_server-xen-x86_64
redhat_5_client-i386
redhat_5_client-x86_64
redhat_5_server-i386
redhat_5_server-x86_64
rescue-redhat_4.8_as-i386
rescue-redhat_4.8_as-x86_64
rescue-redhat_5.3_client-i386
rescue-redhat_5.3_client-x86_64
rescue-redhat_5.3_server-i386
rescue-redhat_5.3_server-x86_64
Derek Yarnell
UNIX Systems Administrator
University of Maryland
Institute for Advanced Computer Studies
_______________________________________________
cobbler mailing list
cobbler(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/cobbler