Commit Script Overview
Understanding Commit Scripts
Junos OS commit scripts enable users to customize the validation process of their configurations in accordance with their own practices and policies and enforce custom configuration rules during the commit process. When a candidate configuration is committed, it is inspected by each active commit script. If a configuration violates your custom rules, the script can instruct Junos OS to take appropriate action. A commit script can:
Generate and display custom warning messages to the user
Generate and log custom system log (syslog) messages
Change the configuration to conform to the custom business rules
Generate a commit error and halt the commit operation
Commit scripts are based on the Junos XML management protocol and the Junos XML API. The Junos XML management protocol is an XML based RPC mechanism, and the Junos XML API is an XML representation of Junos OS configuration statements and operational mode commands.
Commit scripts can be written in Python, Extensible Stylesheet Language Transformations (XSLT), or Stylesheet Language Alternative syntaX (SLAX). The Junos XML API defines an XML equivalent for all statements in the Junos configuration hierarchy . Commit scripts use XML Path Language (XPath) to locate the configuration objects to be inspected and automation script constructs to specify the actions to perform on the configuration objects. The actions can change the configuration or generate messages about it.
Additionally, you can create macros, which allow you to create custom configuration syntax that simplifies the task of configuring a device running Junos OS. By itself, your custom syntax has no operational impact on the device. A corresponding commit script macro uses your custom syntax as input data for generating standard Junos OS configuration statements that execute your intended operational impact.
To view the device's current configuration in Extensible Markup Language (XML) in the command-line interface (CLI), issue the show configuration | display xml command in operational mode. To view your configuration in commit-script-style XML, issue the show configuration | display commit-scripts view command. Commit-script-style XML view displays the configuration in the format that would be input to a commit script.
Benefits of Commit Scripts
Commit scripts provide the following benefits:
Enable the enforcement of custom configuration rules
Improve network reliability and uptime by minimizing human error
Automatically correct configuration mistakes during a commit operation
Abstract and simplify complex configurations
Enforce scaling limits for critical settings