Skip to content
Ask AI

Event-Applet-Netconf

YANG Pathget/get-configedit-configrpc
/event-applets/{name}Ymerge, replace, create, delete—
/event-applets/{name}/actions/{priority}Ymerge, replace, create, delete—
/event-applets/{name}/triggerYmerge, replace, create, delete—

This chapter provides examples on how to use Netconf to manage Event Applet configurations on AsterNOS devices.

Event Applets allow you to define automated responses to system events. Each applet consists of a trigger (monitored interfaces that fire the applet when they go down) and a set of actions (CLI commands to execute when triggered).

Currently supported trigger type: interface-down (intf-down). Currently supported action type: CLI command execution (klish).

For detailed YANG definitions, please refer to yang/asternos-event-applet.yang.


Create Event Applet with Interface-Down Trigger and CLI Actions

Section titled “Create Event Applet with Interface-Down Trigger and CLI Actions”

This example creates a complete event applet that monitors Ethernet interfaces and automatically executes CLI commands when any of them goes down.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet"
operation="create">
<event-applet>
<name>link-down-recovery</name>
<warning>true</warning>
<trigger>
<event-type>intf-down</event-type>
<interfaces>Ethernet1</interfaces>
<interfaces>Ethernet2</interfaces>
</trigger>
<actions>
<action>
<priority>0</priority>
<action-type>klish</action-type>
<command>interface ethernet 5</command>
</action>
<action>
<priority>1</priority>
<action-type>klish</action-type>
<command>shutdown</command>
</action>
<action>
<priority>2</priority>
<action-type>klish</action-type>
<command>no shutdown</command>
</action>
</actions>
</event-applet>
</event-applets>
</top>
</config>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
message-id="urn:uuid:f20f182e-f568-49d0-ad82-aaac24244f74">
<ok/>
</rpc-reply>

Create Event Applet with Trigger Only (No Actions)

Section titled “Create Event Applet with Trigger Only (No Actions)”

You can create an applet without actions and add them later.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet"
operation="create">
<event-applet>
<name>port-down-monitor</name>
<warning>false</warning>
<trigger>
<event-type>intf-down</event-type>
<interfaces>PortChannel0001</interfaces>
</trigger>
</event-applet>
</event-applets>
</top>
</config>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>

Add one or more actions to an applet that was previously created without actions.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet>
<name>port-down-monitor</name>
<actions operation="create">
<action>
<priority>0</priority>
<action-type>klish</action-type>
<command>interface ethernet 5</command>
</action>
<action>
<priority>0.5</priority>
<action-type>klish</action-type>
<command>shutdown</command>
</action>
</actions>
</event-applet>
</event-applets>
</top>
</config>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>

Replace the command of an existing action using the merge operation.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet>
<name>port-down-monitor</name>
<actions operation="replace">
<action>
<priority>0</priority>
<command>show interface counters errors</command>
</action>
</actions>
</event-applet>
</event-applets>
</top>
</config>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>

Remove a specific action by its priority key.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet>
<name>port-down-monitor</name>
<actions>
<action operation="delete">
<priority>0</priority>
</action>
</actions>
</event-applet>
</event-applets>
</top>
</config>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>

Remove event applets and all its associated actions and trigger bindings.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet"
operation="delete">
<event-applet>
<name>port-down-monitor</name>
</event-applet>
</event-applets>
</top>
</config>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>

Add interfaces to an existing applet’s trigger monitoring list.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet>
<name>link-down-recovery</name>
<trigger operation="merge">
<interfaces>Ethernet3</interfaces>
<interfaces>PortChannel0002</interfaces>
</trigger>
</event-applet>
</event-applets>
</top>
</config>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>

Remove specific interfaces from the trigger monitoring list.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet>
<name>link-down-recovery</name>
<trigger>
<interfaces operation="delete">Ethernet1</interfaces>
</trigger>
</event-applet>
</event-applets>
</top>
</config>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<ok/>
</rpc-reply>

Toggle the warning flag to control whether a syslog message is emitted when the applet is triggered.

Enable warning:

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet operation="merge">
<name>link-down-recovery</name>
<warning>true</warning>
</event-applet>
</event-applets>
</top>
</config>

Disable warning:

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet operation="merge">
<name>link-down-recovery</name>
<warning>false</warning>
</event-applet>
</event-applets>
</top>
</config>

Retrieve the full configuration of all event applets via get-config.

<filter type="subtree">
<top>
<event-applets/>
</top>
</filter>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet>
<name>link-down-recovery</name>
<warning>true</warning>
<trigger>
<event-type>intf-down</event-type>
<interfaces>Ethernet1</interfaces>
<interfaces>Ethernet2</interfaces>
<interfaces>Ethernet3</interfaces>
<interfaces>PortChannel0002</interfaces>
</trigger>
<actions>
<action>
<priority>0</priority>
<action-type>klish</action-type>
<command>interface ethernet 5</command>
</action>
<action>
<priority>1</priority>
<action-type>klish</action-type>
<command>shutdown</command>
</action>
<action>
<priority>2</priority>
<action-type>klish</action-type>
<command>no shutdown</command>
</action>
</actions>
</event-applet>
<event-applet>
<name>port-down-monitor</name>
<warning>false</warning>
<trigger>
<event-type>intf-down</event-type>
<interfaces>PortChannel0001</interfaces>
</trigger>
<actions>
<action>
<priority>0</priority>
<action-type>klish</action-type>
<command>show interface counters errors</command>
</action>
</actions>
</event-applet>
</event-applets>
</top>
</data>
</rpc-reply>

