This article explains the difference in system behavior while calling an event-script directly under "event-options event-script" as against calling it by using an event-policy under the "event-options policy" hierarchy.
There are two ways in which an event-options script can be called. The first method is with the help of an event-options policy.
labroot@host# show |compare [edit] + event-options { + policy DISABLE-INTERFACE { + events [ kernel system ]; + within 180 { + trigger on 1; + } + attributes-match { + system.message matches "Starting of initial processes complete"; + } + then { + event-script disable-interface-generic.slax { >> script file is called here + arguments { + interface lo0; + unit 101; + } + } + } + } + }
The file disable-interface-generic.slax is not present in the directory /var/db/scripts/event, and the system while committing the above change will not check for the presence of this file in the /var/db/scripts/event directory.
labroot@host> file list /var/db/scripts/event /var/db/scripts/event: labroot@host> labroot@host# commit commit complete
The second method is to directly call the event-script file under the event-options event-script hierarchy.
labroot@host# set event-options event-script file test_event.slax
In this method, the script checks for the presence of the file test_event.slax in the /var/db/scripts/event directory and if the file does not exist, it throws a validation error while committing this change.
labroot@host> file list /var/db/scripts/event /var/db/scripts/event: labroot@host> labroot@host# commit check error: invalid filename: /var/db/scripts/event//test_event.slax error: <xnm:error xmlns=http://xml.juniper.net/xnm/1.1/xnm xmlns:xnm=http://xml.juniper.net/xnm/1.1/xnm> error: <message> error: Cannot open configuration file: ì¹éØÿÿ error: </message> error: </xnm:error> error: Loading the configuration from event scripts failed error: configuration check-out failed
While using the second method, consider for example that the script file is configured under the event-options event-script hierarchy and after configuration, at some point, it is deleted from /var/db/scripts/event and the Routing Engine is rebooted. In this case, the configuration load will fail while the RE is booting up since the script file that is called no longer exists in the /var/db/scripts/event directory.
The above validation can be overcome by using the optional knob "set event-options event-script optional."
2022-05-25: Version 1