Shuichi Ihara wrote:
> Hi,
>
> I'm attempting to create some python scripts with cobbler APIs.
> Because, API based scripts are much faster than 'cobbler xxx' commands.
>
> Now, I have a couple of questions about cobbler API.
>
> 1. Does API support everything that is supported in 'cobbler xxx' commands?
>   

The cobbler command line is written in the Python API and can do 100% of 
everything.

The XMLRPC API can do all edit operations, and cobbler sync.   This 
covers 90% of operations.  The holdback from doing the rest of them 
would be including a task engine, which may be done at a later date.   
Such an engine would need to log output and make it available in the web 
interface.
> 2. How can we set 'macaddress' and 'ipaddress' to system object via API?
> What's object name? Is there any pointers or good source file to know all
> cobbler object name for cobbler API?
>
>   

It looks like you're using the Python API from what you have below 
(excellent!), in which case you have numerous examples.  The best thing 
you can do is look in the "modules/" directory of a source checkout.  
The cobbler CLI makes every call for every command line argument there, 
and you can see what calls are made for each CLI getopt argument.

(If you were using XMLRPC, instead see the tests at the bottom of 
remote.py, or CobblerWeb.py, the source for the actual webapp... the 
Python API is, however, much more transparent).

> 3. When if I want to update the value in some objects, we always
> have to use find() as first, is it right? I mean the following code (e.g. for
> updating hostname) is simplest way and reasonable?
>
> api = api.BootAPI()
> s = api.systems().find(abc)
> s.hostname = 'xyz'
> api.systems().add(s,with_copy=True)
>   

Pretty close.  The main thing is that I've exposed most of the internals 
directly in API.py, so other than calling methods on the actual cobbler 
objects like 'system', you can access everything through the API 
module.    Anything lower level down is subject to change and isn't a 
stable API.  api.py, however, is stable.

import cobbler.api as capi               # avoid namespace issue as you 
use 'api' later.
api = capi.BootAPI()                     
s = api.find_system(name='abc')    # abc is a string, plus find is a top 
level API call, it's best not to go any deeper and just use the api.py 
implementation
s.set_hostname('xyz')                     # use the set_ methods to 
ensure validation is always run on the input (very important!)
api.add_system(s)                          # again, use the top level 
API function, which sets reasonable defaults for all the arguments



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

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

Reply via email to