OpenDayLight SDN无法通过RESTCONF获取仪表表信息求助
问题背景
使用OpenDayLight 0.8.4、Openvswitch 13和Mininet 2.3.0环境,调用REST API /restconf/operational/opendaylight-inventory:nodes/node/openflow:1/meter/0 获取仪表信息时,出现错误:
Data-missing : Request could not be completed because the relevant data model content does not exist. - : Request could not be completed because the relevant data model content does not exist
已安装的ODL模块包括:
opendaylight-user@root>feature:install odl-restconf opendaylight-user@root>feature:install odl-l2switch-all opendaylight-user@root>feature:install odl-l2switch-switch opendaylight-user@root>feature:install odl-l2switch-switch-ui opendaylight-user@root>feature:install odl-openflowplugin-flow-services-rest opendaylight-user@root>feature:install odl-mdsal-all opendaylight-user@root>feature:install odl-dluxapps-applications
流表相关API(如http://localhost:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/table/0)可正常访问,说明OpenFlow基础功能正常,问题出在Meter相关模块缺失。
解决步骤
1. 安装Meter相关核心模块
进入ODL的Karaf控制台,执行以下命令安装缺失的Meter服务及REST接口模块:
opendaylight-user@root>feature:install odl-meterservice opendaylight-user@root>feature:install odl-openflowplugin-meter-services-rest
odl-meterservice:ODL处理Meter配置与状态的核心服务模块odl-openflowplugin-meter-services-rest:提供Meter相关的RESTCONF接口支持,对应你调用的API路径
2. 验证模块安装状态
执行以下命令确认模块已成功启动:
opendaylight-user@root>feature:list | grep meter
输出中应能看到odl-meterservice和odl-openflowplugin-meter-services-rest处于Started状态。
3. 验证API可用性
重新调用目标API:
/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/meter/0
注意:如果
meter/0尚未创建,仍会提示数据不存在。此时需要先通过RESTCONF创建Meter实例,示例POST请求(JSON格式):
请求路径:/restconf/config/opendaylight-inventory:nodes/node/openflow:1/meter/0
请求体:{ "meter": [ { "meter-id": 0, "flags": ["meter-kbps"], "bands": [ { "band-id": 0, "type": "drop", "rate": 1000 } ] } ] }
内容的提问来源于stack exchange,提问作者user25424132

