【问题标题】:How to augment list from one module to another and add leafs YANG如何将列表从一个模块增加到另一个模块并添加叶子 YANG
【发布时间】:2021-02-04 10:09:54
【问题描述】:

假设我有两个模块,我想用新的叶子扩展一个列表。

module A {
    list deviceList {
        key name;
        leaf name{

        }
        leaf hostname{

        }
    }
}

我想将它扩充到另一片叶子

module B {
    list generalInfo{
        key customerName;
        leaf customerName{
            type string;
        }
        augment moduleA:deviceList {
            leaf ipAddress{
                
            }
        }
}

我已经使用分组、容器和列表来完成它,但这完全改变了我们现有的结构,如果可能的话,我想省略容器和分组。

【问题讨论】:

    标签: ietf-netmod-yang


    【解决方案1】:

    您似乎想重用架构定义的一部分,将其放在架构树中的另一个位置并为其添加一个节点。

    您无法按照您尝试的方式进行操作,因为augment 语句只能出现在根级别或uses 语句中。

    您只能使用 grouping 执行此操作,但您可以省略 container。重构 A:定义一个 grouping,即 list。在 B 中引用它并对其进行扩充。

    module A {
        grouping devices {
          list deviceList {
            key name;
            leaf name{
            }
            leaf hostname{
            }
          }
        }
        uses devices;
    }
    
    module B {
        list generalInfo{
            key customerName;
            leaf customerName{
                type string;
            }
            uses moduleA:devices {
              augment "deviceList" {
                leaf ipAddress{
                }
              }
            }
        }
    }
    

    请注意,如果您在模块 B 中使用 augment 语句,则意味着任何实现模块 B 的设备也必须实现模块 A 及其根级 list deviceList。见RFC 7950 4.2.8

    当服务器实现一个包含“augment”语句的模块时, 这意味着服务器对增强模块的实现 包含额外的节点。

    我不确定这是否是您想要的。如果不是,则将分组定义移动到仅包含分组定义(没有任何“数据定义语句”)的模块中,并从 A 和 B 中导入。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-03
      • 1970-01-01
      • 1970-01-01
      • 2015-02-20
      • 1970-01-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多