简体   繁体   English

如何在YANG模型中细化叶子的范围?

[英]How to refine a leaf's range in YANG model?

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? 还是有解决这个问题的更好方法?

Section 7.13.2 of RFC 7950 explicitly specifies all possible refinements and range is not one of them. RFC 7950的 7.13.2节明确规定了所有可能的改进, range不是其中之一。 Neither is type which can also be seen in the ABNF grammar (section 14): 在ABNF语法中也看不到type (第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 但是您可以做的是在此处添加一个must约束,例如

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";
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM