我的设备yang如下图-
module router {
yang-version 1;
namespace "urn:sdnhub:odl:tutorial:router";
prefix router;
description "Router configuration";
revision "2015-07-28" {
description "Initial version.";
}
list interfaces {
key id;
leaf id {
type string;
}
leaf ip-address {
type string;
}
}
container router {
list ospf {
key process-id;
leaf process-id {
type uint32;
}
list networks {
key subnet-ip;
leaf subnet-ip {
type string;
}
leaf area-id {
type uint32;
}
}
}
list bgp {
key as-number;
leaf as-number {
type uint32;
}
leaf router-id {
type string;
}
list neighbors {
key as-number;
leaf as-number {
type uint32;
}
leaf peer-ip {
type string;
}
}
}
}
}
我正在使用 SDNHub Netconf 客户端来配置我的 netconf 设备(我正在使用模拟器)。我可以添加配置,但无法修改设备上的配置。
我的设备上的初始配置如下所示
{
"router": {
"ospf": [
{
"process-id": 21,
"networks": [
{
"subnet-ip": "12.1.1.1",
"area-id": 12
}
]
}
],"bgp": [
{
"as-number": "31",
"router-id": "123",
"neighbors": [
{
"as-number": "31",
"peer-ip": "1.1.1.1"
}
]
},
{
"as-number": "32",
"router-id": "1234",
"neighbors": [
{
"as-number": "32",
"peer-ip": "2.2.2.2"
}
]
}
]
}
}
我正在尝试修改 ospf 列表 放置http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/testtool/yang-ext:mount/router:router/ospf/21
具有以下有效负载,
{
"ospf":
[
{
"process-id" : "21",
"networks": [
{
"subnet-ip": "12.12.12.12",
"area-id": 1212
}
]
}
]
}
根节点上的配置被覆盖,并在 GET 上为我提供以下数据
{
"router":
{
"ospf": [
{
"process-id": 21,
"networks": [
{
"subnet-ip": "12.12.12.12",
"area-id": 1212
}
]
}
]
}
}
如果我发送了错误的请求,或者是否有任何其他方法可以更新 Netconf 设备上的配置,请告诉我。
最佳答案
我想您想更新ospf
中的网络;那么 URL 应该指向资源: process-id
索引该子树(根据需要 Section 4.5 of RFC 8040 ):
If the target resource represents a YANG list instance, then the key leaf values, in message-body representation, MUST be the same as the key leaf values in the request URI. The PUT method MUST NOT be used to change the key leaf values for a data resource instance.
PUT http://localhost:8181/restconf/path_until_router/router:router/ospf=21 HTTP/1.1
Content-Type: application/yang-data+json
{
"router:process-id": 21,
"router:networks": [
{
"subnet-ip": "12.1.1.1",
"area-id": 12
}
]
}
关于java - 如何更新启用 NETCONF 的设备上的配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43375330/