[et-mgmt-tools] Help using the Cobbler API in triggers

Jennifer Cranfill cranfill at imageworks.com
Wed Apr 9 04:15:03 UTC 2008


Garrett Honeycutt wrote:
> My goal is to access a variable within Cobbler, $hostname for example,
> and use that in a trigger that is run whenever a system is added. Below
> is some pseudo code to demonstrate my aim.
> 
> os.system("/usr/local/sbin/dostuff.sh $hostname")

Cobbler passes the name of the system as the first argument to the 
command. If your system name is the hostname, then in python you can 
just use something simple like:

machine = sys.argv[1]

If your system name is not the hostname then you can query the hostname 
of the system from Cobbler. Here is some python code I've been using:

from cobbler import api
cobbler_api = api.BootAPI()
systems = cobbler_api.systems()
box = systems.find(sys.argv[1])

I'm sure there are other (and probably better) ways as well.

--
Jennifer Cranfill
Systems Engineer
Sony Pictures Imageworks




More information about the et-mgmt-tools mailing list