Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in-line update using implicit type not working with YANG list #535

Open
sanooprajan opened this issue Oct 25, 2024 · 8 comments
Open

in-line update using implicit type not working with YANG list #535

sanooprajan opened this issue Oct 25, 2024 · 8 comments

Comments

@sanooprajan
Copy link

I am trying to do a "set" operation using in-line update and implicit type using both --update-path and --update-value flags as below for a path that is a yang list not a leaf. But it fails.

gnmic set --update-path --update-value

however if i do the update with a value from JSON using both--update-file flag for the value and --update-path for the path, it works. Looks like it is not able to parse a list in command line. is this a bug ?

@hellt
Copy link
Collaborator

hellt commented Oct 25, 2024

without logs it is impossible to tell
you can use prototext or protojson output format to see the raw values sent to the target

@karimra
Copy link
Collaborator

karimra commented Oct 26, 2024

Also, what kind of error do you get back?

@sanooprajan
Copy link
Author

gnmic --insecure set --update-path /interfaces/interface[name=et-0/0/4]/subinterfaces/subinterface[index=0]/ipv4/addresses/address[ip=11.11.11.1] --update-value 11.11.11.1 --log --format protojson

2024/10/28 14:54:30.290072 [gnmic] version=0.38.2, commit=7b315880, date=2024-07-26T00:31:56Z, gitURL=https://github.com/openconfig/gnmic, docs=https://gnmic.openconfig.net
2024/10/28 14:54:30.290109 [gnmic] using config file ""
2024/10/28 14:54:30.290307 [gnmic] adding target {"name":"10.92.70.138:9339","address":"10.92.70.138:9339","username":"root","password":"****","timeout":10000000000,"insecure":true,"skip-verify":false,"buffer-size":100,"retry-timer":10000000000,"log-tls-secret":false,"gzip":false,"token":""}
2024/10/28 14:54:30.290744 [gnmic] sending gNMI SetRequest: prefix='', delete='[]', replace='[]', update='[path:{elem:{name:"interfaces"} elem:{name:"interface" key:{key:"name" value:"et-0/0/4"}} elem:{name:"subinterfaces"} elem:{name:"subinterface" key:{key:"index" value:"0"}} elem:{name:"ipv4"} elem:{name:"addresses"} elem:{name:"address" key:{key:"ip" value:"11.11.11.1"}}} val:{json_val:""11.11.11.1""}]', extension='[]' to 10.92.70.138:9339
2024/10/28 14:54:30.291608 [gnmic] creating gRPC client for target "10.92.70.138:9339"
2024/10/28 14:54:30.592317 [gnmic] target "10.92.70.138:9339" set request failed: target "10.92.70.138:9339" SetRequest failed: rpc error: code = InvalidArgument desc = syntax error, expecting "@";
target "10.92.70.138:9339" set request failed: target "10.92.70.138:9339" SetRequest failed: rpc error: code = InvalidArgument desc = syntax error, expecting "@";
Error: one or more requests failed

@sanooprajan
Copy link
Author

is this something that you requested for ? Let me know if you need something else.

@hellt
Copy link
Collaborator

hellt commented Nov 6, 2024

please format the code snippet with triple backticks

```
your output goes here
```

And I believe you're not providing the expected inline value, your path /interfaces/interface[name=et-0/0/4]/subinterfaces/subinterface[index=0]/ipv4/addresses/address[ip=11.11.11.1] points to a list element, not just a plain value.
you should consider using json/yaml file and put your interface config there.

To see how to use gnmic with openconfig paths you can check this resource.

@sanooprajan
Copy link
Author

sanooprajan commented Nov 6, 2024

gnmic --insecure set --update-path /interfaces/interface[name=et-0/0/4]/subinterfaces/subinterface[index=0]/ipv4/addresses/address[ip=11.11.11.1] --update-value 11.11.11.1 --log --format protojson

2024/10/28 14:54:30.290072 [gnmic] version=0.38.2, commit=7b315880, date=2024-07-26T00:31:56Z, gitURL=https://github.com/openconfig/gnmic, docs=https://gnmic.openconfig.net/ 2024/10/28 14:54:30.290109 [gnmic] using config file "" 2024/10/28 14:54:30.290307 [gnmic] adding target {"name":"10.92.70.138:9339","address":"10.92.70.138:9339","username":"root","password":"****","timeout":10000000000,"insecure":true,"skip-verify":false,"buffer-size":100,"retry-timer":10000000000,"log-tls-secret":false,"gzip":false,"token":""} 2024/10/28 14:54:30.290744 [gnmic] sending gNMI SetRequest: prefix='', delete='[]', replace='[]', update='[path:{elem:{name:"interfaces"} elem:{name:"interface" key:{key:"name" value:"et-0/0/4"}} elem:{name:"subinterfaces"} elem:{name:"subinterface" key:{key:"index" value:"0"}} elem:{name:"ipv4"} elem:{name:"addresses"} elem:{name:"address" key:{key:"ip" value:"11.11.11.1"}}} val:{json_val:""11.11.11.1""}]', extension='[]' to 10.92.70.138:9339 2024/10/28 14:54:30.291608 [gnmic] creating gRPC client for target "10.92.70.138:9339" 2024/10/28 14:54:30.592317 [gnmic] target "10.92.70.138:9339" set request failed: target "10.92.70.138:9339" SetRequest failed: rpc error: code = InvalidArgument desc = syntax error, expecting "@"; target "10.92.70.138:9339" set request failed: target "10.92.70.138:9339" SetRequest failed: rpc error: code = InvalidArgument desc = syntax error, expecting "@"; Error: one or more requests failed

@hellt It works if i use json, the problem is with in-line update. Are you saying with in-line update we cant have list values?

@hellt
Copy link
Collaborator

hellt commented Nov 6, 2024

you often can, but you will have to provide the json string inline, and escape all the characters that would otherwise mean an element delimiter, for instance.

inline values are good for changing a single value (bool, str, int), but not great for json objects

@sanooprajan
Copy link
Author

@hellt Is it possible to have an enhancement and extend it to list value update also ? I was using the templated way of config push like below.
gnmic set --request-file <template1> --request-file <template2> --request-vars <vars_file>
Can it take json object as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants