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

Limiting the Number of E1 Interfaces

This example limits the number of E1 interfaces configured on a Channelized STM1 Intelligent Queuing (IQ) Physical Interface Card (PIC).

For each channelized STM1 interface (cstm1-), the set of corresponding E1 interfaces is selected. The number of those interfaces, as determined by the built-in Extensible Stylesheet Language Transformations (XSLT) count() function, cannot exceed the limit set by the global variable $limit. If there are more E1 interfaces than $limit, a commit error is generated and the commit operation fails.

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:param name="limit" select="16"/>

    <xsl:template match="configuration">
        <xsl:variable name="interfaces" select="interfaces"/>
        <xsl:for-each select="$interfaces/interface[starts-with(name, 'cstm1-')]">
            <xsl:variable name="triple" select="substring-after(name, 'cstm1-')"/>
            <xsl:variable name="e1name" select="concat('e1-', $triple)"/>
            <xsl:variable name="count"
                  select="count($interfaces/interface[starts-with(name, $e1name)])"/>
            <xsl:if test="$count > $limit">
                <xnm:error>
                    <edit-path>[edit interfaces]</edit-path>
                    <statement><xsl:value-of select="name"/></statement>
                    <message>
                        <xsl:text>E1 interface limit exceeded on CSTM1 IQ PIC. </xsl:text>
                        <xsl:value-of select="$count"/>
                        <xsl:text> E1 interfaces are configured, but only </xsl:text>
                        <xsl:value-of select="$limit"/>
                        <xsl:text> are allowed.</xsl:text>
                    </message>
                </xnm:error>
            </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";

param $limit = 16;

match configuration {
    var $interfaces = interfaces;

    for-each ($interfaces/interface[starts-with(name, 'cstm1-')]) {
        var $triple = substring-after(name, 'cstm1-');
        var $e1name = 'e1-' _ $triple;
        var $count = count($interfaces/interface[starts-with(name, $e1name)]);

        if ($count > $limit) {
            <xnm:error> {
                <edit-path> "[edit interfaces]";
                <statement> name;
                <message> {
                    expr "E1 interface limit exceeded on CSTM1 IQ PIC. ";
                    expr $count;
                    expr " E1 interfaces are configured, but only ";
                    expr $limit;
                    expr " are allowed.";
                }
            }
        }
    }
}

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