Table of Contents

About This Guide
Objectives
Supported Routing Platforms
Audience
Using the Indexes
Using the Examples in This Manual
Merging a Full Example
Merging a Snippet
Documentation Conventions
Related Juniper Networks Documentation
Documentation Feedback
Requesting Support
Overview of Configuration and Diagnostic Automation
Commit Scripts
Op Scripts
Comparing Commit Scripts and Op Scripts
Event Policies
Scripts and Event Policy Configuration Statements
Any Hierarchy Level
[edit event-options] Hierarchy Level
[edit system scripts] Hierarchy Level
Introduction to the JUNOS XML and JUNOScript APIs
About XML
XML and JUNOScript Tag Elements
Document Type Definition
Advantages of Using the JUNOScript and JUNOS XML APIs
Overview of a JUNOScript Session
Understanding XSLT
XPath
Templates
Unnamed Templates
Named Templates
Parameters
Variables
Programming Instructions
<xsl:choose>
<xsl:for-each select="xpath-expression">
<xsl:if test="xpath-expression">
Recursion
Context (Dot)
Summary of XPath and XSLT Functions, Elements, Attributes, and Templates
XPath and XSLT Functions Shown in This Manual
concat()
contains()
count()
last()
name()
not()
position()
starts-with()
string-length()
substring-after()
substring-before()
XSLT Elements and Attributes Shown in This Manual
xsl:apply-templates
xsl:call-template
xsl:choose
xsl:comment
xsl:copy-of
xsl:element
xsl:for-each
xsl:if
xsl:import
xsl:otherwise
xsl:param
xsl:stylesheet
xsl:template
xsl:text
xsl:value-of
xsl:variable
xsl:when
xsl:with-param
JUNOS Extension Functions
jcs:break-lines()
jcs:empty()
jcs:first-of()
jcs:hostname()
jcs:invoke()
jcs:output()
jcs:printf()
jcs:progress()
jcs:regex()
jcs:sleep()
jcs:sysctl()
jcs:trace()
JUNOS Named Templates
<jcs:edit-path>
<jcs:emit-change>
<jcs:emit-comment>
<jcs:statement>
Commit Scripts Overview
Advantages of Using Commit Scripts
How Commit Scripts Work
Basic Process for Using Commit Scripts
How the JUNOS Software Commit Model Works with Commit Scripts
Commit Script Input
Commit Script Output
Using Multiple Commit Scripts
Introduction to Writing Commit Scripts
Boilerplate for Commit Scripts
Importing the junos.xsl File
Extension Functions in the junos.xsl File
jcs:invoke() Function
jcs:progress() Function
jcs:output() Function
jcs:trace() Function
jcs:first-of() Function
jcs:printf() Function
jcs:sleep() Function
Templates in the junos.xsl File
<jcs:edit-path> Template
<jcs:emit-change> Template
<jcs:emit-comment> Template
<jcs:statement> Template
<xsl:template match="/"> Template
Design Considerations
Examples: Commit Scripts
Generating a Custom Warning, Error, or System Log Message
Generating a Custom Warning, Error, or System Log Message
Examples: Generating a Custom Warning, Error, or System Log Message
Example: Generating a Custom Warning Message
Verifying the Commit Script Output
Example: Generating a Custom Error Message
Verifying the Commit Script Output
Example: Generating a Custom System Log Message
Verifying the Commit Script Output
Message Tags
Summary of Message Tag Elements
<syslog>
<xnm:error>
<xnm:warning>
Generating a Persistent or Transient Configuration Change
Persistent and Transient Changes
Generating a Persistent or Transient Change
Examples: Generating a Persistent or Transient Change
Example: Generating a Persistent Change
Verifying the Commit Script Output
Example: Generating a Transient Change
Verifying the Commit Script Output
Removing a Persistent or Transient Change
Persistent and Transient Change Tags
Creating Custom Configuration Syntax with Macros
How Macros Work
Creating a Custom Syntax
"data" Element
Expanding the Custom Syntax
Other Ways to Use Macros
Creating a Macro to "Read" the Custom Syntax and Generate Related Configuration Statements
Example: Creating Custom Configuration Syntax with Macros
Verifying the Commit Script Output
Summary of Change Tag Elements
<change>
<transient-change>
Configuring and Troubleshooting Commit Scripts
Enabling a Commit Script and Making the Script Optional
Specifying a Master Source for a Script
Refreshing a Script from the Master Source
Refreshing a Script from a Different Location
Deleting or Deactivating a Commit Script
Displaying Commit Script Output
Tracing Commit Script Processing
Minimum Configuration for Enabling and Viewing Traceoptions Output
Example: Minimum Configuration for Enabling and Viewing Traceoptions Output
Configuring Traceoptions
Configuring the Commit Script's Log Filename
Configuring the Number and Size of Commit Script Log Files
Configuring the Trace Operations
Troubleshooting Commit Scripts
Summary of Commit Script Configuration Statements
allow-transients
apply-macro
commit
file
optional
refresh
refresh-from
scripts
source
traceoptions
Commit Script Examples
Requiring and Restricting Configuration Statements
Testing ex-no-nukes.xsl
Requiring Internal Clocking on T1 Interfaces
Testing ex-clocking-error.xsl
Imposing a Minimum MTU Setting
Testing ex-so-mtu.xsl
Warning About a Deprecated Value
Testing ex-deprecated.xsl
Limiting the Number of E1 Interfaces
Testing ex-16-e1-limit.xsl
Limiting the Number of ATM Virtual Circuits
Testing ex-atm-vc-limit.xsl
Controlling IS-IS and MPLS Interfaces
Testing ex-iso.xsl
Adding T1 Interfaces to a RIP Group
Testing ex-rip-t1.xsl
Adding a Default Encapsulation Type
Testing ex-so-encap.xsl
Controlling LDP Configuration
Testing ex-ldp.xsl
Adding a Final "then accept" Term to a Firewall
Testing ex-add-accept.xsl
Configuring an Interior Gateway Protocol on an Interface
Testing ex-if-class.xsl
Creating a Complex Configuration Based on a Simple Interface Configuration
Testing ex-if-params.xsl
Configuring Administrative Groups for LSPs
Testing ex-lsp-admin.xsl
Controlling a Dual Routing Engine Configuration
Testing ex-dual-re.xsl and ex-dual-re2.xsl
Preventing Import of the Full Routing Table
Testing ex-import.xsl
Automatically Configuring Logical Interfaces and IP Addresses
Testing ex-atm-logical.xsl
Prepending a Global Policy
Testing ex-bgp-global-import.xsl
Assigning a Classifier
Testing ex-classifier.xsl
Op Scripts Overview
How Op Scripts Work
Basic Process for Using Op Scripts
Introduction to Writing Op Scripts
Boilerplate for Op Scripts
Displaying Operational Mode Fields in XML
Using RPCs and Operational Mode Commands
Importing the junos.xsl File
Extension Functions in the junos.xsl File
jcs:first-of() Function
jcs:invoke() Function
jcs:output() Function
jcs:printf() Function
jcs:progress() Function
jcs:sleep() Function
jcs:trace() Function
Templates in the junos.xsl File
<jcs:edit-path> Template
<jcs:emit-change> Template
<jcs:emit-comment> Template
<jcs:statement> Template
Configuring Op Scripts
Enabling an Op Script and Defining a Script Alias
Executing an Op Script
Declaring Arguments
Example: Declaring Arguments
Configuring Command-Line Help Text
Example: Configuring Command-Line Help Text
Specifying a Master Source for a Script
Refreshing a Script from the Master Source
Refreshing a Script from a Different Location
Tracing Op Script Processing
Minimum Configuration for Enabling and Viewing Traceoptions Output
Example: Minimum Configuration for Enabling and Viewing Traceoptions Output
Configuring Traceoptions
Configuring the Op Script's Log Filename
Configuring the Number and Size of Op Script Log Files
Configuring the Trace Operations
Op Script Examples
Restarting an FPC
Testing ex-fpc.xsl
Displaying DNS Hostname Information
Testing ex-hostname.xsl
Customizing Output of the show interfaces terse Command
Line-by-Line Explanation of the Script
Testing ex-interface.xsl
Finding LSPs to Multiple Destinations
Testing ex-lsp.xsl
Summary of Op Script Configuration Statements
arguments
command
description
file
op
refresh
refresh-from
scripts
source
traceoptions
Event Policy Overview
How Event Policies Work
Configuring Event Policy
Defining Destinations for File Archiving
Uploading Files
Executing Operational Mode Commands
Executing Op Scripts in an Event Policy
Correlating Events
Using Regular Expressions to Refine the Set of Events That Cause a Policy to Be Executed
Configuring an Event to Be Ignored
Generating Internal Events
Raising SNMP Traps
Tracing Event Policy Processing
Configuring the Event Policy Log Filename
Configuring the Number and Size of Event Policy Log Files
Configuring Access to the Log File
Configuring a Regular Expression for Lines to Be Logged
Configuring the Trace Operations
Event Policy Examples
Correlating Events Based on Receipt of Other Events Within a Specified Time Interval
Ignoring Events Based on Receipt of Other Events
Correlating Events Based on Event Attributes
Controlling Event Policy Using a Regular Expression
Generating an Internal Event Every Hour
Generating an Internal Event at Midnight
Dampening an Event
Executing an Op Script in Response to an Event
Raising an SNMP Trap in Response to an Event
Summary of Event Policy Configuration Statements
archive-sites
arguments
attributes-match
commands
destination
destination (Command or Script Output)
destination (Routing Platform Files)
destinations
equals
event-options
event-script
events
events (Associating Events with a Policy)
events (Correlating Events with Each Other)
execute-commands
filename
generate-event
ignore
matches
not
output-filename
output-format
policy
raise-trap
starts-with
then
time-interval
time-of-day
traceoptions
transfer-delay
upload
upload (Committed Configuration File)
upload (Specified File)
within
Index
Index of Statements and Elements