summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2022-06-07 14:34:49 +0300
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-06-07 12:12:07 +0000
commit06c0d2f2f9f4b9c97eb9868df166d787ca367ee7 (patch)
tree4646ea28f7e04e2cbb179763bbf77a47762e4bd3 /src/conf_mode
parent03d236f3905ac84db293d1dab8ac78556fb2bdbf (diff)
downloadvyos-1x-06c0d2f2f9f4b9c97eb9868df166d787ca367ee7.tar.gz
vyos-1x-06c0d2f2f9f4b9c97eb9868df166d787ca367ee7.zip
event-handler: T3083: Extended event-handler features
* Added the ability to filter by a syslog identifier * Added the ability to pass arguments to a script * Added the ability to pass preconfigured environment variables to a script * A message that triggered a script is now passed in the `message` variable and can be used in a script * Replaced `call()` to `run()`, since stdout are not need to be printed
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/service_event_handler.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/conf_mode/service_event_handler.py b/src/conf_mode/service_event_handler.py
index cf4aba49b..bb12da11d 100755
--- a/src/conf_mode/service_event_handler.py
+++ b/src/conf_mode/service_event_handler.py
@@ -18,7 +18,7 @@ import json
from pathlib import Path
from vyos.config import Config
-from vyos.util import call
+from vyos.util import call, dict_search
from vyos import ConfigError
from vyos import airbag
@@ -48,9 +48,16 @@ def verify(config):
return None
for name, event_config in config.items():
- if 'pattern' not in event_config or 'script' not in event_config:
+ if not dict_search('filter.pattern', event_config) or not dict_search(
+ 'script.path', event_config):
raise ConfigError(
- 'Event-handler: both pattern and script items are mandatory!')
+ 'Event-handler: both pattern and script path items are mandatory'
+ )
+
+ if dict_search('script.environment.message', event_config):
+ raise ConfigError(
+ 'Event-handler: "message" environment variable is reserved for log message text'
+ )
def generate(config):