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

Michael DeHaan mdehaan at redhat.com
Wed Apr 9 15:03:50 UTC 2008


Jennifer Cranfill wrote:
> 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
>
> _______________________________________________
> et-mgmt-tools mailing list
> et-mgmt-tools at redhat.com
> https://www.redhat.com/mailman/listinfo/et-mgmt-tools

Right!   I added that example here -- 
https://fedorahosted.org/cobbler/wiki/CobblerTriggers -- so other people 
could find it when they were
reading the docs.

Thanks!


--Michael









More information about the et-mgmt-tools mailing list