Supported Platforms
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Overview of Creating Custom Configuration Syntax with Macros
- ACX, EX, M, MX, SRX, T Series
- How Macros Work
- ACX, M, MX, PTX, T Series
- Example: Creating Custom Configuration Syntax with Macros
Creating a Macro to Read the Custom Syntax and Generate Related 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 standard Junos OS statements. To write such a script, follow these steps:
- At the start of the script, include the Extensible Stylesheet
Language Transformations (XSLT) or
Stylesheet Language Alternative Syntax (SLAX) boilerplate from Required Boilerplate for Commit Scripts. It is reproduced here for convenience:
XSLT Boilerplate
<?xml version="1.0" standalone="yes"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:junos="http://xml.juniper.net/junos/*/junos"
xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm"
xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0">
<xsl:import href="../import/junos.xsl"/>
<xsl:template match="configuration">
<!-- ... Insert your code here ... -->
</xsl:template>
</xsl:stylesheet>SLAX Boilerplate
version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
match configuration {
/*
* Insert your code here
*/
} - At the position indicated by the comment “Insert your code here,” include XSLT programming
instructions (or their SLAX equivalents) that inspect the configuration
for the apply-macro statement at a specified hierarchy
level and change the configuration to include standard Junos OS CLI
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 Macros.
- Save the script with a meaningful name.
- Copy the script to either the
/var/db/scripts/commit
directory on the hard drive or the/config/scripts/commit
directory on the flash drive. For information about setting the storage location for commit scripts, see 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. - where filename is the name of the script.
Enable the script by including the file statement at the [edit system scripts commit] hierarchy level:
If the script makes transient changes, include the allow-transients statement at the [edit system scripts commit] hierarchy level:
[edit system scripts commit]allow-transients;
If all the commit scripts run without errors, any transient changes are loaded into the checkout configuration, but not to the candidate configuration. Any persistent changes are loaded into 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.
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Overview of Creating Custom Configuration Syntax with Macros
- ACX, EX, M, MX, SRX, T Series
- How Macros Work
- ACX, M, MX, PTX, T Series
- Example: Creating Custom Configuration Syntax with Macros
Published: 2013-03-05
Supported Platforms
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Overview of Creating Custom Configuration Syntax with Macros
- ACX, EX, M, MX, SRX, T Series
- How Macros Work
- ACX, M, MX, PTX, T Series
- Example: Creating Custom Configuration Syntax with Macros