opendaylight - 杨: How can I include a container from another module?

标签 opendaylight ietf-netmod-yang

我正在编写一个 YANG 模块,我想在其中包含来自另一个模块的容器,即我想在我正在编写的模块中定义一个新容器,该模块引用来自另一个模块的容器。失败尝试的示例:

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

我只包含了上面的基本部分。这里的 acl:access-lists 是一个容器。

是否可以这样组合容器?我已经尝试成功地从分组构建容器。但是,在这种情况下,我无法控制 ietf-access-control-list 的内容。

最佳答案

您应该在第二个模块中导入第一个模块,然后用第二个模块扩充第一个模块:

假设第一个模块包含:

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

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

第二个模块应具有

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允许该操作:

YANG allows a module to insert additional nodes into data models, including both the current module (and its submodules) and an external module. 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.

关于opendaylight - 杨: How can I include a container from another module?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47021180/

相关文章:

protocol-buffers - 杨 vs Protobuf

java - 从 Yang 模型生成 xml/json

java - 失败 : org. apache.maven 插件 :maven-jar-plugin:2. 6:test-jar

java - 使用yangtools解析yang模块失败

ietf-netmod-yang - Yang action vs rpc 和 anydata vs anyxml

java - JAVA中的Yang解析

java - 使用 Opendaylight 通过 NETCONF 检索列表时出现错误 "Duplicate namespace in XML input"

ssh - 如何在Google Cloud的OpenDaylight Controller 中打开DLUX UI

java - ODL Fluorine RpcRegistration 已弃用 现在如何注册 RPC?