[et-mgmt-tools] Introducing cobbler triggers (coming in 0.4.7)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This feature is to be included in the yet-to-be-released 0.4.7 ...

Suppose you are working with a 3rd party system of some kind and want to interact with it when cobbler commands are run. Examples potentially include doing some custom logging, or perhaps interacting with some remote resource (power management? networking hardware? who knows?).

Triggers provide a way to do this.

Cobbler 0.4.7 will include the following trigger directories:

/var/lib/cobbler/triggers/add/profile
/var/lib/cobbler/triggers/add/system
/var/lib/cobbler/triggers/add/distro
/var/lib/cobbler/triggers/add/repo
/var/lib/cobbler/triggers/delete/profile
/var/lib/cobbler/triggers/delete/system
/var/lib/cobbler/triggers/delete/distro
/var/lib/cobbler/triggers/delete/repo


When an object is added or deleted through the cobbler command line (or the API), all trigger scripts in these directories will be executed. The parameter to the script will be the name of the object being added or deleted. If you have a trigger for "delete/system", and run "cobbler system delete --name=AA:BB:CC:DD:EE:FF", the script's parameter will be "AA:BB:CC:DD:EE:FF" (no quotes).

The most simple example would just printing out the name of what is being added.
A more complex example would be showing all of the details of the object.

Here's a more complex example using the Cobbler API. Triggers don't have to use the Cobbler API, but if they want to interact with the Cobbler object tree, they can learn a lot by doing so...

Here's an example echo trigger -- /var/lib/cobbler/triggers/add/profile/echo.py -- I've left it rather short and compressed for demo purposes ... it can definitely be made a lot cleaner :)

#!/usr/bin/python

import sys
import cobbler.api as cobbler_api

if __name__ == "__main__":
   print sys.argv
   print cobbler_api.BootAPI().distros().find(sys.argv[1]).printable()


This was originally written as a suggestion from the Stateless Project (http://fedoraproject.org/wiki/StatelessLinux) -- if anyone has any suggestions on other things they might like triggers for, or questions about how they work, please comment. For those interested in playing with the source, I've already pushed an initial version of the above ... "make rpms" will build cobbler, and install the RPM from the "rpm-build" directory...

--Michael DeHaan





[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux