Solved:
The problem was that I wasn't calling enough methods before calling save_system.
The same code saves the system if I add a modify_system 'network' or a
modify_system 'profile' after modifying the hostname.
Thx!
From: Jason Barlow
Sent: Friday, November 09, 2012 9:30 AM
To: cobbler mailing list
Subject: RE: [cobbler] Problems with writing systems through the XMLRPC API using perl
XML::RPC or XMLRPC::Lite
Thanks for the suggestion.
I'm now checking the return values, and I've removed a failing 'modify_system
call'. Everything checks out ok according to the return values, and I'm able to
read stuff just fine, but the writes just are not taking.
Output:
new system id is ___NEW___system::G2EjtpYQF6V3eb+WvYbocQcEFSqEOEBoCg==
modify name:1
modify hostname: 1
save system: 1
sync:1
[root@spacewalk cobbler]# cobbler system list | grep vacsld01test
[root@vspacewalk cobbler]#
From the following code:
#!/usr/bin/perl
use strict;
use warnings;
use XMLRPC::Lite;
use Data::Dumper;
use diagnostics;
my $username = 'api-user';
my $password = 'api-user';
my $proto = 'http://';
my $servername = 'spacewalk';
my $api = '/cobbler_api';
my $url = $proto . $servername . $api;
my $name = 'vacsld01test';
my $conn =
XMLRPC::Lite->proxy('https://vacslp01spacewalk.cucbc.com/cobbler_a...;
my $token = $conn->login($username, $password)->result();
my $object = $conn->new_system($token)->result();
print "new system id is $object\n";
my $ret;
$ret = $conn->modify_system($object, 'name', $name, $token)->result();
print "modify name:" . $ret . "\n";
$ret = $conn->modify_system($object, 'hostname', $name, $token)->result();
print "modify hostname: " . $ret . "\n";
$ret = $conn->save_system($object, $token);
print "save system: " . $ret . "\n";
$ret = $conn->sync($token)->result();
print "sync:" . $ret . "\n";
From: cobbler-bounces(a)lists.fedorahosted.org
[mailto:cobbler-bounces@lists.fedorahosted.org] On Behalf Of James Clendenan
Sent: Thursday, November 08, 2012 5:32 PM
To: cobbler mailing list
Subject: Re: [cobbler] Problems with writing systems through the XMLRPC API using perl
XML::RPC or XMLRPC::Lite
I'm not going to be much help on this, but one thought I would have is that you're
not checking the return of the result call, which could be trying to tell you something
about an error. I do recall when trying to do a python interface to do similar, it was
usually that I was missing one of the required host fields.
You should also take a look at the test cases for the webui as it also uses the xmlrpc
interface for it's work.
James
On Thu, Nov 8, 2012 at 4:10 PM, Jason Barlow
<jbarlow@central1.com<mailto:jbarlow@central1.com>> wrote:
I'm trying to create a new system profile using perl through the XMLRPC API.
Things work great using python, but when I try to use either of the above perl interfaces,
I'm not able to actually write any of the new objects I've created:
Reading items works a charm, and it looks like the calls themselves are succeeding, but
the host never shows up in a:
#[root@spacewalk cobbler]# cobbler system list | grep test
#
I'm wondering what's going wrong here; am I not authenticating properly?
I've tried using both XML::RPC and XMLRPC::Lite, and get similar results, where reads
work fine, but nothing actually 'sticks'
Here's the script that I'm using for XMLRPC::Lite
#!/usr/bin/perl
use strict;
use warnings;
use XMLRPC::Lite;
use Data::Dumper;
my $username = 'api-user';
my $password = 'sapi-user';
my $proto = 'http://';
my $servername = 'spacewak';
my $api = '/cobbler_api';
my $url = $proto . $servername . $api;
my $name = 'vacsld01test';
my $conn =
XMLRPC::Lite->proxy('https://vacslp01spacewalk.cucbc.com/cobbler_a...;
my $token = $conn->login($username, $password)->result();
my $object = $conn->new_system($token)->result();
$conn->modify_system($object, 'name', $name, $token)->result();
$conn->modify_system($object, 'hostname', $name, $token)->result();
$conn->save_system($object, $token)->result();
$conn->sync($token)->result();
/var/log/cobbler/cobbler.log has:
Thu Nov 8 16:03:46 2012 - INFO | authenticate; ['api-user', True]
Thu Nov 8 16:03:46 2012 - INFO | REMOTE new_item(system); user(api-user)
Thu Nov 8 16:03:46 2012 - DEBUG | authorize; ['api-user', 'new_system',
None, None, True]
Thu Nov 8 16:03:46 2012 - DEBUG | REMOTE api-user authorization result: True; user(?)
Thu Nov 8 16:03:46 2012 - INFO | REMOTE modify_item(system); user(api-user);
object_id(___NEW___system::o0X5NLQrLsh9rXGhtvbuts56aTY6zb4JfQ==); attribute(name)
Thu Nov 8 16:03:46 2012 - DEBUG | authorize; ['api-user',
'modify_system', <cobbler.item_system.System instance at 0x14350560>,
'name', True]
Thu Nov 8 16:03:46 2012 - DEBUG | REMOTE api-user authorization result: True; user(?)
Thu Nov 8 16:03:46 2012 - INFO | REMOTE modify_item(system); user(api-user);
object_id(___NEW___system::o0X5NLQrLsh9rXGhtvbuts56aTY6zb4JfQ==); attribute(hostname)
Thu Nov 8 16:03:46 2012 - DEBUG | authorize; ['api-user',
'modify_system', <cobbler.item_system.System instance at 0x14350560>,
'hostname', True]
Thu Nov 8 16:03:46 2012 - DEBUG | REMOTE api-user authorization result: True; user(?)
Thu Nov 8 16:03:46 2012 - INFO | REMOTE save_item(system); user(api-user);
object_id(___NEW___system::o0X5NLQrLsh9rXGhtvbuts56aTY6zb4JfQ==)
Thu Nov 8 16:03:46 2012 - DEBUG | authorize; ['api-user', 'save_system',
<cobbler.item_system.System instance at 0x14350560>, None, True]
Thu Nov 8 16:03:46 2012 - DEBUG | REMOTE api-user authorization result: True; user(?)
Thu Nov 8 16:03:46 2012 - INFO | add_item(system); ['vacsld01test']
Thu Nov 8 16:03:46 2012 - DEBUG | get_items; ['system']
Thu Nov 8 16:03:46 2012 - INFO | REMOTE sync; user(api-user)
Thu Nov 8 16:03:46 2012 - DEBUG | authorize; ['api-user', 'sync', None,
None, True]
Thu Nov 8 16:03:46 2012 - DEBUG | REMOTE api-user authorization result: True; user(?)
Thu Nov 8 16:03:46 2012 - INFO | sync
Thu Nov 8 16:03:46 2012 - INFO | running pre-sync triggers
Thu Nov 8 16:03:46 2012 - INFO | cleaning trees
I'm using:
cobbler2-2.0.11-4.el5 ( CentOS 5.8)
perl v5.10.1
XMLRPC::Lite 0.715
_______________________________________________
cobbler mailing list
cobbler@lists.fedorahosted.org<mailto:cobbler@lists.fedorahosted.org>
https://lists.fedorahosted.org/mailman/listinfo/cobbler