[Contents] [Prev] [Next] [Index] [Report an Error]

Example: Generating a Persistent Change

If you do not explicitly configure the MPLS protocol family on an interface, the interface is not enabled for MPLS applications. This example generates a persistent change that adds the family mpls statement in the configuration of SONET/SDH interfaces when the statement is not already included in the configuration.

The persistent change is generated by the <jcs:emit-change> template, which is a helper template contained in the junos.xsl import file. The content parameter of the <jcs:emit-change> template includes the configuration statements to be added as a persistent change. The message parameter of the <jcs:emit-change> template includes the warning message to be displayed at the CLI, notifying you that the configuration has been changed.

XSLT Syntax

<?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">
        <xsl:for-each select="interfaces/interface[starts-with(name, 'so-')]/unit">
            <xsl:if test="not(family/mpls)">
                <xsl:call-template name="jcs:emit-change">
                    <xsl:with-param name="message">
                        <xsl:text>Adding 'family mpls' to SONET/SDH interface.</xsl:text>
                    </xsl:with-param>
                    <xsl:with-param name="content">
                            <family>
                                <mpls/>
                            </family>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

SLAX Syntax

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 {
    for-each (interfaces/interface[starts-with(name, 'so-')]/unit) {
        if (not(family/mpls)) {
            call jcs:emit-change() {
                with $message = {
                    expr "Adding 'family mpls' to SONET/SDH interface.";
                }
                with $content = {
                    <family> {
                        <mpls>;
                    }
                }
            }
        }
    }
}

[Contents] [Prev] [Next] [Index] [Report an Error]