このページで
例:RIP グループへの T1 インターフェイスの追加
この例では、コミット スクリプトを使用して手動設定の量を減らす方法、特に 階層レベルで設定されたすべての T1 インターフェイスを [edit interfaces] 階層レベルに追加する方法を [edit protocols rip group test] 示しています。
要件
この例では、T1 インターフェイスを搭載した Junos OS を実行しているデバイスを使用します。
概要とコミット スクリプト
インターフェイスで RIP を有効にする場合は、 と [edit protocols rip] の両方の階層レベルで変更を[edit interfaces]行う必要があります。この例では、コミット スクリプトを使用して、 階層レベルで設定されたすべての T1 インターフェイスを [edit interfaces] 階層レベルに追加する方法を[edit protocols rip group test]示しています。この例では、エラー、警告、システム ログ メッセージは含めいません。設定の変更は通知なく行われます。
このスクリプトの例は、XSLT と SLAX の両方の構文で示されています。
XSLT 構文
<?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:variable name="all-t1"
select="interfaces/interface[starts-with(name, 't1-')]"/>
<xsl:if test="$all-t1">
<change>
<protocols>
<rip>
<group>
<name>test</name>
<xsl:for-each select="$all-t1">
<xsl:variable name="ifname" select="concat(name, '.0')"/>
<neighbor>
<name><xsl:value-of select="$ifname"/></name>
</neighbor>
</xsl:for-each>
</group>
</rip>
</protocols>
</change>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
SLAX 構文
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 {
var $all-t1 = interfaces/interface[starts-with(name, 't1-')];
if ($all-t1) {
<change> {
<protocols> {
<rip> {
<group> {
<name> "test";
for-each ($all-t1) {
var $ifname = name _ '.0';
<neighbor> {
<name> $ifname;
}
}
}
}
}
}
}
}
構成
手順
手順
スクリプトをダウンロード、有効化、テストするには、以下の手順にしたがっています。
スクリプトをテキスト ファイルにコピーし、 rip-t1.xsl または rip-t1.slax に名前を付け、デバイス上の /var/db/scripts/commit/ ディレクトリにコピーします。
以下のテスト構成スタンザを選択し、Ctrl+cを押してクリップボードにコピーします。
スクリプトの SLAX バージョンを使用している場合は、 階層レベルのファイル名を
[edit system scripts commit file]rip-t1.slax に変更します。system { scripts { commit { file rip-t1.xsl; } } } interfaces { t1-0/0/0 { unit 0 { family iso; } } t1-0/0/1 { unit 0 { family iso; } } t1-0/0/2 { unit 0 { family iso; } } t1-0/0/3 { unit 0 { family iso; } } t1-0/1/0 { unit 0 { family iso; } } t1-0/1/1 { unit 0 { family iso; } } t1-0/1/2 { unit 0 { family iso; } } t1-0/1/3 { unit 0 { family iso; } } }設定モードで、 コマンドを
load merge terminal発行して、スタンザをデバイス設定にマージします。[edit] user@host# load merge terminal [Type ^D at a new line to end input] ... Paste the contents of the clipboard here ...
プロンプトで、マウスと貼り付けアイコンを使用して、クリップボードの内容を貼り付けます。
Enter キーを押します。
Ctrl+dを押します。
設定をコミットします。
user@host# commit
検証
設定の検証
目的
スクリプトが想定どおりに動作していることを確認します。
アクション
コマンドを show protocols rip group test 発行します。すべての T1 インターフェイスが 階層レベルで [edit protocols rip group test] 表示されます。
[edit] user@host# show protocols rip group test neighbor t1-0/0/0.0; neighbor t1-0/0/1.0; neighbor t1-0/0/2.0; neighbor t1-0/0/3.0; neighbor t1-0/1/0.0; neighbor t1-0/1/1.0; neighbor t1-0/1/2.0; neighbor t1-0/1/3.0;