我正在尝试为这个配置文件构建 YANG 模型,该文件具有没有键的列表。然而,由于 YANG 列表中密钥的必要性,我无法构建精确的 YANG 模型。
有没有什么想法如何在 YANG 中表示没有键的列表列表。
该文件包含acl,其中可以有很多acl,如用户命名的acl1、acl2,其规则如下例所示。
acls:
acl1:
- rule:
nw_src: 192.168.1.1/24
actions:
allow: 1
- rule:
actions:
allow: 0
acl2:
- rule:
nw_src: 192.168.1.1/24
actions:
allow: 0
- rule:
actions:
allow: 1
我的 YANG 模型是
list acls{
description "list of acls ";
key "acl-name";
ordered-by user;
leaf acl-name {
type string {
length "1..64";
}
}
list acle {
description "This is a list of users in the system.";
key "acle-name";
ordered-by user;
leaf acle-name {
type string {
length "1..64";
}
description
"The name of access-list. A device MAY restrict the length
and value of this name, possibly space and special
characters are not allowed.";
}
container actions {
description "actions for this acl entry ";
leaf allow {
type uint8;
}
} // end actions container
container match{
description "match fields for this acl entry ";
leaf nw_src{
type inet:ipv4-address;
}
}
}//match cont
}//acle
} //acls
因此,相应的有效数据文件具有 YANG 所需的额外字段,但在上面的原始配置文件中不存在,例如(aclname,acle,aclename)。
acls:
acl1:
aclname: acl1
acle:
rule11:
aclename: rule11
nw_src: 192.168.1.1/24
actions:
allow: 1
rule12:
aclename: rule12
actions:
allow: 0
acl2:
aclname: acl2
acle:
rule21:
nw_src: 192.168.1.1/24
aclename: rule21
actions:
allow: 0
rule22:
aclename: rule22
actions:
allow: 1
RFC7950,7.8.2。列表的“关键”声明 https://www.rfc-editor.org/rfc/rfc7950#section-7.8.2
“key”语句,如果列表表示则必须存在
配置并且可以以其他方式存在,以参数 a
指定一个或多个叶子的空格分隔列表的字符串
该列表的标识符。叶子标识符不得出现更多
比钥匙中的一次还要多。每个这样的叶子标识符必须引用一个
列表的子叶。叶子可以直接定义在
列表或列表中使用的分组的子语句。
键中指定的所有叶子的组合值用于
唯一标识一个列表条目。所有关键叶子必须指定值
当创建列表条目时。因此,键中的任何默认值
叶子或其类型将被忽略。任何“强制性”声明
关键叶子被忽略。
列出模型配置数据(无论是否嵌套)必须有一个键。没有办法解决这个问题,因为每个配置列表实例必须是唯一可识别的,因此构造如下instance-identifiers
按预期工作。如果没有密钥,您将很难告诉设备修改(甚至只是获取)配置中的特定条目。因此,你提议做的事情是不可能实现的——这不是阳的行事方式。
仅状态数据(config false;
)列表可以在没有键的情况下存在,因为它们不必以标准方式修改 - 它们的实例化/修改/删除由设备的实现细节控制。
此外,您已经在示例中使用了键。 “acl1”和“acl2”显然是“acl”列表的实例,它们的密钥已编码到其名称中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)