yang模型
使用RFC7950中给的例子,container中包含LIST
module example-a {
yang-version 1.1;
namespace urn:example:a;
prefix a;
container a {
list b {
key id;
leaf id {
type string;
}
notification down {
leaf reason {
type string;
}
}
action reset {
input {
leaf delay {
type uint32;
}
}
output {
leaf result {
type string;
}
}
}
}
}
notification failure {
leaf b-ref {
type leafref {
path "/a/b/id";
}
}
}
}
root@bfa784c0263a:~/netconf_src/bak_sysrepo/build/examples# sysrepoctl -i example-a.yang
root@bfa784c0263a:~/netconf_src/bak_sysrepo/build/examples# sysrepoctl -l | grep example-a
example-a | | I | root:root | 600 | |
root@bfa784c0263a:~/netconf_src/bak_sysrepo/build/examples#
运行netopeer2
root@bfa784c0263a:~/netconf_src/bak_sysrepo/build/examples# netopeer2-server -d -v2
另开一个终端2,创建一个xml的配置文件,向b这个list里写入两个实例
root@bfa784c0263a:~# cat config1.xml
<a xmlns="urn:example:a">
<b>
<id>1</id>
</b>
<b>
<id>2</id>
</b>
</a>
root@bfa784c0263a:~#
终端2启动netopeer2-cli,连接到server
root@bfa784c0263a:~# netopeer2-cli
> connect localhost
Interactive SSH Authentication
Type your password:
Password:
> edit-config --target running --config=./config1.xml
OK
>
终端2上使用config1.xml 来edit running config,默认是merge
> edit-config --target running --config=./config1.xml
OK
>
> get-config --source running --filter-xpath /a/b
DATA
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<a xmlns="urn:example:a">
<b>
<id>1</id>
</b>
<b>
<id>2</id>
</b>
</a>
</data>
终端3上创建一个config2.xml,只包含一个实例
root@bfa784c0263a:~# cat config2.xml
<a xmlns="urn:example:a">
<b>
<id>1</id>
</b>
</a>
root@bfa784c0263a:~#
终端2上用config2.xml来edit running config,op设置为replace
> edit-config --target running --config=./config2.xml --defop replace
OK
>
> get-config --source running --filter-xpath /a/b
DATA
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<a xmlns="urn:example:a">
<b>
<id>1</id>
</b>
</a>
</data>
>