Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

Creating a Commit Script Macro to Read the Custom Syntax and Generate Related Configuration Statements

 

Commit script macros enable you to expand custom configuration syntax into standard Junos OS configuration statements. By itself, the custom syntax in an apply-macro statement has no operational impact on the device. To give meaning to your syntax, there must be a corresponding commit script that uses the syntax as data for generating related Junos OS statements.

To write such a script:

  1. At the start of the script, include the appropriate commit script boilerplate from Required Boilerplate for Commit Scripts. It is reproduced here for convenience:

    XSLT Boilerplate

    SLAX Boilerplate

    Python Boilerplate

  2. At the position indicated by the comment “insert your code here,” include programming instructions that inspect the configuration for the apply-macro statement at a specified hierarchy level and change the configuration to include standard Junos OS syntax.

    For an example that uses both types of instructions and includes a line-by-line analysis of the XSLT syntax, see Example: Creating Custom Configuration Syntax with Commit Script Macros.

  3. Save the script with a meaningful name.
  4. Copy the script to either the /var/db/scripts/commit directory on the hard disk or the /config/scripts/commit directory on the flash drive.

    For information about setting the storage location for commit scripts, see Storing and Enabling Scripts and Storing Scripts in Flash Memory.

    If the device has dual Routing Engines and you want the script to take effect on both of them, you must copy the script to the /var/db/scripts/commit or the /config/scripts/commit directory on both Routing Engines. The commit synchronize command does not copy scripts between Routing Engines.

  5. Enable the script by including the file filename statement at the [edit system scripts commit] hierarchy level.

  6. If the script makes transient changes, include the allow-transients statement at the [edit system scripts commit] hierarchy level.

If all the commit scripts run without errors, any persistent changes are loaded into the candidate configuration, and any transient changes are loaded into the checkout configuration, but not to the candidate configuration. The commit process then continues by validating the configuration and propagating changes to the affected processes on the device running Junos OS.