首页 > 解决方案 > Opendaylight yangtools XML编码乱序键列表

问题描述

当 yang 模型有一个包含多个键的列表时,ODL 在将请求向下发送到 netconf 设备时不会维护属性的顺序。从 RFC 6020 看来,需要严格遵守顺序。

“列表的关键节点被编码为列表标识符元素的子元素,其顺序与它们在“关键”语句中定义的顺序相同。”

主要是我的供应商设备在创建无序列表时没有抱怨,但在删除过程中抱怨错误。

杨模型示例:

container acl-config {
    list acl-config-list {
    key "tenant-id access-control-list-id";
    leaf tenant-id {
        type leafref {
        path "/tenant:tenant-config/tenant:tenant-list/tenant:tenant-id";
        }
    description
        "Unique identifier of the Tenant";
    }

    leaf access-control-list-id {
        type custom-id;
        mandatory true;
        description
            "Unique ACL identifier";
    }
}

删除操作期间编码时的ODL发送请求如下:

<edit-config>
<target>
<running/>
</target>
<default-operation>none</default-operation>
<error-option>rollback-on-error</error-option>
<config>
<acl-config xmlns="http://example.com/acl">
<acl-config-list>
<access-control-list-id>acl7</access-control-list-id>
<tenant-id>f81d4fae-7dec-11d0-a765-00a0c91e6bf6</tenant-id>
<acl-dst-config xmlns:a="urn:ietf:params:xml:ns:netconf:base:1.0" 
a:operation="delete"/>
</acl-config-list>
</acl-config>
</config>
</edit-config>
</rpc>

我希望先对租户 ID 进行编码,而不是按照 yang 中定义的密钥顺序对 access-control-list-id 进行编码。删除操作期间设备抛出错误

<rpc-error>
<error-type>protocol</error-type>
<error-tag>missing-element</error-tag>
<error-severity>error</error-severity>
<error-message xml:lang="en">Invalid position of the key "tenant-id" in a 
list "acl-config-list".</error-message>
<error-info>
<bad-element>/access_control_list:acl-config/acl-config-list[access- 
control-list-id='acl7']/tenant-id</bad-element>
</error-info>
</rpc-error>

我希望 ODL 在 XML 编码期间遵循严格的关键节点顺序并按照 RFC 6020 声明。这没有发生,设备纯粹基于无序问题拒绝请求。这是 ODL yangtools XML 编码问题中的错误,还是设备真的应该以任何顺序处理请求?

标签: opendaylightnetconf

解决方案


看起来这个问题在这里得到了回答


推荐阅读