[英]How to refine the mandatory property of nodes from a grouping in YANG language?
I defined a grouping which has a leaf with mandatory property set to false. 我定义了一个分组,其叶子的强制属性设置为false。 But in some cases, I would like to use this grouping and specify that the leaf should be mandatory.
但在某些情况下,我想使用此分组并指定叶子应该是必需的。 How do I achieve this in YANG?
我如何在YANG实现这一目标?
You would use the refine
statement when specifying a use of your grouping. 在指定分组的使用时,您将使用
refine
语句。
module mandatory-and-grouping {
namespace "org:example:mandatory-and-grouping";
prefix "mag";
grouping my-grouping {
leaf my-leaf {
type string;
}
}
container top {
uses my-grouping {
refine my-leaf {
mandatory true;
}
}
}
}
7.13.2.
7.13.2。 The "refine" Statement
“精炼”声明
Some of the properties of each node in the grouping can be refined with the "refine" statement.
可以使用“精简”语句来细化分组中每个节点的一些属性。 The argument is a string that identifies a node in the grouping.
参数是一个字符串,用于标识分组中的节点。 This node is called the refine's target node.
此节点称为精简的目标节点。 If a node in the grouping is not present as a target node of a "refine" statement, it is not refined and thus is used exactly as it was defined in the grouping.
如果分组中的节点不作为“精炼”语句的目标节点存在,则它不会被细化,因此完全按照在分组中定义的方式使用。
The argument string is a descendant schema node identifier (see Section 6.5 ).
参数字符串是后代模式节点标识符(参见第6.5节 )。
The following refinements can be done:
可以进行以下改进:
A leaf or choice node may get a default value, or a new default value if it already had one.
叶子或选择节点可能会获得默认值,如果已有,则可以获得新的默认值。
A leaf-list node may get a set of default values, or a new set of default values if it already had defaults;
叶子列表节点可以获得一组默认值,或者一组新的默认值(如果它已经有默认值); ie, the set of refined default values replaces the defaults already given.
即,一组精炼的默认值替换已经给出的默认值。
Any node may get a specialized "description" string.
任何节点都可以获得专门的“描述”字符串。
Any node may get a specialized "reference" string.
任何节点都可以获得专门的“引用”字符串。
Any node may get a different "config" statement.
任何节点都可能获得不同的“config”语句。
A leaf, anydata, anyxml, or choice node may get a different "mandatory" statement.
leaf,anydata,anyxml或choice节点可能会获得不同的“强制”语句。
A container node may get a "presence" statement.
容器节点可以获得“存在”语句。
A leaf, leaf-list, list, container, anydata, or anyxml node may get additional "must" expressions.
叶子,叶子列表,列表,容器,anydata或anyxml节点可能会获得其他“必须”表达式。
A leaf-list or list node may get a different "min-elements" or "max-elements" statement.
叶列表或列表节点可以获得不同的“min-elements”或“max-elements”语句。
A leaf, leaf-list, list, container, choice, case, anydata, or anyxml node may get additional "if-feature" expressions.
leaf,leaf-list,list,container,choice,case,anydata或anyxml节点可能会获得额外的“if-feature”表达式。
Any node can get refined extensions, if the extension allows refinement.
如果扩展允许细化,任何节点都可以获得精炼扩展。 See Section 7.19 for details.
详细信息请参见第7.19节 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.