07-21-2025 05:57 AM
Hello, everyone.
I am studying automation for my ENCOR exam.
I have a quick question - what is the difference between a leaf-list node and a list node in YANG models? Google defines them as:
Leaf-list node — Contains a sequence of leaf nodes
List node — Contains a sequence of list entries, each of which is uniquely identified by one or more key leafs
I am a bit confused about the explanations above, they seem somewhat the same to me. Could someone please tell me what is the major distinction here? Both represent some form of a list/array that contains multiple nodes, right?
Thank you
David
Solved! Go to Solution.
07-21-2025 06:05 AM
hello G.
leaf-list vlans { type uint16; } // Simple values
list interface { // Structured data
key "name";
leaf name { type string; }
leaf mtu { type uint16; }
}
and for Encor I'd say use leaf-list for basic value arrays and for complex configurations needing keys
check these links G;
hope it helps\
-Enes
07-21-2025 06:09 AM
They way I finally got this was, thinking like leaf list is like a simple array of single values [“a”, “b”, “c”] but a list like a array of objects, where each object has properties, multiple fields [{name: “eth0”, mtu: 1500}, {name:”eth1”, mtu: 9000}]
Hope this helps.
07-21-2025 06:11 AM - edited 07-21-2025 06:13 AM
Hello David,
First, a leaf node hold a single, simple value (like an integer or string) and has no child nodes.
-> A leaf-list node is a collection of such leaf nodes _ each entry contain exactly one value of a specific type, essentialy forming a flat list of simple values.
On the other hand, a list node is more complex: it defines a sequence of structured entries (like records), each uniquely identified by one or more key leaf nodes. Each entry in a list node can have multiple child node of any type, making it suitable for representing more detailed/hierarchical data structure.
--https://support.huawei.com/enterprise/en/doc/EDOC1100332772/eefbe002/node-types-of-a-yang-model
07-21-2025 06:05 AM
hello G.
leaf-list vlans { type uint16; } // Simple values
list interface { // Structured data
key "name";
leaf name { type string; }
leaf mtu { type uint16; }
}
and for Encor I'd say use leaf-list for basic value arrays and for complex configurations needing keys
check these links G;
hope it helps\
-Enes
07-21-2025 06:09 AM
They way I finally got this was, thinking like leaf list is like a simple array of single values [“a”, “b”, “c”] but a list like a array of objects, where each object has properties, multiple fields [{name: “eth0”, mtu: 1500}, {name:”eth1”, mtu: 9000}]
Hope this helps.
07-21-2025 06:11 AM - edited 07-21-2025 06:13 AM
Hello David,
First, a leaf node hold a single, simple value (like an integer or string) and has no child nodes.
-> A leaf-list node is a collection of such leaf nodes _ each entry contain exactly one value of a specific type, essentialy forming a flat list of simple values.
On the other hand, a list node is more complex: it defines a sequence of structured entries (like records), each uniquely identified by one or more key leaf nodes. Each entry in a list node can have multiple child node of any type, making it suitable for representing more detailed/hierarchical data structure.
--https://support.huawei.com/enterprise/en/doc/EDOC1100332772/eefbe002/node-types-of-a-yang-model
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide