ConfD User Community

How to add to a previously defined container in another yang file


#1

I have a requirement where I have to create a yang file that would add some configurable parameters (leaves, lists) to a container that was defined in another yang file.

Like below:
a.yang has the following:

module a {
    container system {
         container system {
               leaf x {
               }
               leaf y {
               }
         }
    }
}

I need to create b.yang that would add leaf z to the above system container.


#2

Hello,

from question is not fully clear if you want to add new leaf z to the container existing in module a or ff you want to have system container in module b that is different from module a (has leaf z).

I suggest you look at yang RFC https://tools.ietf.org/html/rfc7950

augment statement https://tools.ietf.org/html/rfc7950#page-119
grouping statement https://tools.ietf.org/html/rfc7950#page-104

To see if they can help you with reuse.