CESNET / netopeer2

NETCONF toolset
BSD 3-Clause "New" or "Revised" License
290 stars 186 forks source link

Question: Can notification drive client side sysrepo callback? #1518

Closed BillYJT closed 5 months ago

BillYJT commented 6 months ago

Hi.

I want to use the netopeer client and server in an SDN controller and agent scenario, where the agent(server) creates some notification that drives some subscribed callback logic on the controller(client) side.

I would like to know if the provided netopeer-cli implementation automatically propagates the received notification to the client-side sysrepo subscribed callback. I also see the mentioning of this project which mentioned local interaction with sysrepo. But would like some clarification.

Any input is very much appreciated. Thanks!

michalvasko commented 6 months ago

To answer, no, netopeer2-cli does not notify locally subscribed sysrepo applications when it receives a notification. What you are trying to do is not officially supported so you will have to find your own way of doing so. For example, writing your own simple NETCONF client (or modifying netopeer2-cli) that would just send received notifications to sysrepo should not be difficult.

BillYJT commented 6 months ago

Hi, Michal. Thanks again for the prompt and concise response.

Is there any particular part of the netopeer2-cli that you could point me to that could be a good place to interface with sysrepo? If not, it's also fine, I guess I will just need to learn the code.

michalvasko commented 6 months ago

You could just send the notification to sysrepo when it is received in the CLI in its callback.

jktjkt commented 6 months ago

Since you mentioned SDN, I assume that you're after an architecture where there's a NETCONF server, and you're writing a client which connects to the NETCONF server and which listens for notifications. Right? If that's the case, you can ignore sysrepo completely because it's "just an implementation detail of a server"; your application code won't really be aware of sysrepo because the communication is all defined by the NETCONF standard.

In that scenario, you'll need a NETCONF client library, such as libnetconf2. That library has features for waiting for NETCONF notifications. (If you prefer C++, there's also the C++ wrapper around that, the libnetconf2-cpp.) Once you've learned how to use that library, just write some code which uses that library for notification processing, and do whatever you want to do with that information.

BillYJT commented 5 months ago

Thank you both, Michal and Jan. My question is answered.