キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 
cancel
257
閲覧回数
0
いいね!
0
コメント
Akira Iwamoto
Cisco Employee
Cisco Employee

はじめに

NSO 5.4 では以下の変更点が入っています。これにより、NETCONF NED 作成時には特に注意が必要となっています。

  - ncs: ncs-make-package now generates Makefiles which compiles YANG with
    the option --fail-on-warnings. The generated packages should serve as a
    good example how Makefiles ought to be written.
    For legacy usage of ncs-make-package has a new option
    --no-fail-on-warnings.
    A new option --lsa-lower-ncs <dir> has been added. An upper node needs
    to have its own packages compiled for the lower node's ncs namespace if
    the lower node runs a different version than the upper node.
    Period is now accepted as a valid character in package names. In Java
    packages the period character is replaced with underscore.
    (ENG-23702)

 

Yangコンパイル時の警告とエラー

NSOに内蔵されているyang コンパイラ (ncsc コマンド) では、その内容によって警告やエラーを出す場合があります。例えば、以下のように、must ステートメントが指定する先のノードがない場合には、動作時に評価出来出来ないことになるため、警告が表示されます。

module test1 {
namespace "http://com/example/test1";
prefix test1;

leaf leaf1 {
type string;
must "../leaf2";
}
}

コンパイル実行

$ ncsc -c test1.yang
test1.yang:34: warning: The XPath expression references an undefined node: the node 'leaf2' from module 'test1' is not found

別の例として、以下のモデルをコンパイルすると、警告が表示されます。

module test1 {
namespace "http://com/example/test1";
prefix test1;

grouping grp1 {
container cont1 {
must "../leaf2[text() = 'abc']";
}
}
container contA {
leaf leaf2 {
type string;
}
uses grp1;
}

コンパイルの実行

$ ncsc -c test1.yang
test1.yang:17: warning: The 'must' expression should have a tailf:dependency. If is doesn't, it will be checked for every commit.

--fail-on-warnings オプション

警告はエラーではありませんので、コンパイル自体は成功します。実際、上記例の yang から作られた fxs ファイルを使用した場合でも、NSO 内部でそれらを保管するロジックが動作し、見た目に問題があるわけではありません。dependency の問題については、動作速度への顕著な影響があります。

--fail-on-warnings オプションを使用することで、警告発生時にコンパイルを失敗させることが出来ます。以下の様に、リターンコードが 1 となっていることがわかります。

$ ncsc -c test1.yang
test1.yang:17: warning: The 'must' expression should have a tailf:dependency. If is doesn't, it will be checked for every commit.
$ echo $?
0
$ ncsc -c --fail-on-warnings test1.yang
test1.yang:17: error: The 'must' expression should have a tailf:dependency. If is doesn't, it will be checked for every commit.
$ echo $?
1

ncs-make-package が生成する Makefile

ncs-make-package コマンドでは、パッケージの雛形を生成することが出来ます。その際には、コンパイルを行うための、Makefile も共に作成されます。

NSO 5.4 以降では、ncs-make-package コマンドが雛形を生成する際、Makefile 内のコンパイルコマンドに、--fail-on-warnings がデフォルトで使用されるようになりました。  このドキュメント記載時には Netconf NED 作成時について影響があります。

デバイスベンダーが提供するyang ファイルを使用して Netconf NED を作成する際、dependency の警告が発生することがよくあります。動作速度等を気にしないのであれば、ncs-make-package コマンドに --no-fail-on-warnings オプションを付加して使用しててください。

Cisco ESC NED の作成

$ ncs-make-package --netconf-ned <yang dir> escned1
$ make -C escned1/src
...
yang/esc_locators.yang:67: warning: The 'must' expression should have a tailf:dependency. If is doesn't, it will be checked for every commit.
...
make: *** [Makefile:51: ncsc-out/.done] Error 1
$

コンパイルに失敗しました。

Cisco ESC NED の作成 (--no-fail-on-warnings)

$ ncs-make-package --no-fail-on-warnings --netconf-ned <yang dir> escned2
...
yang/esc_locators.yang:67: warning: The 'must' expression should have a tailf:dependency. If is doesn't, it will be checked for every commit.
...
$  

コンパイルに成功しました。

Getting Started

検索バーにキーワード、フレーズ、または質問を入力し、お探しのものを見つけましょう

シスコ コミュニティをいち早く使いこなしていただけるよう役立つリンクをまとめました。みなさんのジャーニーがより良いものとなるようお手伝いします