Closed pedroaston closed 7 months ago
There isn't a standard package here because there are different ways that one might need to apply the config. For example, maybe you want to update
the config vs. replace
it -- or include other parameters.
You can just take the JSON that is output by ygot
and provide it to the device as a json_ietf_val
in the gNMI TypedValue
message.
The ygnmi
library has some helpers around using gNMI, particularly with OpenConfig schemas, and would also provide some primitives around update
and replace
.
Agreed with Rob. ygnmi is very useful if you're interested in a lot of interactions with a gNMI server.
FYI, I know it's not the question you asked, but because I was looking at the similar Cisco schema recently, just wanted to share that you might want to use the helper funcs ygot supports, which really help with readability. I think roughly your code above would be the following (no long struct names, no initializing vars, you can work down the hierarchy of the model, and if you get autocomplete working on the generated structs, this just takes a few minutes to type out).
i := device.GetOrCreateInterfaces().GetOrCreateInterface("Loopback666") i.Description = ygot.String("test_gnmi_ygot_pipeline")
ipv4 := i.GetOrCreateIpv4().GetOrCreateAddresses().GetOrCreateAddress() ipv4.Address = ygot.String("1.1.1.1") ipv4.Netmask = ygot.String("255.255.255.255")
ipv6 := i.GetOrCreateIpv6().GetOrCreateAddresses().GetOrCreateIpv6Address("9000::1") ipv6.PrefixLength = ygot.Uint8(128) ipv6.Zone = ygot.String("0")
You might just need to add the necessary flags for ygot to generate this. (i.e. -generate_append -generate_getters)
Hey! Thank you all for the feedback 👍
I followed @robshakir's hint and placed the interface yang leaf in as a TypedValue. The below snippet configures a loopback interface on a router successfully. Still need to manually assemble the yang leaf path.
@wenovus I saw on another issue that you were looking into developing path struct generation without compressed paths. Have you abandoned it?
I haven't properly checked ygnmi helpers. I may give it a better look in the future.
PS: For question/discussion-related topics is there an openconfig slack or forum like space?
Do you have a link to the issue? I probably need to update it if it's still an open issue.
ygnmi already supports uncompressed structs as of this commit: https://github.com/openconfig/ygnmi/commit/5559c6e7160615f4d6c607151cc3e427b992072b
The path struct generation in ygot is deprecated. It is planned to be deleted prior to v1 release (work which is currently on-pause).
Per the OpenConfig website GitHub issues are the preferred channel: https://openconfig.net/about/contribute/. There is a also a public forum linked there but it's lower volume than the GitHub repos.
Hey! It was issue #888. However, now that I've read it again, you did mention that path struct generation was implemented in ygnmi in that issue. I will check the path struct generation there.
Closing this one. Thanks
Hey there! I've been exploring the ygot package and played with generated code from the Cisco interfaces yang models. I manage to create manually (for now) with the code below, a perfect replica of the json model inside the router.
Code used to manually assemble:
Resulting JSON:
From the examples and docs it seems the package currently does not transform a goStruct generated from the Yang into a gNMI SetRequest Update correct? Is there another openconfig package to tackle this issue?
Thanks 😄