샘플 커밋 스크립트에 대한 라인별 설명
SONET/SDH 인터페이스에 변경 적용
다음 XSLT 커밋 스크립트는 이름이 (은)로 시작하는 각 인터페이스에 임시 변경을 적용하고 so-캡슐화를 ppp로 설정합니다. 임시 변경 사항에 대한 정보는 커밋 스크립트를 사용하여 영구 또는 임시 구성 변경 생성 개요를 참조하십시오. 이 예의 SLAX 버전은 예: 임시 변경 생성을 참조하십시오.
1 <?xml version="1.0"?> 2 <xsl:stylesheet version="1.0" 3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 4 xmlns:junos="http://xml.juniper.net/junos/*/junos" 5 xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm" 6 xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0"> 7 <xsl:import href="../import/junos.xsl"/> 8 <xsl:template match="configuration"> 9 <xsl:for-each select="interfaces/interface[starts-with(name, 'so-') \ and unit/family/inet]"> 10 <transient-change> 11 <interfaces> 12 <interface> 13 <name><xsl:value-of select="name"/></name> 14 <encapsulation>ppp</encapsulation> 15 </interface> 16 </interfaces> 17 </transient-change> 18 </xsl:for-each> 19 </xsl:template> 20 </xsl:stylesheet>
1~8행은 커밋 스크립트에 필요한 상용구에 설명된 대로 상용구이며 간결성을 위해 여기에서 생략됩니다.
라인 9는 <xsl:for-each> 이름이 'so-'로 시작하고 모든 논리 장치에서 활성화된 각 인터페이스 노드를 검사하는 family inet 프로그래밍 명령입니다. (간결성을 위해서만 두 줄에 표시됩니다.)
9 <xsl:for-each select="interfaces/interface[starts-with(name, 'so-') \ and unit/family/inet]">
라인 10은 임시 변경을 위한 개방형 태그입니다. 요소의 <transient-change> 가능한 내용은 Junos XML 프로토콜 작업<load-configuration>에서 태그 요소의 <configuration> 내용과 동일합니다.
10 <transient-change>
라인 11~16은 임시 변경의 내용을 나타냅니다. 캡슐화는 으로 ppp설정됩니다.
11 <interfaces> 12 <interface> 13 <name><xsl:value-of select="name"/></name> 14 <encapsulation>ppp</encapsulation> 15 </interface> 16 </interfaces>
라인 17~19는 이 템플릿의 모든 열린 태그를 닫습니다.
17 </transient-change> 18 </xsl:for-each> 19 </xsl:template>
라인 20은 스타일 시트와 커밋 스크립트를 닫습니다.
20 </xsl:stylesheet>
ISO 지원 인터페이스에 변경 적용
다음 샘플 XSLT 스크립트는 국제 표준화 기구(ISO) 프로토콜에 대해 활성화된 인터페이스도 MPLS 활성화되어 계층 수준에 포함 [edit protocols mpls interface] 되도록 보장합니다. 이 예의 SLAX 버전은 예: 제어 IS-IS 및 MPLS 인터페이스를 참조하십시오.
1 <?xml version="1.0"?> 2 <xsl:stylesheet version="1.0" 3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 4 xmlns:junos="http://xml.juniper.net/junos/*/junos" 5 xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm" 6 xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0"> 7 <xsl:import href="../import/junos.xsl"/> 8 <xsl:template match="configuration"> 9 <xsl:variable name="mpls" select="protocols/mpls"/> 10 <xsl:for-each select="interfaces/interface/unit[family/iso]"> 11 <xsl:variable name="ifname" select="concat(../name, '.', name)"/> 12 <xsl:if test="not(family/mpls)"> 13 <xsl:call-template name="jcs:emit-change"> 14 <xsl:with-param name="message"> 15 <xsl:text> 16 Adding 'family mpls' to ISO-enabled interface 17 </xsl:text> 18 </xsl:with-param> 19 <xsl:with-param name="content"> 20 <family> 21 <mpls/> 22 </family> 23 </xsl:with-param> 24 </xsl:call-template> 25 </xsl:if> 26 <xsl:if test="$mpls and not($mpls/interface[name = $ifname])"> 27 <xsl:call-template name="jcs:emit-change"> 28 <xsl:with-param name="message"> 29 <xsl:text>Adding ISO-enabled interface </xsl:text> 30 <xsl:value-of select="$ifname"/> 31 <xsl:text> to [protocols mpls]</xsl:text> 32 </xsl:with-param> 33 <xsl:with-param name="dot" select="$mpls"/> 34 <xsl:with-param name="content"> 35 <interface> 36 <name> 37 <xsl:value-of select="$ifname"/> 38 </name> 39 </interface> 40 </xsl:with-param> 41 </xsl:call-template> 42 </xsl:if> 43 </xsl:for-each> 44 </xsl:template> 45 </xsl:stylesheet>
1~8행은 커밋 스크립트에 필요한 상용구에 설명된 대로 상용구이며 간결성을 위해 여기에서 생략됩니다.
라인 9는 다음 for-each 루프에서 참조할 [edit protocols mpls] 수 있도록 계층 수준에 대한 참조를 저장합니다.
9 <xsl:variable name="mpls" select="protocols/mpls"/>
라인 10은 ISO가 활성화된 각 인터페이스 유닛(논리적 인터페이스)을 검사합니다. , 에서 unit중지되지만, 조건자 은select(는) 요소 아래에 <family> 중첩된 요소를 포함하는 <iso> 단위로만 선택을 제한합니다.
10 <xsl:for-each select="interfaces/interface/unit[family/iso]">
라인 11은 변수에서 인터페이스 이름을 구축합니다. 첫째, name 변수 선언의 속성은 으로 ifname설정됩니다. Junos OS 인터페이스 이름은 디바이스 이름, 기간 및 단위 번호의 연결을 입니다. 스크립트의 이 시점에서 컨텍스트 노드는 단위 번호입니다. 라인 10이 인터페이스/인터페이스/단위로 컨텍스트를 변경하기 때문입니다. 은../name(는<name>) 컨텍스트 노드의 상위 노드의 요소를 의미하며, 디바이스 이름(type-fpc//picport)입니다. XPath 표현식의 "name" 토큰은 유닛 번호(unit-number)인 컨텍스트 노드의 요소를 나타냅니다<name>. 연결이 수행된 후, 11행의 XPath 표현식은 -fpc//picport로unit-number 확인됩니다type. <xsl:for-each> 라인 10의 명령이 계층을 통과하고 ISO 지원 인터페이스를 찾으면 인터페이스 이름이 변수에 ifname 재귀적으로 저장됩니다.
11 <xsl:variable name="ifname" select="concat(../name, '.', name)"/>
라인 12는 MPLS 활성화되지 않은 각 ISO 지원 인터페이스에 대해 true로 평가합니다.
12 <xsl:if test="not(family/mpls)">
13행은 junos.xsl 파일의 도우미 또는 편의 템플릿인 템플릿을 호출 jcs:emit-change 합니다. 이 템플릿은 emit-change Template(SLAX 및 XSLT) 및 emit_change(Python)에서 논의됩니다.
13 <xsl:call-template name="jcs:emit-change">
라인 14~18은 템플릿에서 message 매개 변수를 jcs:emit-change 사용합니다. 메시지 매개변수는 , 및 <edit-path><statement> 요소를 명시적으로 포함하는 대신 사용할 수 있는 <warning>바로 가기입니다.
14 <xsl:with-param name="message"> 15 <xsl:text> 16 Adding 'family mpls' to ISO-enabled interface 17 </xsl:text> 18 </xsl:with-param>
라인 19~23은 템플릿에서 content 매개 변수를 jcs:emit-change 사용합니다. 매개 변수는 content 현재 컨텍스트 노드와 상대적으로 변경을 지정합니다.
19 <xsl:with-param name="content"> 20 <family> 21 <mpls/> 22 </family> 23 </xsl:with-param>
라인 24와 25는 각각 라인 13과 12에서 열린 태그를 닫습니다.
24 </xsl:call-template> 25 </xsl:if>
라인 26은 MPLS 이미 활성화되었는지, 이 인터페이스가 계층 수준에서 구성 [edit protocols mpls interface] 되지 않았는지 테스트합니다.
26 <xsl:if test="$mpls and not($mpls/interface[name = $ifname])">
라인 27~41에는 템플릿의 또 다른 송신이 포함되어 있습니다 jcs:emit-change . 이 호출에서 인터페이스는 계층 수준에 추가 [edit protocols mpls interface] 됩니다.
27 <xsl:call-template name="jcs:emit-change"> 28 <xsl:with-param name="message"> 29 <xsl:text>Adding ISO-enabled interface </xsl:text> 30 <xsl:value-of select="$ifname"/> 31 <xsl:text> to [edit protocols mpls]</xsl:text> 32 </xsl:with-param> 33 <xsl:with-param name="dot" select="$mpls"/> 34 <xsl:with-param name="content"> 35 <interface> 36 <name> 37 <xsl:value-of select="$ifname"/> 38 </name> 39 </interface> 40 </xsl:with-param> 41 </xsl:call-template>
라인 42~45는 모든 열린 요소를 닫습니다.
42 </xsl:if> 43 </xsl:for-each> 44 </xsl:template> 45 </xsl:stylesheet>