Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Example: Find LSPs to Multiple Destinations Using an Op Script

This example uses an op script to check for label-switched paths (LSPs) to multiple destinations.

Requirements

This example uses a device running Junos OS.

Overview and Op Script

The following example script, which is shown in both XSLT and SLAX, checks for LSPs to multiple destinations. The script takes one mandatory command-line argument, the address specifying the LSP endpoint. The address argument can include an optional prefix length. If no address is specified, the script generates an error message and halts execution.

The get-configuration variable stores the remote procedure call (RPC) to retrieve the [edit protocols mpls] hierarchy level of the device’s committed configuration. This configuration is stored in the config variable. The get-route-information variable stores the RPC equivalent of the show route address terse operational mode command, where the value of the destination tag specifies address. The script sets this value to the address specified by the user on the command line. The script invokes the get-route-information RPC and stores the output in the rpc-out variable. If rpc-out does not contain any errors, the script examines all host route entries present at the route-table/rt/rt-destination node.

For each host route entry, if an LSP to the destination is configured in the active configuration, the script generates a “Found” message with the destination address and corresponding LSP name in the output. If an LSP to the destination is not configured, the output generates a “Missing” message containing the destination address and hostname.

XSLT Syntax

SLAX Syntax

Configuration

Procedure

Step-by-Step Procedure

To download, enable, and test the script:

  1. Copy the XSLT or SLAX script into a text file, name the file lsp.xsl or lsp.slax as appropriate, and copy it to the /var/db/scripts/op/ directory on the device.

  2. In configuration mode, include the file statement at the [edit system scripts op] hierarchy level and lsp.xsl or lsp.slax as appropriate.

  3. Issue the commit and-quit command to commit the configuration and to return to operational mode.

  4. Execute the op script by issuing the op lsp address address operational mode command.

Verification

Verifying Script Execution

Purpose

Verify that the script behaves as expected.

Action

Issue the op lsp address address operational mode command to execute the script. The output varies depending on the configuration.