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.
Regular configuration groups cannot test whether the configuration for an interface at the [edit interfaces interface-name sonet-options] hierarchy level includes the aggregate statement. A commit script can perform this test and set the encapsulation only on nonaggregated interfaces.
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";
}
}
}
}
To test the example in this section, perform the following steps:
system {
scripts {
commit {
file ex-so-encap.xsl;
allow-transients;
}
}
}
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;
}
}
}
}
- [edit]
- user@host# load merge terminal
- [Type ^D at a new line to end input]
- > Paste the contents of the clipboard here<
- [edit]
- user@host# commit
Display Configuration with Transient Changes
When you issue the show interfaces | display commit-scripts command, the following output appears:
[edit]
user@host# show interfaces | display commit-scripts
so-1/2/2 {
sonet-options { # The presence of these statements prevents the
aggregate as0; # transient change from taking effect on this interface.
}
}
so-1/2/3 {
encapsulation cisco-hdlc; # Added by transient change.
unit 0 {
family inet {
address 10.0.0.3/32;
}
}
}
so-1/2/4 {
encapsulation cisco-hdlc; # Added by transient change.
unit 0 {
family inet {
address 10.0.0.4/32;
}
}
}
Display Configuration Without Transient Changes
When you issue the show interfaces command, the following output appears. The transient changes are not displayed when you do not include the piped display commit-scripts option. They are in effect nonetheless.
[edit]
user@host# show 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;
}
}
}