cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
122
Views
2
Helpful
3
Replies

List versus Leaf-List nodes in YANG

Mitrixsen
Level 1
Level 1

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

3 Accepted Solutions

Accepted Solutions

Enes Simnica
Level 4
Level 4

hello G. 

  • Leaf-list = Simple array of single-value items (like [10, 20, 30]). Example: VLAN lists.
    List = Structured table with keyed entries (like [{name: "Gi0/1", mtu: 1500}, {...}]). but some more key difference would be that Leaf-list values have no sub-fields, and also List entries have multiple attributes and require unique keys...
    Example YANG:
 
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

more Cisco?!
more Gym?!

View solution in original post

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.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

View solution in original post

M02@rt37
VIP
VIP

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

 

 

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.

View solution in original post

3 Replies 3

Enes Simnica
Level 4
Level 4

hello G. 

  • Leaf-list = Simple array of single-value items (like [10, 20, 30]). Example: VLAN lists.
    List = Structured table with keyed entries (like [{name: "Gi0/1", mtu: 1500}, {...}]). but some more key difference would be that Leaf-list values have no sub-fields, and also List entries have multiple attributes and require unique keys...
    Example YANG:
 
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

more Cisco?!
more Gym?!

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.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

M02@rt37
VIP
VIP

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

 

 

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.