On Wed, Mar 3, 2010 at 5:18 PM, Jasper Capel <jcapel(a)redhat.com> wrote:
----- "Jonathan Sabo" <jsabo(a)criminal.org> wrote:
> List,
>
> I'm trying to script inserting new systems into cobbler and I wrote
> the below code using the cobbler api. I'm finding that it creates
> the
> system but it's not available in the webUI until I've done a service
> cobbler restart. Is there a way around that so it's available
> immediately after it's saved with out having to restart cobblerd?
>
>
I'm not 100% sure here.
The python API is modifying the datafiles directly if I'm not mistaken (instead of
communicating with the cobblerd process), you could try using the XMLRPC API instead. In
Cobbler 2.0 I believe the command line utilities have been modified to communicate with
the cobblerd process instead of using the python API directly.
See:
https://fedorahosted.org/cobbler/wiki/CobblerXmlrpc
Cheers,
Jasper
_______________________________________________
cobbler mailing list
cobbler(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/cobbler
This is what I ended up with using xml-rpc....
#!/usr/bin/python
from xmlrpclib import *
# constants for testing
system_name="testing"
intf="eth1"
# standard XML-RPC proxy
conn = ServerProxy("http://localhost/cobbler_api")
# athenticate with cobbler (requires authn-testing to work)
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.modify_system(sys_id, "profile", "default", token)
conn.modify_system(sys_id, "name", system_name, token)
conn.modify_system(sys_id, "gateway", "192.168.69.1", token)
conn.modify_system(sys_id, 'modify_interface', {
"macaddress-%s" % intf : "AA:BB:CC:EE:EE:EE",
"ipaddress-%s" % intf : "192.168.10.50",
"gateway-%s" % intf : "192.168.10.1",
"dnsname-%s" % intf : "foo.example.com",
"static-%s" % intf : True,
"dhcptag-%s" % intf : "section2",
"staticroutes-%s" % intf : "a:b:c d:e:f"
}, token)
conn.save_system(sys_id, token)