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

Edit YANG instance using NETCONF operations #24

Open
wisotzky opened this issue May 31, 2021 · 7 comments
Open

Edit YANG instance using NETCONF operations #24

wisotzky opened this issue May 31, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@wisotzky
Copy link

At the moment, NETCONF operations are carried but are not functional. It would be useful, to dry-run an edit-config operation that uses the nc:operation as defined.

@rjarry
Copy link
Collaborator

rjarry commented Jun 1, 2021

Hi,

I am not sure libyang is suitable for this. Maybe you should have a look at sysrepo (or sysrepo-python).

@rjarry rjarry changed the title Feature Request | Edit YANG instance using NETCONF operations Edit YANG instance using NETCONF operations Jun 1, 2021
@rjarry rjarry added the enhancement New feature or request label Jun 1, 2021
@wisotzky
Copy link
Author

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.

@rjarry
Copy link
Collaborator

rjarry commented Jun 14, 2021

In that case, maybe you are looking for lyd_diff()

https://github.com/CESNET/libyang/blob/libyang1/src/tree_data.h#L415

@wisotzky
Copy link
Author

Hi @rjarry
I've look into lyd_diff already. 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.

@rjarry
Copy link
Collaborator

rjarry commented Jun 14, 2021

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.

@wisotzky
Copy link
Author

@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.

@samuel-gauthier
Copy link
Collaborator

Hi @wisotzky , do you still need that? If you need NETCONF, isn't ncclient (for instance) more suited to your needs?

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

No branches or pull requests

3 participants