Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi,
i am new to using libnetconf2 , and i am trying to understand how to create a subscription for specific xpath and register for a callback so i can process any on change, is there any example or documentation part which gives me a good idea on sequence of operations i need to do with libnetconf2 apis

You must be logged in to vote

The failed assert is a bug that should now be fixed. The stream should simply be skipped, there is not much use of it, but it is not just an arbitrary name. In any case, establish-sub is not the command you want to use but rather establish-push, which starts the special YANG Push subscription.

Replies: 2 comments · 5 replies

Comment options

Yes, but you are in the wrong project, all of this is provided by sysrepo, which includes some examples. libnetconf2 is a library strictly for NETCONF communication (establishing NETCONF sessions and processing NETCONF messages).

You must be logged in to vote
0 replies
Comment options

Hi Michal,

we have a requirement for detecting changes on data in netconf server,

  1. we have netopeer2-server and sysrepo running on one machine ( where all config data is written )
  2. The application which wants to subscribe for data changes resides in a different machine,
  3. Application needs to retrieve data from netopeer2-server using libnetconf2 client,
  4. is there a way with which libnetconf2 client can subscribe on server for specific xpath to watch and get the changes
You must be logged in to vote
5 replies
@michalvasko
Comment options

Ah, in that case sysrepo is not relevant because it can communicate only locally on a single machine. What you need to use are YANG/NETCONF mechanisms, YANG Push based on the description, specifically. Look at the RFC and the YANG module, it is fully supported by netopeer2.

@srikanths1
Comment options

Hi Michal,
thank you, this is what we are trying to do so,
but we wanted to understand the flow for establish-sub (netopeer2-cli , only to understand logical flow ), we have loaded an example module in server, and trying to establish a subscription for a xpath in this node, but i think we are fundamentally doing something wrong,

can you please help?
OnCli, we do following

connect
get --filter-xpath=/example-multicontainer:*
DATA

m-system Lnux eth0 192.168.1.1 255.255.255.0

establish-sub --stream new1 --filter-xpath /example-multicontainer:system-info
nc ERROR: SSH channel poll error (Socket error: disconnected).
cli_send_recv: Failed to receive a reply.

On server, we see abort,
[INF]: SR: EV ORIGIN: "/ietf-subscribed-notifications:establish-subscription" "rpc" ID 1 priority 0 for 1 subscribers published.
[INF]: SR: EV LISTEN: "/ietf-subscribed-notifications:establish-subscription" "rpc" ID 1 priority 0 processing (remaining 1 subscribers).
[ERR]: SR: Failed to collect modules to subscribe to (Item not found).
netopeer2-server: /root/new/sysrepo-2.10.1/src/utils/sn_common.c:851: srsn_sub_free: Assertion `i < snstate.count' failed.
Aborted

yang model:

module example-multicontainer {
namespace "http://example.com/ns/example-multicontainer";
prefix "ex";

container system-info {
description "Information about the system";

leaf hostname {
  type string;
  description "Hostname of the system";
}

leaf os {
  type string;
  description "Operating system of the system";
}

}

container network-config {
description "Network configuration of the system";

leaf interface-name {
  type string;
  description "Name of the network interface";
}

leaf ip-address {
  type string;
  description "IP address assigned to the interface";
}

leaf subnet-mask {
  type string;
  description "Subnet mask of the network interface";
}

}
// RPC operation to get interface information
rpc get-system-info {
description "Retrieve information about systeminfo";
output {
container system-info {
leaf hostname {
type string;
description "hostname";
}
leaf os {
type string;
description "Description of the os";
}
}
}
}
}

@michalvasko
Comment options

The failed assert is a bug that should now be fixed. The stream should simply be skipped, there is not much use of it, but it is not just an arbitrary name. In any case, establish-sub is not the command you want to use but rather establish-push, which starts the special YANG Push subscription.

Answer selected by srikanths1
@srikanths1
Comment options

Thank you Michal, one followup question is, when we have subscribed with establish-push notifications on candidate datastore from application, and suppose application fails the validation, is there way to indicate to server to reject the change via netconf2 apis?

@michalvasko
Comment options

If validation fails on copy-config from candidate to running, the new config will automatically be rejected locally by sysrepo. You cannot affect this remotely via NETCONF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.