Default Value for List

Hi,

Is it possible to define default value for a list? According to RFC 7950, default value can be defined for typedef, leaf, leaf-list and choice. In case I want to have a list with default element, do I have to define it in init.xml files? Is there a way solve it directly on YANG definition?

Example list:

container con {
      list example-list {
        key "var0";
        unique "var1";
  
        leaf var0 {
          type uint32;
        }
  
        leaf var1 {
          mandatory true;
          type uint32;
        }
  
        leaf var2 {
          type uint32;
        }
    }
}

By default I want to have list element with values:

<example-list>
   <var0>12313</var0>
   <var1>645</var1>
   <var2>234</var2>
</example-list>

I have tried defining default values for each leaf but it didn’t work (also not possible to define default values for key parameters).

Thanks!

Hi,

You need to use an “init.xml” file.

1 Like