cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
502
Views
0
Helpful
4
Replies

Expected behavior of the unique statement

lweddewer
Level 5
Level 5

What is the expected behavior of the unique statement if one entry is not set.

example:

list interface {

      key "uid";

      unique "ctag stag";

   

      leaf uid {

          type string;

          }

       leaf ctag {

          type uint16 {

                range "0..4095";

                }

           }

       leaf stag {

          type uint16 {

                range "0..4095";

                }

           }

       ...

If both ctag and stag have values a validate brings a "values are not unique"  if I try to add the same parameters a second time.

If only one leaf have a value and the second is left empty a validate runs without any warning even if the remaining  leaf have the same value in two list entries. My idea was to cover single tagged and double tagged configurations with one yang modell.

To me it's looks like unique doesn't work if one entry is empty.

I have seen this behavior in version nso version 4.4.1.2 and also in nso version 4.4.5.

So I'm not sure if it is "working as desigened".

Regards

Lothar

1 Accepted Solution

Accepted Solutions

Jan Lindblad
Cisco Employee
Cisco Employee

If one or more of the leafs referenced in unique don't exist, the unique statement has no effect, just as you have seen. If you refer to keys, add a mandatory or default to all leafs, they will always exist, and the unique stmt will apply everywhere.

View solution in original post

4 Replies 4

frjansso
Cisco Employee
Cisco Employee

Is it the combination of ctag and stag that has to be unique?

If you add another unique statment for ctag to the model, i.e.

unique ctag;

unique "ctag stag";

That would mean that ctag always hasto be unique though.

Hello Fredrik,

thank you for your quick reply.

Unfortunately your idea adding a second unique statment doesn't work for this problem.

When adding the second unique statment a valid combination of

line 1 ctag = 100  stag = 100;

line 2 ctag = 100  stag = 101;

will lead to a validation error by the unique "ctag" statment.

Looks like the unique statment doesn't work for this problem.

Regrads

Lothar

Have a look at the YANG RFC under section "The list's unique Statement".

RFC 6020 - YANG - A data modeling language for NETCONF

It provides a very similar case as an example.

Jan Lindblad
Cisco Employee
Cisco Employee

If one or more of the leafs referenced in unique don't exist, the unique statement has no effect, just as you have seen. If you refer to keys, add a mandatory or default to all leafs, they will always exist, and the unique stmt will apply everywhere.