EventHandlers Package — pynag 0.8.5 documentation

### Navigation

- index
- modules |
- next |
- previous |
- pynag 0.8.5 documentation »
- The pynag module »
- Model Package »

# EventHandlers Package

## `EventHandlers` Package

This module is experimental.

The idea is to create a mechanism that allows you to hook your own events into an ObjectDefinition instance.

This enables you for example to log to file every time an object is rewritten.

class `pynag.Model.EventHandlers.` `BaseEventHandler`(debug=False)
  `debug`(object_definition, message)

    Used for any particual debug notifications

  `pre_save`(object_definition, message)

    Called at the beginning of save()

  `save`(object_definition, message)

    Called when objectdefinition.save() has finished

  `write`(object_definition, message)

    Called whenever a modification has been written to file

exception `pynag.Model.EventHandlers.` `EventHandlerError`(message, errorcode=None, errorstring=None)

  Bases: `exceptions.Exception`

class `pynag.Model.EventHandlers.` `FileLogger`(logfile='/var/log/pynag.log', debug=False)

  Bases: `pynag.Model.EventHandlers.BaseEventHandler`

  Handler that logs everything to file

  `debug`(object_definition, message)

    Used for any particular debug notifications

  `save`(object_definition, message)

    Called when objectdefinition.save() has finished

  `write`(object_definition, message)

    Called whenever a modification has been written to file

class `pynag.Model.EventHandlers.` `GitEventHandler`(gitdir, source, modified_by, auto_init=False, ignore_errors=False)

  Bases: `pynag.Model.EventHandlers.BaseEventHandler`

  `debug`(object_definition, message)
  `get_uncommited_files`()

    Returns a list of files that are have unstaged changes

  `is_commited`()

    Returns True if all files in git repo are fully commited

  `pre_save`(object_definition, message)

    Commits object_definition.get_filename() if it has any changes

  `save`(object_definition, message)
  `write`(object_definition, message)

class `pynag.Model.EventHandlers.` `NagiosReloadHandler`(nagios_init, *args, **kwargs)

  Bases: `pynag.Model.EventHandlers.BaseEventHandler`

  This handler reloads nagios every time that a change is made. This is only meant for small environments

  `debug`(object_definition, message)

    Used for any particual debug notifications

  `pre_save`(object_definition, message)

    Called at the beginning of save()

  `save`(object_definition, message)

    Called when objectdefinition.save() has finished

  `write`(object_definition, message)

    Called whenever a modification has been written to file

class `pynag.Model.EventHandlers.` `PrintToScreenHandler`(debug=False)

  Bases: `pynag.Model.EventHandlers.BaseEventHandler`

  Handler that prints everything to stdout

  `debug`(object_definition, message)

    Used for any particual debug notifications

  `save`(object_definition, message)

    Called when objectdefinition.save() has finished

  `write`(object_definition, message)

    Called whenever a modification has been written to file

### Navigation

- index
- modules |
- next |
- previous |
- pynag 0.8.5 documentation »
- The pynag module »
- Model Package »