Reputation: 945
I have a grouping like -
grouping threshold-value-grouping {
container threshold-value {
description "Threshold value";
leaf upper-limit-val {
description
"Upper limit";
type uint32 {
range "1..60000";
}
}
leaf lower-limit-val {
description
"Lower limit";
type uint32 {
range "1..60000";
}
}
}
}
And i want to reuse this grouping at multiple places. But when used at different places, the range of the leaves vary.
So i am wondering how can I use the refine statement to achieve? Or is there any better way to address this issue?
Upvotes: 2
Views: 1969
Reputation: 5002
Section 7.13.2 of RFC 7950 explicitly specifies all possible refinements and range
is not one of them. Neither is type
which can also be seen in the ABNF grammar (section 14):
refine-stmt = refine-keyword sep refine-arg-str optsep
"{" stmtsep
;; these stmts can appear in any order
*if-feature-stmt
*must-stmt
[presence-stmt]
*default-stmt
[config-stmt]
[mandatory-stmt]
[min-elements-stmt]
[max-elements-stmt]
[description-stmt]
[reference-stmt]
"}" stmtsep
But what you can do is to add a must
constraint here, something like
uses threshold-value-grouping {
refine threshold-value/upper-limit-val {
must '(. >= 10 and . <= 100)' {
error-message "Here you can only use values between 10 and 100";
}
}
}
Upvotes: 4