【问题标题】:How many leafref is possible inside a leaf in Yang modelling?在杨建模中,一片叶子内可能有多少个叶子引用?
【发布时间】:2023-03-03 09:43:01
【问题描述】:

根据 RFC - RFC 6020 - LeafRef 我可以理解叶子可以包含一个叶子引用,而叶子引用又具有指向被引用实例的路径,但问题是一个叶子可以有多少个叶子引用?只有一个还是多个?

例如

leaf mgmt-interface {
         type leafref {
             path "../interface/name";
         }
         type leafref {
             path "../interface/ip";
         }
     }

以上可以吗?

【问题讨论】:

    标签: datamodel ietf-netmod-yang


    【解决方案1】:

    leafref 只能通过path 定位单个leafleaf-list 节点。一个叶子可能只有一个type 子语句(也适用于leaf-listtypedef),并且type 可能只有一个path 子语句。

    7.6.2. The leaf's Substatements

    +--------------+---------+-------------+
    | substatement | section | cardinality |
    +--------------+---------+-------------+
    | config       | 7.19.1  | 0..1        |
    | default      | 7.6.4   | 0..1        |
    | description  | 7.19.3  | 0..1        |
    | if-feature   | 7.18.2  | 0..n        |
    | mandatory    | 7.6.5   | 0..1        |
    | must         | 7.5.3   | 0..n        |
    | reference    | 7.19.4  | 0..1        |
    | status       | 7.19.2  | 0..1        |
    | type         | 7.6.3   | 1           | <--
    | units        | 7.3.3   | 0..1        |
    | when         | 7.19.5  | 0..1        |
    +--------------+---------+-------------+
    

    12. YANG ABNF Grammar

    type-stmt           = type-keyword sep identifier-ref-arg-str optsep
                         (";" /
                          "{" stmtsep
                              type-body-stmts
                          "}")
    
    type-body-stmts     = numerical-restrictions /
                         decimal64-specification /
                         string-restrictions /
                         enum-specification /
                         leafref-specification /
                         identityref-specification /
                         instance-identifier-specification /
                         bits-specification /
                         union-specification
                         
    leafref-specification =
                         ;; these stmts can appear in any order
                         path-stmt stmtsep
                         [require-instance-stmt stmtsep]
    
    path-stmt           = path-keyword sep path-arg-str stmtend
    

    注意:在 YANG 1.0 中,leafref 类型不能使用 union。这在 YANG 1.1 中有所改变,但是任何内置的 YANG 类型都可能出现在 union 中。

    9.12. The union Built-In Type

    成员类型可以是任何内置或派生类型,但必须 不是内置类型“empty”或“leafref”之一。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-08
      • 2011-07-04
      • 2014-04-04
      • 1970-01-01
      • 2017-02-24
      • 2020-07-08
      • 2021-01-02
      相关资源
      最近更新 更多