02-22-2018 07:49 AM - edited 03-01-2019 04:06 AM
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
Solved! Go to Solution.
02-22-2018 11:35 PM
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.
02-22-2018 08:01 AM
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.
02-22-2018 11:52 PM
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
02-24-2018 10:28 PM
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.
02-22-2018 11:35 PM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide