[NETCONF-789] Wrong url for POST requests in Web API Created: 13/Jul/21  Updated: 09/Jan/22  Resolved: 09/Jan/22

Status: Resolved
Project: netconf
Component/s: restconf-openapi
Affects Version/s: None
Fix Version/s: 1.13.6, 2.0.12

Type: Bug Priority: Medium
Reporter: Arne Chrestin Assignee: Dominik Vrbovský
Resolution: Done Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File karaf_test2.log    

 Description   

The described behavior was observed in Aluminium SR1, SR3 as well as Silicon SR1.

In the Web API, the body of example schemas for POST requests does not match to the request url. For example, for mounting a device, I can send a POST request to

https://onap.lab:30267/rests/data/network-topology:network-topology/topology=<topology name>

which is the top-level POST in the request group network-topology. The example schema proposed by the API is as follows:

 

<?xml version="1.0" encoding="UTF-8"?>
<topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
       (…)
  <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
         (…)
  </node>
</topology>

 

Sending this POST request produces an error message, because the enclosing <topology> tag is not a child node, while the next inner level of the example request, e.g. <node>, is a proper child node for the request url. 
It seems that the top-level POST url in the request groups goes one level "too deep". For a mounted NETCONF device, we could not send the whole <config> via the Web API because only child nodes of <config> were allowed.



 Comments   
Comment by Robert Varga [ 13/Jul/21 ]

Can you provide exact request URLs, payloads and karaf.log, please?

Comment by Arne Chrestin [ 14/Jul/21 ]

The POST request as per ODL Web API example:

url: (url for the top-level POST in the network-topology group of the Web API)
http://localhost:8181/rests/data/network-topology:network-topology
body: (Template shortened by me, keeping the salient elements)

<?xml version="1.0" encoding="UTF-8"?>
<network-topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
  <topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
     <topology-id xmlns="urn:TBD:params:xml:ns:yang:network-topology">topology-netconf</topology-id>
     <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
                <node-id>test</node-id>
                <host xmlns="urn:opendaylight:netconf-node-topology">10.43.9.24</host>
                <port xmlns="urn:opendaylight:netconf-node-topology">18883</port>
                <username xmlns="urn:opendaylight:netconf-node-topology">netconf</username>
                <password xmlns="urn:opendaylight:netconf-node-topology">netconf</password>
                <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
      </node>
 </topology>
</network-topology>

response: Code = 400 (Bad Request)

{
 "errors": {
 "error": [
{ "error-type": "protocol", "error-tag": "malformed-message", "error-info": "Child \"network-topology\" was not found in parent schema node \"(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)network-topology\"", "error-message": "Error parsing input: Child \"network-topology\" was not found in parent schema node \"(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)network-topology\"" }
]
 }
 }

 

The correct request:

url: same as above

body: (only remove the <network-topology> wrapper)

<?xml version="1.0" encoding="UTF-8"?>
 <topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
 <topology-id xmlns="urn:TBD:params:xml:ns:yang:network-topology">topology-netconf</topology-id>
     <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
                <node-id>test</node-id>
                <host xmlns="urn:opendaylight:netconf-node-topology">10.43.9.24</host>
                <port xmlns="urn:opendaylight:netconf-node-topology">18883</port>
                <username xmlns="urn:opendaylight:netconf-node-topology">netconf</username>
                <password xmlns="urn:opendaylight:netconf-node-topology">netconf</password>
                <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
      </node>
 </topology>

response: Code = 201 (Created)

Note: Despite the error message above, after sending the first request, I have to send a DELETE request before sending the second (successful) POST. If I don't send the DELETE, I get the following error for the second request: Code 409 (Conflict)

 

{
  "errors": {
    "error": [
      {
        "error-path": "/network-topology:network-topology/topology[topology-id='topology-netconf']",
        "error-type": "protocol",
        "error-tag": "data-exists",
        "error-message": "Data already exists"
      }
    ]
  }
}

 

 

 

In analogy, when I go to the next level in the same group, the POST request url is
http://localhost:8181/rests/data/network-topology:network-topology/topology=1
and the example request body starts with

<?xml version="1.0" encoding="UTF-8"?>
<topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
   <topology-types xmlns="urn:TBD:params:xml:ns:yang:network-topology">
      <topology-netconf xmlns="urn:opendaylight:netconf-node-topology"> </topology-netconf>
   </topology-types>
   <underlay-topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
      <topology-ref xmlns="urn:TBD:params:xml:ns:yang:network-topology">Some topology-ref</topology-ref>
   </underlay-topology>
   <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
...

which creates the same error as above. Again, the outermost tag <topology> must be removed and the request should start with <node> to get it working.

The same is observed in other groups.

 

Attaching the karaf.log above (I used ODL Aluminium SR1 from an ONAP SDNC image here).

 

Comment by Robert Varga [ 20/Jul/21 ]

Hmm, the logs are a bit unfriendly here:

2021-07-14T11:14:59,364 | WARN  | qtp656141606-309 | RestconfDocumentedExceptionMapper | 339 - org.opendaylight.netconf.restconf-nb-rfc8040 - 1.12.1 |  -  | Input exception has a family of 4xx but doesn't contain any descriptive errors: errors: [RestconfError [error-type: protocol, error-tag: malformed-message, error-message: Error parsing input: Child "network-topology" was not found in parent schema node "(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)network-topology", error-info: Child "network-topology" was not found in parent schema node "(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)network-topology"]]
2021-07-14T11:15:24,166 | WARN  | qtp656141606-120 | RestconfDocumentedExceptionMapper | 339 - org.opendaylight.netconf.restconf-nb-rfc8040 - 1.12.1 |  -  | Input exception has a family of 4xx but doesn't contain any descriptive errors: errors: [RestconfError [error-type: protocol, error-tag: data-exists, error-message: Data already exists, error-path: /(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)network-topology/topology/topology[{(urn:TBD:params:xml:ns:yang:network-topology?revision=2013-10-21)topology-id=topology-netconf}]]]

https://git.opendaylight.org/gerrit/c/netconf/+/96941 should help with that.

Comment by Robert Varga [ 21/Jul/21 ]

Okay, so the primary problem is in apidoc explorer, as its examples should follow https://datatracker.ietf.org/doc/html/rfc8040#appendix-B.2.1 .

Generated at Wed Feb 07 20:15:54 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.