CESNET / libnetconf

C NETCONF library
Other
113 stars 84 forks source link

Query on right API to use to get sessions information #291

Open PravalliSure opened 2 weeks ago

PravalliSure commented 2 weeks ago

I have a situation where I need to send a kill-session from a sysrepo application on a different session that locked Datastore. I did this and I am able to kill the session

  rpc = nc_rpc_kill(1);
  msgtype = nc_send_rpc(session, rpc, 0, &msgid);

Now I want to extract the session id from ietf-netconf-monitoring which locked running datastore and send it as parameter. Which is the best netconf API that I can use?

  const char* get_locks_rpc = "/ietf-netconf-monitoring:netconf-state/datastores/datastore[name='running']";
  nc_rpc* rpc = nc_rpc_get(get_locks_rpc, NC_WD_UNKNOWN, NC_PARAMTYPE_CONST);
  msgtype = nc_send_rpc(session, rpc, 0, &msgid);

This doesn't work

michalvasko commented 1 week ago

Yes, getting the session ID from ietf-netconf-monitoring data is the only way. What exactly is the problem with this?

Also, are you really using libnetconf or is it libnetconf2?