1

My device yang is as shown below -

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;
                }
            }
        }
    }
}

I am using the SDNHub Netconf Client to configure my netconf device(I'm using a simulator). I'm able to add configurations, but I'm not able to modify configurations on the device.

The initial configurations on my device is shown below

{

  "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"
        }
      ]
    }
  ]
  }
}

I'm trying to modify the ospf list with PUT http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/testtool/yang-ext:mount/router:router/ospf/21

with the following payload,

{
  "ospf":
   [

    {

    "process-id" : "21",
        "networks": [
          {
            "subnet-ip": "12.12.12.12",
            "area-id": 1212
          }
        ]
  }
]
}

The configurations on the root node gets over-written and gives me the following data on GET

{
  "router": 
{

    "ospf": [
      {
        "process-id": 21,
        "networks": [
          {
            "subnet-ip": "12.12.12.12",
            "area-id": 1212
          }
        ]
      }
    ]
  }
}

Please let me know if I'm sending a wrong request or if there is any other way to update configurations on a Netconf device.

predi
  • 5,528
  • 32
  • 60
  • Your payload is probably wrong. Take a look at [https://datatracker.ietf.org/doc/html/rfc8040#section-4.5](https://datatracker.ietf.org/doc/html/rfc8040#section-4.5) on how to use PUT. There's an example. Maybe just keep the `networks` branch of the payload. BTW, this is RESTCONF, not NETCONF. – predi Apr 13 '17 at 07:59
  • Thanks for your reply. Can you tell me what payload should I use to add an ospf node to the existing initial configurations ? This is the rest url http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/testtool17831_2/yang-ext:mount/router:router/ospf/{process-id} Is this URL valid btw ? – Priya Ravichander Apr 13 '17 at 12:11
  • Not sure. Try `http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/testtool/yang-ext:mount/router:router/ospf=21`, and with the payload being just `{"networks": [{"subnet-ip": "12.12.12.12", "area-id": 1212}]}`. – predi Apr 13 '17 at 12:42

1 Answers1

1

I suppose you would like to update the network in ospf; then the URL should point till the resource: process-id indexes that subtree (as requires 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
    }
  ]
}
Community
  • 1
  • 1
Ariel Otilibili
  • 260
  • 1
  • 6