Repository navigation
Edit YANG instance using NETCONF operations #24
Description
Activity
Hi,
I am not sure libyang is suitable for this. Maybe you should have a look at sysrepo (or sysrepo-python).
- changed the title
[-]Feature Request | Edit YANG instance using NETCONF operations[/-][+]Edit YANG instance using NETCONF operations[/+]on Jun 1, 2021 Would need to explore more deeply on what's possible using libyang2. As there is a method to "merge" data instances, it would be an obvious requirement to do "replace", "remove", "create" and "replace" to modify data instances (dnode). This would be useful to implement dryrun/preview as with Ansible.
In that case, maybe you are looking for lyd_diff()
https://github.com/CESNET/libyang/blob/libyang1/src/tree_data.h#L415
Hi @rjarry
I've look intolyd_diffalready. To use it the way I want, the target device must support the candidate datastore (NETCONF). It would not work with RESTCONF nor gNMI...So the idea is, that you can retrieve the current device config, apply the change and look what would be different.
This needs to be supported by libyang itself. I do not think we will implement this only in the python bindings. If you need it you can submit a pull request on libyang. Note that the python bindings are incomplete and lyd_diff is not yet supported.
@rjarry... Let me review what is available in libyang2 first. I guess, that editing data instances is sort of a basic requirement for an advanced YANG engine like libyang. Converting dnodes to native XML, JSON or dict to modify and converting it back to XML, JSON or dict thereafter does not sound like a good approach at all. Also editing XML, JSON or dict is sort of tricky because of the way that lists are converted - so access by key(s) requires quite some extra code.
Hi @wisotzky , do you still need that? If you need NETCONF, isn't ncclient (for instance) more suited to your needs?
At the moment, NETCONF operations are carried but are not functional. It would be useful, to dry-run an
edit-configoperation that uses thenc:operationas defined.