Subscribe CONFD_STREAM_NOTIFICATION with filter

Hi,

I run the example confd-6.3/examples.confd/misc/notifications/confd_notifications to test the subscription on the notification CONFD_STREAM_NOTIFICATION_EVENT.
The subscription on the stream works well, but the filter does not work.
The test result is as below.

  1. Starting confd_notification to receive the notification on stream ‘NETCONF’
    bash>confd_notifications -n ‘NETCONF’
  2. Create a data node
    confd-cli(config)# test-container test-list test
    confd-cli(config-test-list-test)# commit
  3. Then the notification is received by confd_notifications and printed as below.
    bash> confd_notifications -n ‘NETCONF’
    Waiting for event notifications…
    Notif stream: event at 2017-03-21T11:16:55.471121+01:00
    netconf-config-change
    changed-by
    username test
    session-id 0
    source-host 192.168.171.12
    datastore enum<0>
    edit
    target /notitest:test-container/test-list[test-list-name=“test”]
    operation enum<2>

Then I try subscribe stream NETCONF with filter. What I want is to only receive the notification when the /notitest:test-container/test-list[test-list-name=“test”] is changed.

  1. run confd_notifications with -x option
    bash> confd_notifications -n ‘NETCONF’ -x ‘/notitest:test-container/test-list[test-list-name=“test”]’

  2. delete the '/notitest:test-container/test-list[test-list-name=“test”]
    confd_cli(config)# no test-container test-list test
    confd_cli(config)# commit

But there is no any notification got printed by confd_notifications.

Could you help on this? How can I filter the notification for the specific leaf?
Thanks.
The model that I used is as below.

module notification-test {
yang-version “1”;
namespace “http://notification-test”;
prefix “notitest”;

import ietf-yang-types {
prefix “yang”;
}

container test-container {
description
“root model for set”;
list test-list {
key “test-list-name”;
leaf test-list-name {
type string;
description
“Specify a named list to configure”;
}
leaf test-leaf {
type string;
description
“Configure a leaf”;
}
}
}

}

Hi,

Note that the NETCONF notification stream is only reporting changes done over the NETCONF interface, here the ConfD NETCONF server interface. I.e. the changes you do over CLI will not trigger notifications to the NETCONF stream.

Then why the change I do over CLI does trigger the notification to the NETCONF stream when I try “confd_notifications -n ‘NETCONF’”? Reposting as below, you can see the notification is received on stream “NETCONF”.
The problem is when I use confd_notification -x, the filter does not work.

  1. Starting confd_notification to receive the notification on stream ‘NETCONF’
    bash>confd_notifications -n ‘NETCONF’
  2. Create a data node
    confd-cli(config)# test-container test-list test
    confd-cli(config-test-list-test)# commit
  3. Then the notification is received by confd_notifications and printed as below.
    bash> confd_notifications -n ‘NETCONF’
    Waiting for event notifications…
    Notif stream: event at 2017-03-21T11:16:55.471121+01:00
    netconf-config-change
    changed-by
    username test
    session-id 0
    source-host 192.168.171.12
    datastore enum<0>
    edit
    target /notitest:test-container/test-list[test-list-name=“test”]
    operation enum<2>

You are correct, all config changes (i.e. transaction commits) will be reflected in netconf-config-change notifications, regardless of which NB interface was used to request them. I believe your problem is with the XPath expression, which should have its root at the notification itself, i.e. it would be /ncn:netconf-config-change/… - you are actually asking to receive only “notitest:test-container” notifications, and there aren’t any of those.

The library API for CONFD_STREAM_NOTIFICATION_EVENT is pretty much exactly modeled after the NETCONF spec in RFC 5277 - you can look at the details for XPath filters there as well as see some examples. You can also experiment with the actual NETCONF notifications via netconf-console with --create-subscription and -x/–xpath (see the ‘netconf-consoele -h’ output). Once you have something working for -x there, it should work to just paste it into your code…

Thanks a lot.
The xpath now works.