A while back I had used the example Perl in the wiki to get my toes  
wet into talking XMLRPC to cobbler.  All was going well in 1.6.x and  
then since we haven't deployed the system I though hey I will go to  
2.0 so i have less pain later!

Anyway this code,

use XMLRPC::Lite;

# Build the connection
my $xmlrpc = XMLRPC::Lite->proxy($uri);
# Login to cobbler xmlrpm and get session token back.
my $token = $xmlrpc->login($user, $password)->result();
# Create new system object
my $object = $cobbler->new_system($token)->result();
$cobbler->modify_system($object, "name", $hostname, $token)->result();
$cobbler->modify_system($object, "hostname", $hostname, $token)->result 
();
$cobbler->modify_system($object, "profile", $profile, $token)->result();
$cobbler->modify_system($object, "gateway", $gateway, $token)->result();
###
my %eth0 = (
        "macaddress-eth0" => $mac,
        "ipaddress-eth0" => $ip,
        "static-eth0" => 1,
        "subnet-eth0" => $netmask,
);

$cobbler->modify_system($object, "modify-interface", \%eth0, $token)- 
 >result();
# Commit the system object
my $result = $cobbler->save_system($object, $token)->result();

Created a host with the code, and the cobbler.log shows nothing bad,

Thu Sep 24 17:02:38 2009 - INFO | authenticate; ['derek', True]
Thu Sep 24 17:02:39 2009 - INFO | REMOTE new_item(system); user(derek)
Thu Sep 24 17:02:39 2009 - DEBUG | authorize; ['derek', 'new_system',  
None, None, True]
Thu Sep 24 17:02:39 2009 - INFO | REMOTE authorization result: True;  
user(?)
Thu Sep 24 17:02:39 2009 - INFO | REMOTE modify_item(system); user 
(derek); object_id(___NEW___system:: 
3TOmCVq3auSpmKAFRcwApSaOIZV2Plmt0g==); attribute(name)
Thu Sep 24 17:02:39 2009 - DEBUG | authorize; ['derek',  
'modify_system', <cobbler.item_system.System instance at 0x727ec20>,  
'name', True]
Thu Sep 24 17:02:39 2009 - INFO | REMOTE authorization result: True;  
user(?)
Thu Sep 24 17:02:39 2009 - INFO | REMOTE modify_item(system); user 
(derek); object_id(___NEW___system:: 
3TOmCVq3auSpmKAFRcwApSaOIZV2Plmt0g==); attribute(hostname)
Thu Sep 24 17:02:39 2009 - DEBUG | authorize; ['derek',  
'modify_system', <cobbler.item_system.System instance at 0x727ec20>,  
'hostname', True]
Thu Sep 24 17:02:39 2009 - INFO | REMOTE authorization result: True;  
user(?)
Thu Sep 24 17:02:39 2009 - INFO | REMOTE modify_item(system); user 
(derek); object_id(___NEW___system:: 
3TOmCVq3auSpmKAFRcwApSaOIZV2Plmt0g==); attribute(profile)
Thu Sep 24 17:02:39 2009 - DEBUG | authorize; ['derek',  
'modify_system', <cobbler.item_system.System instance at 0x727ec20>,  
'profile', True]
Thu Sep 24 17:02:39 2009 - INFO | REMOTE authorization result: True;  
user(?)
Thu Sep 24 17:02:39 2009 - INFO | REMOTE modify_item(system); user 
(derek); object_id(___NEW___system:: 
3TOmCVq3auSpmKAFRcwApSaOIZV2Plmt0g==); attribute(gateway)
Thu Sep 24 17:02:39 2009 - DEBUG | authorize; ['derek',  
'modify_system', <cobbler.item_system.System instance at 0x727ec20>,  
'gateway', True]
Thu Sep 24 17:02:39 2009 - INFO | REMOTE authorization result: True;  
user(?)
Thu Sep 24 17:02:39 2009 - INFO | REMOTE modify_item(system); user 
(derek); object_id(___NEW___system:: 
3TOmCVq3auSpmKAFRcwApSaOIZV2Plmt0g==); attribute(modify-interface)
Thu Sep 24 17:02:39 2009 - DEBUG | authorize; ['derek',  
'modify_system', <cobbler.item_system.System instance at 0x727ec20>,  
'modify-interface', True]
Thu Sep 24 17:02:39 2009 - INFO | REMOTE authorization result: True;  
user(?)
Thu Sep 24 17:02:39 2009 - INFO | REMOTE save_item(system); user 
(derek); object_id(___NEW___system:: 
3TOmCVq3auSpmKAFRcwApSaOIZV2Plmt0g==)
Thu Sep 24 17:02:39 2009 - DEBUG | authorize; ['derek', 'save_system',  
<cobbler.item_system.System instance at 0x727ec20>, None, True]
Thu Sep 24 17:02:39 2009 - INFO | REMOTE authorization result: True;  
user(?)
Thu Sep 24 17:02:39 2009 - INFO | add_item(system);  
['rhel4-64.umiacs.umd.edu']
Thu Sep 24 17:02:39 2009 - INFO | get_items; ['system']

And the system is created however the eth0 interface is not, any  
ideas?  Additionally when I check dumpvars on the system it gives this  
error,

# cobbler system dumpvars --name=rhel4-64.umiacs.umd.edu
### ERROR ###
Unexpected remote error, check the server side logs for further info
exceptions.AttributeError:'NoneType' object has no attribute  
'get_parent'

and logs this,

Thu Sep 24 17:05:26 2009 - INFO | Exception occured:  
exceptions.AttributeError
Thu Sep 24 17:05:26 2009 - INFO | Exception value: 'NoneType' object  
has no attribute 'get_parent'
Thu Sep 24 17:05:26 2009 - INFO | Exception Info:
   File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line  
1725, in _dispatch
     return method_handle(*params)
    File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line  
914, in get_blended_data
     return self.xmlrpc_hacks(utils.blender(self.api, True, obj))
    File "/usr/lib/python2.4/site-packages/cobbler/utils.py", line  
504, in blender
     tree = grab_tree(api_handle, root_obj)
    File "/usr/lib/python2.4/site-packages/cobbler/utils.py", line  
489, in grab_tree
     parent = obj.get_parent()

Derek Yarnell
UNIX Systems Administrator
University of Maryland
Institute for Advanced Computer Studies



_______________________________________________
cobbler mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/cobbler

Reply via email to