Implementation of notification of list

Hi,
I have a list as below. I would like to send a notification from a list.
I need help in implementing the same.
It will be helpful if you have any sample example.

grouping tx-array-notification-group {
description
  "Grouping for tx-array for notification";

list tx-array-carriers{
  key name;
  description "notification of state change for tx-array-carriers";

  leaf name{
    type leafref{
      path "/user-plane-configuration/tx-array-carriers/name";
    }
    description
      "name of tx-array-carriers is notified at state change";
  }
  leaf state{
    type leafref{
      path "/user-plane-configuration/tx-array-carriers/state";
    }
  description
    "state of tx-array-carriers is notified at state change";
  }
}
}

Implemented as below:
cfgTxCarrier is number nodes present in list.

  int j=0;
 for(i=0;i<cfgTxCarrier;i++)
{
  getdatetime(&eventTime);
 CONFD_SET_TAG_XMLBEGIN(&val[j],o_ran_uplane_conf_tx_array_carriers_state_change,o_ran_uplane_conf__ns);
  j++;
  CONFD_SET_TAG_STR(&val[j],o_ran_uplane_conf_name,"INACTIVE");
  j++;
  CONFD_SET_TAG_ENUM_VALUE(&val[j],o_ran_uplane_conf_state,0);
  j++;
  CONFD_SET_TAG_XMLEND(&val[j],o_ran_uplane_conf_tx_array_carriers_state_change, o_ran_uplane_conf__ns);
  j++;
  int status = confd_notification_send(notifctx, &eventTime, val, j);
  if (status != CONFD_OK) {
    errorLog("UPLANE: Tx Carrier  state-change Notification fail - status = %d %s", status, 
  confd_lasterr());
          }
      }

}

Getting error like:
1.devel-cdb subscriber as-confd closed unexpectedly (while delivering
subscription notification)

Regards,
Biswajit

There are probably more issues, but from what you provided above:

  1. You are sending one list entry, then the one you already sent + the next one, etc. Your for loop is broken.
  2. You don’t have any notification node information.

Use examples.confd/netconf_notifications/ as a reference. See notifier_builtin_replay_store.c in that example.

Hi cohult,
Thanks a lot for your reply.
I have modified as per example.
getdatetime(&eventTime);

 CONFD_SET_TAG_XMLBEGIN(val[j],o_ran_uplane_conf_tx_array_carriers_state_change,o_ran_uplane_conf__ns);
         
 j++;

CONFD_SET_TAG_XMLBEGIN(&val[j],o_ran_uplane_conf_tx_array_carrier,o_ran_uplane_conf__ns);

 j++;

  CONFD_SET_TAG_STR(&val[j],o_ran_uplane_conf_name,TxArrayCarrier[0].TxCarrierKey);
  j++;
  CONFD_SET_TAG_ENUM_VALUE(&val[j],o_ran_uplane_conf_state,0);
  j++;
   CONFD_SET_TAG_XMLEND(&val[j],o_ran_uplane_conf_tx_array_carrier, o_ran_uplane_conf__ns);
  j++;
  CONFD_SET_TAG_XMLEND(&val[j],o_ran_uplane_conf_tx_array_carriers_state_change, o_ran_uplane_conf__ns);
j++;
 int status = confd_notification_send(notifctx, &eventTime, val, j);
 If (status != CONFD_OK) {
           errorLog("UPLANE: Tx Carrier  state-change Notification fail - status = %d %s", status, confd_lasterr());
                          }

The main difference i notice between the example and my requirement is :
the notification leaf nodes are referencing to list.
will there any implementation change?
Currently on client i am not getting as expected output.On client, I am getting all the list present in yang file without value.
If you can figure out my mistake then it will be really helpful.

[biswajit@krikkit confd]$ ~buildtools/confd/7.3/x86_64/bin/netconf-console-tcp --host=10.21.10.234 -port=2023 -s all notification.xml

<?xml version="1.0" encoding="UTF-8"?>
 <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
 <ok/>
 </rpc-reply>
 <?xml version="1.0" encoding="UTF-8"?>
 <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
<eventTime>2020-11-16T08:10:40.946415+00:00</eventTime>
 <netconf-session-start xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
<username>admin</username>
<session-id>18</session-id>
<source-host>10.10.6.52</source-host>
</netconf-session-start>
</notification>
     <?xml version="1.0" encoding="UTF-8"?>

  <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
 <eventTime>2020-11-16T08:10:41.830156+00:00</eventTime>
    <netconf-config-change xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
   <changed-by>
  <username>admin</username>
  <session-id>18</session-id>
  <source-host>10.10.6.52</source-host>
</changed-by>
<datastore>running</datastore>
<edit>
  <target xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces">/if:interfaces/if:interface[if:name=' eth0']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-tx-endpoints[o-ran-uplane-conf:name='LLTE-DCH-0']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-tx-endpoints[o-ran-uplane-conf:name='LLTE-DCH-1']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-tx-endpoints[o-ran-uplane-conf:name='LLTE-DCH-2']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-tx-endpoints[o-ran-uplane-conf:name='LLTE-DCH-3']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:tx-array-carriers[o-ran-uplane-conf:name='tac-00']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:tx-array-carriers[o-ran-uplane-conf:name='tac-01']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:tx-array-carriers[o-ran-uplane-conf:name='tac-02']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:tx-array-carriers[o-ran-uplane-conf:name='tac-03']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-rx-endpoints[o-ran-uplane-conf:name='LLTE-RXDCH-1']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-rx-endpoints[o-ran-uplane-conf:name='LLTE-RXDCH-2']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-rx-endpoints[o-ran-uplane-conf:name='LLTE-RXDCH-3']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-rx-endpoints[o-ran-uplane-conf:name='LLTE-RXDCH-4']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-rx-endpoints[o-ran-uplane-conf:name='LLTE-RXPRACH-1']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-rx-endpoints[o-ran-uplane-conf:name='LLTE-RXPRACH-2']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-rx-endpoints[o-ran-uplane-conf:name='LLTE-RXPRACH-3']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:low-level-rx-endpoints[o-ran-uplane-conf:name='LLTE-RXPRACH-4']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:rx-array-carriers[o-ran-uplane-conf:name='rac-01']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:rx-array-carriers[o-ran-uplane-conf:name='rac-02']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:rx-array-carriers[o-ran-uplane-conf:name='rac-03']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:rx-array-carriers[o-ran-uplane-conf:name='rac-04']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:rx-array-carriers[o-ran-uplane-conf:name='rac-05']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:rx-array-carriers[o-ran-uplane-conf:name='rac-06']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:rx-array-carriers[o-ran-uplane-conf:name='rac-07']</target>
  <operation>create</operation>
</edit>
<edit>
  <target xmlns:o-ran-uplane-conf="urn:o-ran:uplane-conf:1.0">/o-ran-uplane-conf:user-plane-configuration/o-ran-uplane-conf:rx-array-carriers[o-ran-uplane-conf:name='rac-08']</target>
  <operation>create</operation>
</edit>
</netconf-config-change>
 </notification>
<?xml version="1.0" encoding="UTF-8"?>
 <notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
<eventTime>2020-11-16T08:10:42.07305+00:00</eventTime>
<netconf-session-end xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
 <username>admin</username>
<session-id>18</session-id>
<source-host>10.10.6.52</source-host>
<termination-reason>closed</termination-reason>
</netconf-session-end>
</notification>