On Mon, 28 Mar 2011 17:26:31 -0400, Gary Algier <gaa(a)ulticom.com> wrote:
On 03/28/11 16:23, Scott Henson wrote:
> On Mon, 28 Mar 2011 09:02:20 -0400, Gary Algier<gaa(a)ulticom.com> wrote:
>> Hello,
>>
>> I would like to write a cobbler trigger to do something every time I add a
>> system. I looked at the documentation at:
>>
https://fedorahosted.org/cobbler/wiki/CobblerTriggers
>
> The best example I can give you is the triggers found in the modules
> directory in the cobbler source [1]. The install_* ones and sync_*
> ones. The api passed in is a copy of BootAPI (which is the actual name
> of CobblerAPI). It is normally not ok to use BootAPI for various
> reasons, but in this case the trigger is running inside of cobblerd and
> can safely make use of BootAPI.
>
> [1] -
http://git.fedorahosted.org/git/?p=cobbler;a=tree;f=cobbler/modules;h=a6f...
>
How do I specify a module to be run pre-system-add?
Using an executable I would put it in:
/var/lib/cobbler/triggers/add/system/pre
with a name of my choosing. Do I create a similar directory structure and
place it in:
/usr/lib/python2.4/site-packages/cobbler/modules/add/system/pre
No, you will need to put it in
/usr/lib/python2.4/site-package/cobbler/modules and name it
install_pre_*. You will then want to create a function in that module
named 'register' that takes no arguments and returns
"/var/lib/cobbler/triggers/install/pre/*". Then you will want to have a
function called 'run', which takes api, args, and logger. This will be
the function that does the magic.
How does it know when to apply the modules in:
/usr/lib/python2.4/site-packages/cobbler/modules/
or are they applied on every operation?
Cobblerd loads all python files in that directory and runs the register
function to identify what kind of module it is.
It looks like they are run every time and the register function tells
cobbler
when it should be used, but it only seems to define pre vs post.
You can return any valid trigger path and it should run it in the
instances when the trigger would be run.
--
Scott Henson
Red Hat CIS Operator
WVU Alum BSAE/BSME