Retrieve configuration of a single event applet by name.

<filter type="subtree">
<top>
<event-applets>
<event-applet>
<name>link-down-recovery</name>
</event-applet>
</event-applets>
</top>
</filter>

Response example

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet">
<event-applet>
<name>link-down-recovery</name>
<warning>true</warning>
<trigger>
<event-type>intf-down</event-type>
<interfaces>Ethernet1</interfaces>
<interfaces>Ethernet2</interfaces>
<interfaces>Ethernet3</interfaces>
<interfaces>PortChannel0002</interfaces>
</trigger>
<actions>
<action>
<priority>0</priority>
<action-type>klish</action-type>
<command>interface ethernet 5</command>
</action>
<action>
<priority>1</priority>
<action-type>klish</action-type>
<command>shutdown</command>
</action>
<action>
<priority>2</priority>
<action-type>klish</action-type>
<command>no shutdown</command>
</action>
</actions>
</event-applet>
</event-applets>
</top>
</data>
</rpc-reply>

Section titled “Complete Workflow: Link-Down Auto-Recovery”

This end-to-end example demonstrates a practical use case: automatically attempting to recover a failing link by cycling the interface state.

Step 1: Create an applet with multi-step recovery actions.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet"
operation="create">
<event-applet>
<name>auto-recovery</name>
<warning>true</warning>
<trigger>
<event-type>intf-down</event-type>
<interfaces>Ethernet5</interfaces>
<interfaces>Ethernet6</interfaces>
</trigger>
<actions>
<action>
<priority>0</priority>
<action-type>klish</action-type>
<command>show interface status</command>
</action>
<action>
<priority>1</priority>
<action-type>klish</action-type>
<command>interface ethernet 5</command>
</action>
<action>
<priority>2</priority>
<action-type>klish</action-type>
<command>shutdown</command>
</action>
<action>
<priority>3</priority>
<action-type>klish</action-type>
<command>no shutdown</command>
</action>
</actions>
</event-applet>
</event-applets>
</top>
</config>

Step 2: Verify the configuration was applied.

<get-config>
<source><running/></source>
<filter type="subtree">
<top>
<event-applets>
<event-applet>
<name>auto-recovery</name>
</event-applet>
</event-applets>
</top>
</filter>
</get-config>

Step 3: Later, if Ethernet5/6 goes down, the applet fires automatically:

  1. Logs the last 20 system messages for diagnostics
  2. Enters interface context for Ethernet5
  3. Administratively shuts down the interface
  4. Brings it back up (link flap recovery)

Step 4: After maintenance, remove the applet when no longer needed.

<config>
<top>
<event-applets xmlns="http://asterfusion.com/ns/yang/asternos-event-applet"
operation="delete">
<event-applet>
<name>auto-recovery</name>
</event-applet>
</event-applets>
</top>
</config>

Tree Diagram

module: asternos-event-applet
+--rw event-applets
+--rw event-applet* [name]
+--rw name string
+--rw trigger
| +--rw event-type identityref
| +--rw (event-params)?
| +--:(intf-down)
| +--rw interfaces* union
+--rw actions
| +--rw action* [priority]
| +--rw priority string
| +--rw action-type identityref
| +--rw (payload)?
| +--:(klish)
| +--rw command string
+--rw warning? boolean

Table of Properties

NameRequiredType/RangeDescription
event-appletsMPath-only node, has no configurable value.
event applet configuration.
event-appletMPath-only node, has no configurable value.
nameONone
triggerMPath-only node, has no configurable value.
The event that fires this applet. Exactly one trigger per applet.
event-typeM”intf-down”Which kind of event fires this applet. New event sources are added by defining a new identity based on event-type.
interfacesOEthernet nameInterfaces monitored by this trigger. Accepts either an

Ethernet port or a port-channel.
actionsMPath-only node, has no configurable value.
Ordered set of actions executed when the applet fires.

Actions run in ascending priority order; within the same priority the order is unspecified.
actionMPath-only node, has no configurable value.
A single action bound to this applet. Its payload format is selected by action-type.
priorityONoneExecution order key, range 0-9999.9999. The smaller the value the earlier the action runs.
action-typeM”klish”Which execution format payload carries. New formats are added by defining a new identity based on action-type.
commandMstring (length 1..4096)klish CLI command to execute, e.g.

‘shutdown’ or ‘show interface counters’.
warningO”true"
"false”
print warning to syslog when applet is triggered.

Tree Diagram

module: asternos-event-applet
+--rw event-applets

Tree Diagram

module: asternos-event-applet
+--rw event-applets