Closed pklepikov closed 3 years ago
Hi @pklepikov
Yes, it's a little ugly but that's how it works right now.
Using --update-path
and --update-value
defaults to using value type json
, this was to facilitate interacting with SROS.
if you want a specific type (one of "json", "json_ietf", "string", "int", "uint", "bool", "decimal", "float", "bytes", "ascii"
) using --update
or --update-file
is the way to go.
--update-file
will take into account --encoding
since files will most probably be either json or json_ietf
Those are method 1 and method 2 you used.
There is an option to improve this which I'm not sure will be any better or any prettier:
Add a --update-type
flag to Set cmd which takes one of "json", "json_ietf", "string", "int", "uint", "bool", "decimal", "float", "bytes", "ascii".
The resulting command will look like:
gnmic set --update-path /system/name/host-name --type json_ietf --update-value new_hostname
This also means a --replace-type
flag needs to be added to Set cmd.
Multiple --update-type
and --replace-type
can be used and will be matched with --update-path
and --replace-path
according to their order.
Resulting command:
gnmic set --update-path /dummy/path/1 --update-type json_ietf --update-value val1 \
--update-path /dummy/path/2 --update-type string --update-value val2 \
--replace-path /dummy/path/3 --replace-type bool --replace-value val3
Let me know what you think about it, or if you have any alternate way to handle these cases.
Hi @pklepikov ,
Another approach is embedding the type in the --update-value
flag like this:
gnmic set --update-path /dummy/path/1 --update-value json_ietf:::val1
If the value contains/starts with a :::
the --delimiter
flag can be used :
gnmic set --update-path /dummy/path/1 --update-value json_ietf@val1 --delimiter @
Thoughts ?
I try to gnmic client to update some values on SRLinux platform, which supports json_ietf encoding.
Here is a simple example with hostname change:
Debug message:
If i try to change hostname using another method, everything is successfully changed Method-1:
Method-2
Complete log for all combinations log.txt