- play_arrow Overview
- play_arrow Junos Automation Scripts Overview
- play_arrow Junos XML Management Protocol and Junos XML API Overview
-
- play_arrow Automation Scripting Using XSLT
- play_arrow XSLT Overview
- play_arrow Standard XPath and XSLT Functions Used in Automation Scripts
- play_arrow Standard XSLT Elements and Attributes Used in Automation Scripts
-
- play_arrow Automation Scripting Using Python
- play_arrow Python Overview
- Understanding Python Automation Scripts for Junos Devices
- Requirements for Executing Python Automation Scripts on Junos Devices
- Overview of Python Modules on Junos Devices
- How to Use Python Interactive Mode on Devices Running Junos OS
- How to Use the psutil Module to Retrieve Process and System Information on Devices Running Junos OS
- How to Use the Requests Library for Python on Devices Running Junos OS
- IPv6 Support in Python Automation Scripts
- How to Specify the Routing Instance in Python 3 Applications on Devices Running Junos OS Evolved
-
- play_arrow Automation Script Input
- play_arrow Global Parameters in Automation Scripts
-
- play_arrow Extension Functions and Named Templates for Automation Scripts
- play_arrow Extension Functions for Automation Scripting
- play_arrow Extension Functions in the jcs and slax Namespaces
- base64-decode() Function (SLAX)
- base64-encode() Function (SLAX)
- break-lines() Function (SLAX and XSLT)
- close() Function (SLAX and XSLT)
- dampen() Function (Python, SLAX, and XSLT)
- document() Function (SLAX)
- emit_error() Function (Python)
- emit_snmp_attributes Function (Python)
- emit_warning() Function (Python)
- empty() Function (SLAX and XSLT)
- evaluate() Function (SLAX)
- execute() Function (SLAX and XSLT)
- first-of() Function (SLAX and XSLT)
- get-command() Function (SLAX)
- get-hello() Function (SLAX and XSLT)
- get-input() Function (SLAX and XSLT) and get_input() (Python)
- get-protocol() Function (SLAX and XSLT)
- get-secret() Function (SLAX and XSLT) and get_secret() (Python)
- get_snmp_action() Function (Python)
- get_snmp_oid() Function (Python)
- hostname() Function (Python, SLAX, and XSLT)
- invoke() Function (SLAX and XSLT)
- open() Function (SLAX and XSLT)
- output() Function (Python, SLAX, and XSLT)
- parse-ip() Function (SLAX and XSLT) and parse_ip() (Python)
- printf() Function (Python, SLAX, and XSLT)
- progress() Function (Python, SLAX, and XSLT)
- regex() Function (SLAX and XSLT)
- set_routing_instance() Function (Python)
- sleep() Function (SLAX and XSLT)
- split() Function (SLAX and XSLT)
- sysctl() Function (Python, SLAX, and XSLT)
- syslog() Function (Python, SLAX, and XSLT)
- trace() Function (Python, SLAX, and XSLT)
- play_arrow Named Templates for Automation Scripting
- play_arrow Named Templates in the jcs Namespace
-
- play_arrow Manage Automation Scripts
- play_arrow Store and Enable Scripts
- play_arrow Configure a Remote Source for Scripts
- play_arrow Configure the Session Protocol for Scripts
- play_arrow Control Execution of Scripts
- play_arrow Synchronize Scripts Between Routing Engines
- play_arrow Convert Scripts Between SLAX and XSLT
-
- play_arrow Commit Scripts
- play_arrow Commit Scripts Overview
- play_arrow Create and Execute Commit Scripts
- Required Boilerplate for Commit Scripts
- XML Syntax for Common Commit Script Tasks
- Design Considerations for Commit Scripts
- How to Avoid Potential Conflicts When Using Multiple Commit Scripts
- Line-by-Line Explanation of Sample Commit Scripts
- Control the Execution of Commit Scripts During Commit Operations
- Control the Execution of Commit Scripts in the QFabric System
- Configure Checksum Hashes for a Commit Script
- How to Process Large Configurations Against Commit Scripts
- Example: Retrieve the Pre-Inheritance Candidate Configuration in a Commit Script
- play_arrow Generate a Custom Warning, Error, or System Log Message Using Commit Scripts
- Overview of Generating Custom Warning, Error, and System Log Messages
- Generate a Custom Warning, Error, or System Log Message in Commit Scripts
- SLAX and XSLT Commit Script Tag Elements to Use When Generating Messages
- Example: Generate a Custom Warning Message
- Example: Generate a Custom Error Message
- Example: Generate a Custom System Log Message
- play_arrow Generate Persistent or Transient Configuration Changes Using Commit Scripts
- Overview of Generating Persistent or Transient Configuration Changes Using Commit Scripts
- Generate a Persistent or Transient Configuration Change in SLAX and XSLT Commit Scripts
- Generate a Persistent or Transient Configuration Change in Python Commit Scripts
- SLAX and XSLT Commit Script Tag Elements to Use When Generating Persistent and Transient Configuration Changes
- Remove a Persistent or Transient Configuration Change Using Commit Scripts
- Example: Generate Persistent and Transient Configuration Changes Using Commit Scripts
- play_arrow Create Custom Configuration Syntax with Commit Script Macros
- Overview of Creating Custom Configuration Syntax with Commit Script Macros
- Create Custom Configuration Syntax with Commit Script Macros
- Create a Commit Script Macro to Read the Custom Syntax and Generate Related Configuration Statements
- Example: Creating Custom Configuration Syntax with Commit Script Macros
- play_arrow Commit Script Examples
- Example: Adding a Final then accept Term to a Firewall
- Example: Adding T1 Interfaces to a RIP Group
- Example: Assign a Classifier Using a Commit Script
- Example: Automatically Configure Logical Interfaces and IP Addresses
- Example: Configure Administrative Groups for LSPs
- Example: Configure a Default Encapsulation Type
- Example: Configure Dual Routing Engines
- Example: Configure an Interior Gateway Protocol on an Interface
- Example: Control IS-IS and MPLS Interfaces
- Example: Control LDP Configuration
- Example: Create a Complex Configuration Based on a Simple Interface Configuration
- Example: Impose a Minimum MTU Setting
- Example: Limit the Number of ATM Virtual Circuits
- Example: Limit the Number of E1 Interfaces
- Example: Load a Base Configuration
- Example: Prepend a Global Policy
- Example: Prevent Import of the Full Routing Table
- Example: Require Internal Clocking on T1 Interfaces
- Example: Require and Restrict Configuration Statements
- play_arrow Junos XML and XSLT Tag Elements Used in Commit Scripts
- play_arrow Troubleshoot Commit Scripts
-
- play_arrow Op Scripts
- play_arrow Op Scripts Overview
- play_arrow Create and Execute Op Scripts
- Required Boilerplate for Op Scripts
- Map Operational Mode Commands and Output Fields to Junos XML Notation
- How to Use RPCs and Operational Mode Commands in Op Scripts
- Declare and Use Command-Line Arguments in Op Scripts
- Configure Help Text for Op Scripts
- Define Operational Mode Commands to Allow in an Op Script
- Enable an Op Script and Define a Script Alias
- Configure Checksum Hashes for an Op Script
- Execute an Op Script on the Local Device
- Execute an Op Script from a Remote Site
- Disable an Op Script
- play_arrow Op Script Examples
- Change the Configuration Using SLAX and XSLT Scripts
- Example: Change the Configuration Using SLAX and XSLT Op Scripts
- Example: Change the Configuration Using Python Op Scripts
- Example: Customize Output of the show interfaces terse Command Using an Op Script
- Example: Display DNS Hostname Information Using an Op Script
- Example: Find LSPs to Multiple Destinations Using an Op Script
- Example: Restart an FPC Using an Op Script
- Example: Export Files Using an Op Script
- Example: Import Files Using an Op Script
- Example: Search Files Using an Op Script
- play_arrow Provision Services Using Service Template Automation
- play_arrow Troubleshoot Op Scripts
-
- play_arrow Event Policies and Event Scripts
- play_arrow Event Policy Overview
- play_arrow Event Policy Triggers
- Use Correlated Events to Trigger an Event Policy
- Trigger an Event Policy Based on Event Count
- Example: Trigger an Event Policy Based on Event Count
- Use Regular Expressions to Refine the Set of Events That Trigger a Policy
- Example: Controlling Event Policy Using a Regular Expression
- Generate Internal Events to Trigger Event Policies
- Use Nonstandard System Log Messages to Trigger Event Policies
- Junos Logger Utility
- play_arrow Event Policy Actions
- Configure an Event Policy to Execute Operational Mode Commands
- Configure an Event Policy to Change the Configuration
- Example: Changing the Configuration Using an Event Policy
- Example: Changing the Interface Configuration in Response to an Event
- Execute Event Scripts in an Event Policy
- Change the Configuration Using an Event Script
- Configuring an Event Policy to Pass Arguments to an Event Script
- Configure Event Policies to Ignore an Event
- Example: Ignore Events Based on Receipt of Other Events
- Overview of Using Event Policies to Raise SNMP Traps
- Example: Raise an SNMP Trap in Response to an Event
- Understanding the Event System Log Priority in an Event Policy
- Example: Configuring the Event System Log Priority in an Event Policy
- Example: Limit Event Script Output Based on a Specific Event Type
- play_arrow Configure Event Policy File Archiving
- play_arrow Configure Event Policy Privileges
- play_arrow Event Scripts Overview
- play_arrow Create and Execute Event Scripts
- play_arrow Troubleshoot Event Policies and Event Scripts
-
- play_arrow SNMP Scripts
- play_arrow SNMP Scripts Overview
- play_arrow Create and Execute SNMP Scripts
- play_arrow SNMP Script Example
- play_arrow Troubleshoot SNMP Scripts
-
- play_arrow Configuration Statements and Operational Commands
How to Use the SLAX Processor (slaxproc)
The SLAX processor (slaxproc) is a command-line tool that can validate SLAX script syntax, convert between SLAX and XSLT formats, and format or run SLAX scripts. The slaxproc modes define what function the processor performs. The following sections outlines commonly used modes. For a complete list of the slaxproc modes, see Understanding the SLAX Processor (slaxproc).
Validating SLAX Script Syntax
The SLAX processor provides an option to check the syntax of a SLAX script.
To check the syntax of a SLAX script, issue the
slaxproc
command with the--check
or-c
mode option and the script filename.content_copy zoom_out_map$ slaxproc --check script1.slax OR $ slaxproc -c script1.slax
If the script syntax is correct, the SLAX processor issues a "script check succeeds" message. Otherwise, the processor issues a list of error messages detected during script parsing. Fix any indicated errors, and repeat the check.
Converting Scripts Between XSLT and SLAX Formats
The SLAX processor supports converting scripts between SLAX
and XSLT formats. When you convert a script, you have the option to
reference the file arguments positionally or use the command-line
file options, --input
or -i
and --output
or -o
, to specify the original input script and the converted
output script, respectively. If you use the command-line file options,
the files can be referenced in any order on the command line, and
the file options can be interspersed among other command-line options.
If you do not provide an argument specifying an input file or an output file, standard input or standard output is used. When using standard input, press Ctrl+d to signal the end-of-file.
To convert a SLAX script to XSLT, issue the slaxproc
command with the --slax-to-xslt
or -x
mode
option. To reference the files positionally, specify the input SLAX
file as the first argument and the desired output path and filename
of the converted XSLT script as the second argument. To reference
the files using command-line file options, include the file options
in any order. For example:
$ slaxproc --slax-to-xslt test/script2.slax test/script2.xsl OR $ slaxproc -x -i test/script2.slax -o test/script2.xsl
To convert an XSLT script to SLAX, issue the slaxproc
command with the --xslt-to-slax
or -s
mode
option. To reference the files positionally, specify the input XSLT
file as the first argument and the desired output path and filename
of the converted SLAX script as the second argument. To reference
the files using command-line file options, include the file options
in any order.
Optionally, when converting a script from XSLT to SLAX, include
the --write-version
or -w
option to specify
the SLAX version of the converted script. Acceptable values are 1.0,
1.1, and 1.2. The default version is the latest SLAX version. Use
the -p
option for partial input when you do not require
the SLAX script boilerplate in the output.
The following example converts the XSLT script script1.xsl to the SLAX script script1.slax. The SLAX script will include the statement "version 1.0;" as the first line of the script.
$ slaxproc --xslt-to-slax -w 1.0 test/script1.xsl test/script1.slax OR $ slaxproc -s -w 1.0 -i test/script1.xsl -o test/script1.slax
The slaxproc --xslt-to-slax
mode with the -p
option is useful for quickly converting Junos OS hierarchies
from XML format into SLAX. The following example provides the Junos OS [edit policy-options]
hierarchy in XML format as input to the
SLAX processor. The -p
option indicates partial script
input as opposed to a full script.
$ slaxproc -s -p <policy-options> <policy-statement> <name>export-policy</name> <term> <name>term1</name> <from> <route-filter> <address>10.0.4.4/30</address> <prefix-length-range>/30-/30</prefix-length-range> </route-filter> </from> <then> <accept/> </then> </term> </policy-statement> </policy-options> [Ctrl+d]
The SLAX processor returns the SLAX formatting for the hierarchy.
<policy-options> { <policy-statement> { <name> "export-policy"; <term> { <name> "term1"; <from> { <route-filter> { <address> "10.0.4.4/30"; <prefix-length-range> "/30-/30"; } } <then> { <accept>; } } } }
Running SLAX Scripts
The SLAX processor supports executing SLAX scripts from the
command line. This is the default slaxproc mode. To explicitly use
this mode, issue the slaxproc
command with the --run
or -r
command-line mode option.
When you execute a script, you have the option to reference
the file arguments positionally or use the command-line file options, --name
or -n
, --input
or -i
, and --output
or -o
, to specify the SLAX script
file, and the input and output files, respectively. If you use the
command-line file options, the files can be referenced in any order
on the command line, and the file options can be interspersed among
other command-line options.
If no input file is required, use the -E
option to
indicate an empty input document. Additionally, if the input or output
argument has the value "‑", standard input or standard output is used.
When using standard input, press Ctrl+d to signal the end-of-file.
The syntax for executing a script is:
$ slaxproc script input-file output-file OR $ slaxproc (--name | -n) script (--input | -i) input-file (--output | -o) output-file
To execute a script using the slaxproc command-line tool:
Formatting SLAX Scripts
The SLAX processor provides the option to format a script to
correct the indentation and spacing to the preferred style. When you
format a script, you have the option to reference the file arguments
positionally or use the command-line file options, --input
or -i
and --output
or -o
, to specify
the unformatted input file and the formatted output file, respectively.
If you use the command-line file options, the files can be referenced
in any order on the command line.
To format a SLAX script, issue the slaxproc
command with the --format
or -F
mode option.
To reference the files positionally, specify the unformatted SLAX
script as the first argument and the desired output path and filename
of the formatted SLAX script as the second argument. To reference
the files using command-line file options, include the file options
in any order. For example:
$ slaxproc --format script1.slax script1-format.slax OR $ slaxproc -F -i script1.slax -o script1-format.slax
Given the following unformatted SLAX script as input:
version 1.1; decimal-format default-format { decimal-separator "." ; digit "#" ; grouping-separator "," ; infinity "Infinity" ; minus-sign "-" ; nan "NaN"; pattern-separator ";" ; percent "%"; per-mille "\x2030"; zero-digit "0" ; } match / { var $number = -14560302.5; expr format-number($number, "###,###.00", "default-format"); }
the SLAX processor outputs the following formatted SLAX script:
version 1.1; decimal-format default-format { decimal-separator "."; digit "#"; grouping-separator ","; infinity "Infinity"; minus-sign "-"; pattern-separator ";"; percent "%"; per-mille " 30"; zero-digit "0"; nan "NaN"; } match / { var $number = -14560302.5; expr format-number($number, "###,###.00", "default-format"); }