hi i have a yang
container a{
choice id{
default b;
case b{
leaf b{
type empty;}}
case c{
leaflist d {
leaf e {
type uint16;}}
}
}
i wrote a deviation to delete the default value for choice id
i want to write a deviation to raise an error-message if we try to configure choice as case b
can some one help me in writing that deviation
Hello,
If I add deviation
to the same yang
file, i can restrict configuration of b
with must
statement:
container a{
choice id{
default b;
case b{
leaf b{ type empty;}
}
case c{
leaf-list d {type uint16;}
}
}
}
deviation "/a/id" {
deviate delete { default b; }
}
deviation "/a/id/b/b" {
deviate add {
must "not(.)" {
error-message "Leaf must not be configured";
}
}
}
then in e.g. CLI you get must
statement:
(config)# a b │
(config)# commit │
Aborted: 'a b' : Leaf must not be configured │
(config)#
Unfortunately I was not able to this if I put deviation into separate yang
file like this:
import datamodel {
prefix dm;
}
deviation "/dm:a/dm:id" {
deviate delete { default b; }
}
deviation "/dm:a/dm:id/dm:b/dm:b" {
deviate add {
must "not(.)" {
error-message "Leaf must not be configured";
}
}
}
This may be bug. I’ll try to find out.
If any error message works, maybe just the not-supported deviation is enough instead of a new must expression.
It probably makes more sense too - doesn’t seem to be much point allowing ‘b’ to be set, only to reject it at commit. (Or to put it differently, it’s very strange to have must "not(.)"
on any node…) But anyway, deviation in a separate module works fine for me (with ConfD-7.2.1, but I don’t think that is required) - @mnovak, how did you compile for that case?
Yes, you are right, I forgot to use --deviation
option in confdc
(using ver. 7.1). Now it works.
datamodel.fxs: datamodel-dev.yang datamodel.yang
confdc -c -o $@ --deviation datamodel-dev.yang datamodel.yang
Thanks!