简体   繁体   English

YANG:我怎样才能从另一个模块中包含一个容器?

[英]YANG: How can I include a container from another module?

I am writing a YANG module where I want to include a container from another module ie I want to define a NEW container in the module that I am writing that references a container from another module.我正在编写一个 YANG 模块,我想在其中包含来自另一个模块的容器,即我想在我正在编写的模块中定义一个新容器,该容器引用来自另一个模块的容器。 Example of failed attempt:失败的尝试示例:

 module newmodule {
 yang-version 1.1;
 namespace "urn:nist:params:xml:ns:yang:newmodule";
 prefix newmodule;

    import ietf-access-control-list {
      prefix "acl";
    }

    container newprofile {
      uses acl:access-lists;
    }
  }

I have only included the essential parts above.我只包括了上面的基本部分。 Here acl:access-lists is a container.这里 acl:access-lists 是一个容器。

Is it possible to compose containers like this?是否可以像这样组合容器? I've tried successfully to build containers from groupings.我已经成功地尝试从分组构建容器。 However, in this case I have no control over the contents of ietf-access-control-list.但是,在这种情况下,我无法控制 ietf-access-control-list 的内容。

You should import the first module in the second one, then augment the first with the second:您应该在第二个模块中导入第一个模块,然后用第二个模块扩充第一个模块:

Let's say the first module contains:假设第一个模块包含:

module first {
  yang-version 1.1;
  namespace "http://first";
  prefix first;

  container first-container {
    description
      "First container";
}

The second module shall have第二个模块应该有

module second {
  yang-version 1.1;
  namespace "http://second";
  prefix second;

  import first {
    prefix first;
  }

  augment "/first:first-container" {
    container second-container {
      description
        "Second container";
    }
  }
}

YANG 1.1 allows that operation: YANG 1.1允许这样的操作:

YANG allows a module to insert additional nodes into data models, including both the current module (and its submodules) and an external module. YANG 允许模块将附加节点插入数据模型,包括当前模块(及其子模块)和外部模块。 This is useful, for example, for vendors to add vendor-specific parameters to standard data models in an interoperable way.例如,这对于供应商以可互操作的方式将供应商特定参数添加到标准数据模型非常有用。

The "augment" statement defines the location in the data model hierarchy where new nodes are inserted, and the "when" statement defines the conditions when the new nodes are valid. “augment”语句定义了数据模型层次结构中插入新节点的位置,“when”语句定义了新节点有效时的条件。

This is apparently not possible.这显然是不可能的。 You can only use a grouping in this fashion and not a container.您只能以这种方式使用分组而不是容器。

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

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