Event Handlers Configuration

The yangcli-pro program can access an event handler mapping configuration. An event-handler is a mapping between notification (or set of notifications) and an event handler script. A session-cfg can specify event-handlers to install when the session starts. The event-handler command can also be run in session mode to apply to the current session. These named event handler mapping configuration are saved in a configuration file. Use the --autoeventhandlers to suppress automatic loading of this file. The default is to load this file at start-up and save it upon exit.

By default, the event handlers configuration is saved in $HOME/.yumapro/yangcli_pro_event_handlers.conf. To override this file, set --autoeventhandlers=false and use the event-handler-cfg command to load a specific event-handlers configuration file.

Creating New Event Handlers

Use event-handler-cfg 'create' command to create a new event handler. The created event handler does not actually cause any event scripts to be invoked because there has to be a session-cfg mapping. The session-cfg command has a parameter ‘use-event-handler’.

> event-handler-cfg ?

brief          Show brief help text
create         An event-handler name to use to create a new event handler.
delete         Delete the specified event-handler from the saved event hand...
event-name     The event name for the event handler.
full           Show full help text
module-name    The module name for the event handler.
normal         Show normal help text
save           Save the specified event handler to the saved event handlers...
script         The yangcli script name to use for the event handler.
shell-script   The shell script name to use for the event handler.
show           Show the specified event-handler or the current event-handle…

> event-handler-cfg create=handler-ses-change module-name=ietf-netconf-notifications event-name=netconf-config-change shell-script=ses-change.sh.

A new event_handler is created: event_handler-id=handler-ses-change

Event Handler 'handler-ses-change'

> event-handler-cfg show=handler-ses-change
   Event Handler 'handler-ses-change'

> event-handler-cfg delete=handler-ses-change
Deleted saved event_handler 'handler-ses-change'


Multiple Event Handlers

Multiple event handlers can be active at once, however only one event script at a time can be invoked. This will be improved in a future release.

Saving the Configured Event Handlers

The event handlers configuration can be saved or loaded at run-time, if the --autoeventhandlers=true parameter is used (the default). The event-handlers-cfg save command is used to save this file.

> event-handlers-cfg save

Saved 3 event_handlers OK to '~/.yumapro/.yangcli_pro_event_handlers.conf'


To save the event handlers to a different file, simply provide the filespec in the 'event-handler-cfg save' command:

> event-handlers-cfg save myeventhandlers.conf

Saved 2 eventhandlers OK to 'myeventhandlers.conf'


Loading Additional Configured Event Handlers

Additional event handlers can be added to the configuration in memory with the 'event-handlers-cfg load' command. The named event handlers in the file cannot conflict with names already in use or the duplicate event handlers will be skipped.

session-A> event-handlers-cfg load myeventhandlers.conf

Loaded saved event_handlers OK from 'myeventhandlers.conf'


Displaying the Configured Event Handlers

The event-handlers that are available can be displayed with the event-handlers-cfg 'show' command. The --brief and --full extensions are available for this command.

> event-handlers-cfg show

Saved event_handlers source: '~/.yumapro/.yangcli_pro_event_handlers.conf'

   Event Handler 'handler-ses-change'
   Event Handler 'handler-ses-start'
   Event Handler 'handler-ses-end'

Event Handlers Variables

The event handler is passed 8 variables in the dollar parameters for the script





script name



handler name being invoked



module name of the event



Event name



eventTime field from the notification



XML file of the <notification> element



session-name that received the event



IP address of the server that sent the event

The raw event filespec to XML file that contains the complete <notification> element for this event. This file will be deleted after the script is invoked.

Example XML File:

<?xml version="1.0" encoding="UTF-8"?>
<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
  <netconf-config-change xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
      <target xmlns:nacm="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">/nacm:nacm</target>