[et-mgmt-tools] adding a new system with the cobbler api?
Michael DeHaan
mdehaan at redhat.com
Tue Feb 12 20:06:20 UTC 2008
Jennifer Cranfill wrote:
> I'm having trouble adding a new system using the cobbler python api
> with version 0.7.2 (I have not tried this with any other versions).
>
> Here is my python code:
>
> >>> from cobbler import api
> >>> cobbler_api = api.BootAPI()
> >>> new_sys = cobbler_api.new_system()
> >>> new_sys.name = 'testmachine'
> >>> new_sys.profile = 'cserver_centos51_x86'
> >>> cobbler_api.add_system(new_sys)
> True
>
> That works, but it doesn't show up in the cobbler command line:
> $ cobbler system list | grep test
> $
>
> Am I missing something?
>
> Thanks!
>
> --
> Jennifer Cranfill
> Systems Engineer
> Sony Pictures Imageworks
> cranfill at imageworks.com
>
Aha! You've uncovered a bug in one of the new API functions. Thanks
for reporting this.
In the old API, there was basically two types of adds ... one that adds
things temporarily (which is what happens when the API
is initialized, and another that happens when you save an object, that
does nudge the serializer into saving state. Those two types
are still there, but I added a higher level function to make needing to
know about the collections interface less important. Looks like that
function isn't doing it correctly though, and I need to fix that.
The following will work for you now:
cobbler_api.systems().add(new_sys,with_copy=True)
And I'll fix the version in the 0.7.X branch to do the right thing when
you call it. (Basically it just needs to pass some extra flags
down to the systems().add call).
--Michael
More information about the et-mgmt-tools
mailing list