java - 如何更新启用 NETCONF 的设备上的配置?

标签 java sdn ietf-netmod-yang ietf-netconf

我的设备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/

相关文章:

用于角度应用程序的 Java webdriver 不是 Protractor ?

Java Process Servers 好主意与否?

c - 如何让openflow交换机能够在ip数据包的id字段上标记信息?

networking - SDN中的管理平面是什么?

java - 如何从java桌面应用程序中保存fos_user数据

java - 为什么 guava 缓存只能在本地缓存中存储非空值以及如何绕过这个问题

python - 通过 Mininet python API 设置的带宽不会反射(reflect)在 Opendaylight 中

ietf-netmod-yang - yang 中默认值的条件赋值

opendaylight - 在哪里可以找到使用 opendaylight 解析 YANG 文件的示例

ietf-netmod-yang - 叶节点 'when' 或 'must' 语句用法