このページで
例:E1 インターフェイス数の制限
このコミット スクリプトの例では、チャネル化された STM1 インテリジェント キューイング(IQ) PIC に設定された E1 インターフェイスの数を制限し、ユニットごとのスケジューラに関する競合問題を回避します。
要件
この例では、チャネライズドSTM1 インテリジェントキューイング(IQ)PICでJunos OSを実行しているデバイスを使用しています。
概要とコミット スクリプト
以下のスクリプトは、チャネライズドSTM1 IQインターフェイスに設定されたE1インターフェイスが16個以下であることを保証します。チャネル化された STM1 インターフェイス(cstm1-)ごとに、対応する E1 インターフェイスのセットが選択されます。組み込みの XSLT(Extensible Stylesheet Language Transformations) count()
関数によって決定されるこれらのインターフェイスの数は、グローバル パラメーター limit
によって設定された制限を超えることはできません。より limit
多くのE1インターフェイスがある場合、コミットエラーが生成され、コミット操作は失敗します。
このスクリプトの例は、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: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 構文
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."; } } } } }
構成
手順
手順
スクリプトをダウンロード、有効化、テストするには、以下の手順にしたがっています。
スクリプトをテキスト ファイルにコピーし、 e1-limit.xsl または e1-limit.slax というファイルに名前を付け、デバイス上の /var/db/scripts/commit/ ディレクトリにコピーします。
以下のテスト構成スタンザを選択し、Ctrl+cを押してクリップボードにコピーします。
スクリプトの SLAX バージョンを使用している場合は、 階層レベルのファイル名を
[edit system scripts commit file]
e1-limit.slax に変更します。system { scripts { commit { file e1-limit.xsl; } } } interfaces { cau4-0/1/0 { partition 1 interface-type ce1; partition 2-18 interface-type e1; } cstm1-0/1/0 { no-partition interface-type cau4; } ce1-0/1/0:1 { clocking internal; e1-options { framing g704; } partition 1 timeslots 1-4 interface-type ds; } ds-0/1/0:1:1 { no-keepalives; dce; encapsulation frame-relay; lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.0/31; } } } e1-0/1/0:2 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.2/31; } } } e1-0/1/0:3 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.4/31; } } } e1-0/1/0:4 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.6/31; } } } e1-0/1/0:5 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.8/31; } } } e1-0/1/0:6 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.10/31; } } } e1-0/1/0:7 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.12/31; } } } e1-0/1/0:8 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.14/31; } } } e1-0/1/0:9 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.16/31; } } } e1-0/1/0:10 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.18/31; } } } e1-0/1/0:11 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.20/31; } } } e1-0/1/0:12 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.22/31; } } } e1-0/1/0:13 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.24/31; } } } e1-0/1/0:14 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.26/31; } } } e1-0/1/0:15 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.28/31; } } } e1-0/1/0:16 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.30/31; } } } e1-0/1/0:17 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.32/31; } } } e1-0/1/0:18 { no-keepalives; per-unit-scheduler; dce; clocking internal; encapsulation frame-relay; e1-options { framing g704; } lmi { lmi-type ansi; } unit 100 { point-to-point; dlci 100; family inet { address 10.0.0.34/31; } } } }
設定モードで、 コマンドを
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
検証
コミット スクリプトの実行の検証
目的
スクリプトが想定どおりに動作していることを確認します。
アクション
コマンドの出力を commit
確認します。設定スタンザの例では、cstm1-0/1/0 インターフェイスを 17 個の E1 インターフェイスにチャネル化するため、スクリプトでエラーが生成され、コミット操作が失敗します。コマンドを発行すると、以下の commit
出力が表示されます。
[edit] user@host# commit [edit interfaces] 'cstm1-0/1/0' E1 interface limit exceeded on CSTM1 IQ PIC. 17 E1 interfaces are configured, but only 16 are allowed. error: 1 error reported by commit scripts error: commit script failure