ODL Calcium版本添加流规则失败求助
OpenDaylight添加流规则失败问题解决
问题分析与修复方案
1. 第一个URL错误原因及修正
请求URL http://127.0.0.1:8181/rests/data/opendaylight-inventory:nodes/node=openflow:1/table=0/flow=1 报错Schema for '(urn:opendaylight:inventory?revision=2013-08-19)table' not found,核心原因是未指定table所属的模块命名空间。table节点属于flow-node-inventory模块,必须明确标注前缀,正确URL应为:
http://127.0.0.1:8181/rests/data/opendaylight-inventory:nodes/node=openflow:1/flow-node-inventory:table=0/flow=1
2. 第二个URL请求体错误修正
POST请求报错Schema node with name in_port was not found under (urn:opendaylight:flow:inventory?revision=2013-08-19)match,是因为match字段名不匹配yang schema定义:
- 原请求体中
"in_port"需改为"in-port"(连字符格式) - 必须添加
flow-node-inventory命名空间前缀,确保字段归属正确
正确的请求体示例(JSON格式)
{ "flow-node-inventory:flow": [ { "id": "1", "table_id": 0, "match": { "flow-node-inventory:in-port": "openflow:1:1" }, "instructions": { "instruction": [ { "order": 0, "apply-actions": { "action": [ { "order": 0, "output-action": { "output-node-connector": "openflow:1:2", "max-length": 65535 } } ] } } ] }, "priority": 100, "hard-timeout": 0, "idle-timeout": 0 } ] }
额外注意事项
- 请求头必须包含
Content-Type: application/json和Accept: application/json,同时携带正确的认证信息(默认admin/admin) - 确保ODL已安装必要特性:至少包含
odl-openflowplugin-all、odl-restconf,或单独安装odl-openflowplugin-flow-services - 可用curl命令快速测试:
curl -u admin:admin -X PUT -H "Content-Type: application/json" -d @flow.json http://127.0.0.1:8181/rests/data/opendaylight-inventory:nodes/node=openflow:1/flow-node-inventory:table=0/flow=1
内容的提问来源于stack exchange,提问作者Frogsam
相关产品推荐
相关产品推荐

