I am trying to build YANG model for this configuration file that has lists without keys. However, Due to the necessity of key in YANG list, I wasn't able to build exact YANG model. Is there any idea how to represents list of list without key in YANG.
The file includes acls in which there could be many acl like acl1, acl2 named by users and has rules as in the example below.
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
My YANG model is
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
And hence the corresponding valid data file has extra fields that are necessary for YANG but not exist in my original configuration file above like (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