Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nokia/moler/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Event extends ConnectionObserver for long-running observation tasks. Unlike Command, which fires once and completes, an Event keeps watching the connection and triggers a callback every time a matching pattern appears.
- Monitoring for log messages, alarms, or state changes.
- Collecting repeated occurrences of a pattern (e.g., every SNMP trap).
- Triggering actions in response to device output without stopping the observation.
Event is abstract. Subclass it and implement data_received(), pause(), and resume().Constructor
The connection to observe.
How many times the event must occur before it automatically finishes.
-1 means infinite — the event keeps running until explicitly cancelled or break_event() is called.The runner managing background execution. Resolved from the connection or the global default if
None.Public methods
start
ConnectionObserver.start().
Override the event’s timeout. Rarely needed given the default infinite-like timeout.
self.
add_event_occurred_callback
Function to call when the event fires. Called as
callback(**callback_params).Keyword arguments passed to
callback each time it is called.MolerException if a callback is already registered.
remove_event_occurred_callback
event_occurred
data_received() when a match is found. Appends event_data to the internal occurrence list, triggers notify(), and — if till_occurs_times is positive and the count is reached — calls break_event() automatically.
Data associated with this occurrence (e.g., the matched line or a parsed dict).
ResultAlreadySet if the event is already done.
notify
event_occurred().
get_last_occurrence
event_data value from the most recent occurrence, or None if the event has not yet occurred.
break_event
If
False and the number of occurrences is less than till_occurs_times, a MolerException is set instead of a result. Set to True to force completion regardless of occurrence count.get_long_desc / get_short_desc
"Event '<module>.<ClassName>(id:...)'". Override in subclasses for more informative output.
enable_log_occurrence / disable_log_occurrence
INFO level. Logging is enabled by default.
Abstract methods to implement
data_received (from ConnectionObserver)
self.event_occurred(parsed_data) whenever a match is found.
pause
resume() is called.
resume
pause().
Key attributes
| Attribute | Type | Description |
|---|---|---|
callback | callable | None | The registered callback (as a functools.partial). |
callback_params | dict | Parameters passed to the callback. |
till_occurs_times | int | Target occurrence count. -1 = infinite. |
event_name | str | Lower-case underscore form of the class name. |