cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3094
Views
0
Helpful
2
Replies

How to make a Yang container mandatory?

Steven Li
Level 1
Level 1

Based on YANG 1.1, you can make a container and all the leafs under the container as mandatory, eg:

      container rsp {
          mandatory true;
          leaf interface {
            type string;
          }
          leaf logicalInterfaceId {
            type uint16;
          }
      }

 

But I got error when try to run the make:

 error: unexpected keyword 'mandatory'

 

So how to make a container and all the leaf under the container as mandatory in NSO?

1 Accepted Solution

Accepted Solutions

vleijon
Cisco Employee
Cisco Employee

I might be mistake, but RFC7950 states:

7.5.2.  The container's Substatements

                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | presence     | 7.5.5   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+

I do not see a mandatory statement there. Am I missing some later revision of the standard?

 

Anyhow, a (non-presence) container is mandatory if at least one leaf is mandatory, so you can achieve the same effect by making all leafs in the container mandatory.

View solution in original post

2 Replies 2

vleijon
Cisco Employee
Cisco Employee

I might be mistake, but RFC7950 states:

7.5.2.  The container's Substatements

                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | presence     | 7.5.5   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+

I do not see a mandatory statement there. Am I missing some later revision of the standard?

 

Anyhow, a (non-presence) container is mandatory if at least one leaf is mandatory, so you can achieve the same effect by making all leafs in the container mandatory.

Hi Vleijon,

 

Thank you very much for your reply!

 

The container's mandatory statement seems someone's suggestion to the standard:

https://www.ietf.org/mail-archive/web/netmod/current/msg09786.html

 

Somehow it makes sense to me.