我试图为这个配置文件建立杨模型,这个配置文件有没有键的列表。然而,由于杨列表中键的必要性,我无法建立精确的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
我的杨模型是
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
发布于 2018-03-05 14:43:08
如果列表表示配置,则"key“语句必须存在,否则该语句可能会出现,该语句以一个字符串作为参数,该字符串指定该列表的一个或多个叶标识符的空格分隔列表。叶标识符不能在键中出现超过一次。每个这样的叶标识符必须引用列表的子叶。可以在列表的子语句中或在列表中使用的分组中直接定义leafs。键中指定的所有leafs的组合值用于唯一标识列表条目。在创建列表条目时,必须给所有键叶赋值。因此,键叶或其类型中的任何默认值都会被忽略。键片中的任何“强制”语句都会被忽略。
列出模型配置数据(无论是否嵌套)必须有一个键。这是无法避免的,因为每个配置列表实例都必须是唯一可标识的,以便像instance-identifiers
这样的构造可以按照预期的方式工作。如果没有密钥,您将很难告诉设备修改(甚至只是获取)配置中的特定条目。因此,你提议做的事情是不可能实现的--这不是杨的做法。
只有状态数据(config false;
)列表可能不存在密钥,因为它们不需要以标准方式进行修改--它们的实例化/修改/删除受设备的实现细节控制。
此外,您已经在示例中使用密钥了。"acl1“和"acl2”显然是"acl“列表的实例,它们的密钥被编码到它们的名称中。
https://stackoverflow.com/questions/49083454
复制相似问题