Event-Applet-Netconf
此内容尚不支持你的语言。
Event Applet
Section titled “Event Applet”Resources Summary
Section titled “Resources Summary”| YANG Path | get/get-config | edit-config | rpc |
|---|---|---|---|
| /event-applets/{name} | Y | merge, replace, create, delete | — |
| /event-applets/{name}/actions/{priority} | Y | merge, replace, create, delete | — |
| /event-applets/{name}/trigger | Y | merge, replace, create, delete | — |
Examples
Section titled “Examples”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 Actions to an Existing Event Applet
Section titled “Add Actions to an Existing Event Applet”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>Merge (Modify) an Action
Section titled “Merge (Modify) an Action”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>Delete an Action from an Event Applet
Section titled “Delete an Action from an Event Applet”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>Delete an Event Applet
Section titled “Delete an Event Applet”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>Bind Interfaces to an Existing Trigger
Section titled “Bind Interfaces to an Existing Trigger”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>Unbind Interfaces from a Trigger
Section titled “Unbind Interfaces from a Trigger”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>Enable / Disable Warning Logging
Section titled “Enable / Disable Warning Logging”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>Get All Event Applets
Section titled “Get All Event Applets”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>Get a Specific Event Applet
Section titled “Get a Specific Event Applet”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>Complete Workflow: Link-Down Auto-Recovery
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:
- Logs the last 20 system messages for diagnostics
- Enters interface context for Ethernet5
- Administratively shuts down the interface
- 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>Properties Descriptions
Section titled “Properties Descriptions”event applet configuration
Section titled “event applet configuration”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? booleanTable of Properties
| Name | Required | Type/Range | Description |
|---|---|---|---|
| event-applets | M | Path-only node, has no configurable value. event applet configuration. | |
| event-applet | M | Path-only node, has no configurable value. | |
| name | O | None | |
| trigger | M | Path-only node, has no configurable value. The event that fires this applet. Exactly one trigger per applet. | |
| event-type | M | ”intf-down” | Which kind of event fires this applet. New event sources are added by defining a new identity based on event-type. |
| interfaces | O | Ethernet name | Interfaces monitored by this trigger. Accepts either an Ethernet port or a port-channel. |
| actions | M | Path-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. | |
| action | M | Path-only node, has no configurable value. A single action bound to this applet. Its payload format is selected by action-type. | |
| priority | O | None | Execution order key, range 0-9999.9999. The smaller the value the earlier the action runs. |
| action-type | M | ”klish” | Which execution format payload carries. New formats are added by defining a new identity based on action-type. |
| command | M | string (length 1..4096) | klish CLI command to execute, e.g. ‘shutdown’ or ‘show interface counters’. |
| warning | O | ”true" "false” | print warning to syslog when applet is triggered. |
Action
Section titled “Action”Tree Diagram
module: asternos-event-applet +--rw event-appletsTrigger
Section titled “Trigger”Tree Diagram
module: asternos-event-applet +--rw event-applets