我正在学习OpenDayLight和Yang,我想不出如何对一个叶节点施加约束。我有一个叶节点(vpn-id)。当l3vpn型节点等于'bgp‘时,我希望这个节点的数据被允许用于vpn-id。如果叶节点不等于'bgp‘,并且输入了vpn-id,我想抛出一个错误。我已经在OpenDayLight中测试过这一点,它总是允许我保存数据,不管其中包含什么数据。
而且,我很难找到杨的例子,所以我可以教自己。欢迎提出建议。
module DaveTest {
namespace "urn:aaa:ddd:DaveTest";
prefix dave-module;
description "Dave testing file";
revision "2017-04-17" {
description "Initial version.";
}
container testing-vars {
list test-list {
key "vpn-transaction-id l3vpn-type";
unique "vpn-transaction-id";
leaf vpn-transaction-id {
type string;
}
leaf l3vpn-type {
type enumeration {
enum "bgp";
enum "static";
enum "gre tunnel";
}
mandatory true;
}
leaf vpn-id {
when "../l3vpn-type = 'bgp'";
type string;
}
}
}发布于 2017-04-25 05:56:37
发布于 2021-01-26 09:33:59
您可以按以下方式添加“必须”语句:
leaf vpn-id {
must "../l3vpn-type = 'bgp'";
type string;
}https://stackoverflow.com/questions/43588132
复制相似问题