cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
883
Views
0
Helpful
7
Replies

CLI vs REST leaf-list behaviour

suinduku
Cisco Employee
Cisco Employee

How to replace(override) old value(s) in a leaf-list with new value(s) during every update? 

Tried below, 

leaf-list <leaf-name>

{                   

    ----                 

  tailf:cli-replace-all;

  ------}

  But this is working only with cli, but not with REST call.   With REST call, new values are getting appended to old values instead of overriding.   Please suggest how to achieve  this through REST.

7 Replies 7

Jan Lindblad
Cisco Employee
Cisco Employee

Is this YANG part of a device YANG model? Assuming so, which NED?

Are you interested to replace all values in a single go because the device requires this behavior for proper operation? If so, it is up to the NED to do this correctly. There is no way to control this behavior from the NB side (e.g. REST/RESTCONF client), and there shouldn't be.

I need this for service yang model.

NED(cisco-ios 5.4) is having this constraint already. i.e., able to override the old values with new, if we verify in NED directly.

But as service model is appending the new values with old values, it is passing all the values(old and new) to the NED.

dheidric
Cisco Employee
Cisco Employee

Are you using PUT, POST or PATCH?

http - What is the difference between PUT, POST and PATCH? - Stack Overflow

It seems like PUT is what you need.

-Don

I am using PATCH, not very sure if I can use PUT in our context. I will check on this.

It is not allowed to use PUT. It might be as with PUT, we have to provide all the details again, not just only the parameter that we intended to update.

Got following response:

HTTP/1.1 405 Method Not Allowed

Server:

Allow: DELETE, GET, HEAD, PATCH

Allow: GET, POST, OPTIONS, HEAD

Content-Length: 0

Content-Type: text/html

I was able to make PUT work with NSO – see my example below – attaching my Yang model for reference.

Vlans is a leaf-list.

curl -i -u admin:admin \

http://localhost:8080/api/running/aws/Sheraton/site/Lake_Shore_Drive/vlans \

-X PUT \

-H "Content-Type: application/vnd.yang.data+json" \

-d '{

"aws:vlans": ["99"]

}'

If you have a complex RESTCONF payload with some things being added/updated, others removed etc, you may need to use the YANG Patch media type: https://tools.ietf.org/html/rfc8072 That will allow you to replace the contents of the service model leaf-list, for example, while doing other things to other content.