Example: Configuring a Default Encapsulation Type
Point-to-Point Protocol (PPP) encapsulation is the default encapsulation type for physical interfaces. You need not configure encapsulation for any physical interfaces that support PPP encapsulation. If you do not configure encapsulation, PPP is used by default. For physical interfaces that do not support PPP encapsulation, you must configure an encapsulation to use for packets transmitted on the interface.
This example configures default Cisco HDLC encapsulation on SONET/SDH interfaces not configured as aggregate interfaces. The $tag variable is passed to the <jcs:emit-change> template as transient-change, so this change is not copied to the candidate configuration.
Simply including configuration groups in the configuration does not enable you to test whether the aggregate statement is included for an interface at the [edit interfaces interface-name sonet-options] hierarchy level. A commit script can perform this test and set the encapsulation only on nonaggregated interfaces. The ex-so-encap script written to perform this test has the following syntax:
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-')
and not(sonet-options/aggregate)]">
<xsl:call-template name="jcs:emit-change">
<xsl:with-param name="tag" select="'transient-change'"/>
<xsl:with-param name="content">
<encapsulation>cisco-hdlc</encapsulation>
</xsl:with-param>
</xsl:call-template>
</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-') and
not(sonet-options/aggregate)]) {
call jcs:emit-change($tag = 'transient-change') {
with $content = {
<encapsulation> "cisco-hdlc";
}
}
}
}
Testing the ex-so-encap Script
To test the ex-so-encap script,
perform the following steps:
- Copy the XSLT or SLAX script from Example: Configuring a Default Encapsulation Type into a text file, name the file
ex-so-encap.xslorex-so-encap.slaxas appropriate, and copy it to the/var/db/scripts/commitdirectory on the device. Select the following 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 ex-so-encap.slax.
system {scripts {commit {allow-transients;file ex-so-encap.xsl;}}}interfaces {so-1/2/2 {sonet-options {aggregate as0;}}so-1/2/3 {unit 0 {family inet {address 10.0.0.3/32;}}}so-1/2/4 {unit 0 {family inet {address 10.0.0.4/32;}}}}In configuration mode, issue the load merge terminal command to merge the stanzas into your device configuration:
[edit]user@host# load merge terminal[Type ^D at a new line to end input]... Paste the contents of the clipboard here ...- At the prompt, paste the contents of the clipboard using the mouse and the paste icon.
- Press Enter.
- Press Ctrl+d.
Issue the commit command.
[edit]
user@host# commit
When you issue the commit command, the ex-so-encap commit script tests for SONET/SDH interfaces that are not configured as aggregate interfaces and sets the default encapsulation type on the nonaggregated interfaces to Cisco HDLC encapsulation. This is implemented as a transient-change. Even though the transient changes are in effect, they are not, by default, displayed in the normal output of the show interfaces command.
To view the configuration with the transient changes, issue the show interfaces | display commit-scripts command:
Hide Navigation Pane
Show Navigation Pane
Download
SHA1