Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Example: Configuring Administrative Groups for LSPs

 

Administrative groups, also known as link coloring or resource classes, are manually assigned attributes that describe the color of links. Links with the same color conceptually belong to the same class. You can use administrative groups to implement a variety of policy-based label-switched path (LSP) setups.

This commit script example searches for apply-macro statements with the color parameter included at the [edit protocols mpls] hierarchy level. For each apply-macro statement, the script uses the data provided to generate a transient change and expand the macro into a standard Junos OS administrative group for LSPs.

Requirements

This example uses a device running Junos OS.

Overview and Commit Script

In this example, the Junos OS management process (mgd) inspects the configuration, looking for apply-macro statements. For each apply-macro statement with the color parameter included at the [edit protocols mpls] hierarchy level, the script generates a transient change, using the data provided within the apply-macro statement to expand the macro into a standard Junos OS administrative group for LSPs.

For this example to work, an apply-macro statement must be included at the [edit protocols mpls] hierarchy level with a set of addresses, a color parameter, and a group-value parameter. The commit script converts each address to an LSP configuration and converts the color parameter into an administrative group.

For a line-by-line explanation of this script, see Example: Creating Custom Configuration Syntax with Commit Script Macros.

The example script is shown in both XSLT and SLAX syntax:

XSLT Syntax

SLAX Syntax

Configuration

Step-by-Step Procedure

To download, enable, and test the script:

  1. Copy the script into a text file, name the file lsp-admin.xsl or lsp-admin.slax as appropriate, and copy it to the /var/db/scripts/commit/ directory on the device.
  2. Select the following test configuration stanzas, and press Ctrl+c to copy them to the clipboard.

    If you are using the SLAX version of the script, change the filename at the [edit system scripts commit file] hierarchy level to lsp-admin.slax.

  3. In configuration mode, issue the load merge terminal command to merge the stanzas into your device configuration.

    1. At the prompt, paste the contents of the clipboard by using the mouse and the paste icon.

    2. Press Enter.

    3. Press Ctrl+d.

  4. Issue the commit command to commit the configuration.

Verification

Verifying the Configuration

Purpose

Verify that the script behaves as expected.

Action

Issue the show protocols mpls | display commit-scripts configuration mode command and review the output. Adding the | display commit-scripts option allows you to see the configuration statements that are generated by transient changes.

With Script-Generated Changes

When you issue the show protocols mpls | display commit-scripts configuration mode command, the following output appears:

Without Script-Generated Changes

The output of the show protocols mpls | display commit-scripts no-transients configuration mode command excludes the label-switched-path statements:

When you issue the show protocols mpls command without the piped display commit-scripts no-transients command, you see the same output because this script does not generate any persistent changes: