0
container first{       
        container second{
            type boolean;
        }
}

how can i do something like this.(My error:i can't boolean a container/error: unexpected keyword "type") I don't want to use leaf. Is there an alternative ?

  • What meaning are you trying to convey to a reader of your module? Define "boolean container" for us. – predi Jul 09 '21 at 07:17
  • YANG has the concept of presence containers, which implies that the mere existence of that container has meaning. From that point of view, it ends up being some kind of a boolean: its existence implies 'true', its absence implies false. However, not sure this is what you want. Types are only applicable for leaves and leaf-lists, so for sure containers cannot have them. Check the presence containers, and alternatively check the 'empty' type for leaves. – Paulo Gomes Jul 13 '21 at 08:21

1 Answers1

1

As per RFC 6020. For storing single data we have to use leaf. Using containers to store boolean data, I don't think would be possible.

As per RFC6020 section 7.5.1, Containers are used to organize the hierarchy of data nodes, and those whose presence in the configuration has an explicit meaning.It means we can't use container to store the data.

If you don't want to use boolean then you can try to use "enum" like this:

 leaf myenum {
     type enumeration {
         enum zero {
              value 0;
         }   
         enum one {
             value 1;
         }
     }
 }

.

Sachin
  • 1,460
  • 17
  • 24