Hello friends:
Could someone post a simple example of how to access the XMLRPC interface using perl? I'm able to do this just fine with Python but would also like to be able to do it with Perl as well. The example given on this page uses a session token, which I'd like to avoid:
http://fedorahosted.org/cobbler/wiki/CobblerXmlrpc
<code> #!/usr/bin/perl
use strict; use XMLRPC::Lite;
# Build the connection my $xmlrpc = XMLRPC::Lite -> proxy('https://x.x.x.x/cobbler_api_rw');
# Login to cobbler xmlrpm and get session token back. my $token = $xmlrpc->login("cobbler-xmlrpc-user", "cobbler-xmlrpc-pass")->result();
# Create new system object my $object = $xmlrpc->new_system($token)->result(); $xmlrpc->modify_system($object, "name", "example", $token)->result(); $xmlrpc->modify_system($object, "profile", "F8-i386", $token)->result();
# Commit the system object my $result = $xmlrpc->save_system($object, $token)->result(); </code>
Basically all I want to do is be able to pull distros, profiles, systems, etc. into my Perl program. Forgive my ignorance on this topic; my Python skills are a lot stronger, and I wasn't able to find any documentation on using Perl with XMLRPC.
thanks
Sean
On 10/13/2011 02:59 PM, Sean Carolan wrote:
Hello friends:
Could someone post a simple example of how to access the XMLRPC interface using perl? I'm able to do this just fine with Python but would also like to be able to do it with Perl as well. The example given on this page uses a session token, which I'd like to avoid:
Wow, perl SOAP::SOM seems pretty confusing, especially with the data returned by cobbler. But perhaps this will get you started:
#!/usr/bin/perl
use strict; use XMLRPC::Lite; use Data::Dumper;
# Build the connection my $xmlrpc = XMLRPC::Lite -> proxy('http://x.x.x/cobbler_api');
# Get the distros- return a SOM object my $som = $xmlrpc->get_distros(); # This will return an array of the entries my $params = $som->valueof('//params/param'); foreach my $distro (@$params) { print $distro->{'name'} . "\n"; print Dumper($distro); }
The dumper output will show you the other hash keys available in $distro.
cobbler@lists.fedorahosted.org