Here's the code and it seems to work as of right now. Perhaps someone can suggest how this code could be better:
Basically I pass it two arguments, the first being the existing system and the second being what I would like to rename the system to:
#!/usr/bin/python
import sys from xmlrpclib import *
system_name=sys.argv[1] new_name=sys.argv[2]
intf="eth0"
conn = ServerProxy("http://localhost/cobbler_api")
token = conn.login("testing","testing")
# Check for systems and create if it doesn't exist try: sys_id = conn.get_system_handle(system_name, token) except Fault, reason: if reason.faultCode == 1: sys_id = conn.new_system(token) pass else: raise
conn.rename_system(sys_id, new_name, token) sys_id = conn.get_system_handle(new_name, token) conn.modify_system(sys_id, "profile", "CentOS-5.2-x86_64-combined", token) conn.modify_system(sys_id, "name", new_name, token) conn.modify_system(sys_id, 'modify_interface', { "ipaddress-%s" % intf : "10.130.242.220", "dnsname-%s" % intf : new_name, }, token)
conn.save_system(sys_id, token)
I mostly ripped this code off from other posts I found.
Thanks -jeremy
On Sep 14, 2010, at 6:33 AM, Stuart Sears wrote:
On 14/09/10 01:53, Jeremy Hansen wrote:
Is there a resource for cobbler api examples? Currently I'm trying to use the XMLAPI interface and I'm having some issues.
xmlrpclib.Fault: <Fault 1: 'exceptions.TypeError:set_dns_name() takes exactly 3 arguments (2 given)'>
When I add an additional argument for the interface, modify_system() breaks:
xmlrpclib.Fault: <Fault 1: 'exceptions.TypeError:modify_system() takes exactly 5 arguments (6 given)'>
You're really going to have to show us what you are trying :)
If anyone has an example of modifying dns_name within an existing system profile, this would be very helpful in understanding how this works. I'm obviously pretty green when it comes to working with the API.
I've done some, but as I say, show us the code :)
Stuart
Stuart Sears RHCA etc. "It's today!" said Piglet. "My favourite day," said Pooh. _______________________________________________ cobbler mailing list cobbler@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/cobbler