MOP_MODIFIED leaf element in list

Hello Team,

We work with an extremely large schema close to 2500 lines. We are maintaining a list of mac-address.

container server {
list database {
key “ip”;
unique “ip”;
leaf ip {
type inet:ip-address;
}
leaf name {
type string;
}
leaf m----n;
}
}

I have subscribed for any changes to the list CREATE / DELETE and entry using
if ((status_ = cdb_subscribe(subsock_, 0, network__ns, &headpoint_,
“/server/database/”)) != CONFD_OK)
{
std::cerr << “Terminate: subscribe.” << status_ << std::endl;
return e_confd_failure;
}

But I am also interested in any change to leaf name. When I use the cdb_diff_iter, the iterator halts at MOP_MODIFIED. But I cannot access the xmltag name. The tag ends at database.

I am not very keen on using cdb_get_modifications since there are many leaves under the list and I am not interested in any of them. I only need to address the changes to particular leaf. Please help!

Best regards.

From ConfD user guide:

MOP_MODIFIED

    A descendant of the list entry given by kp has been modified.
MOP_VALUE_SET

    The value of the leaf given by kp has been set to newv.

This means that kp contains the keypath of the list. You need to read kp in MOP_VALUE_SET to get the kyepath of the leaf (which is under list)

1 Like

First, a “unique” statement on a list key is redundant. The list key will be checked for uniqueness anyway.

In addition to @mnovak 's comment, adding something like

  <server xmlns="http://tail-f.com/ns/example/dhcpd">
  <database>
    <ip>192.168.0.2</ip>
    <name>some name here</name>
    <m>test</m>
  </database>
  </server>

Seems to work fine:

$ confd_cmd -d -d -c "subwait_iter /server/database 1 100"
subwait_iter "/server/database" "1" "100"
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
TRACE CDB_SUBSCRIBE /server/database --> CONFD_OK
TRACE CDB_SUBSCRIBE_DONE  --> CONFD_OK
SUBSCRIBED TO /server/database
TRACE CDB_SUBSCRIPTION_EVENT --> 6
COMMIT
TRACE CDB_SUB_PROGRESS  --> CONFD_OK
TRACE CDB_SUB_ITERATE 6
TRACE CDB_SUB_PROGRESS  --> CONFD_OK
/server/database /server/database{192.168.0.2} created
TRACE CDB_SUB_PROGRESS  --> CONFD_OK
/server/database /server/database{192.168.0.2}/ip set ( -> 192.168.0.2)
TRACE CDB_SUB_PROGRESS  --> CONFD_OK
/server/database /server/database{192.168.0.2}/m set ( -> test)
TRACE CDB_SUB_PROGRESS  --> CONFD_OK
/server/database /server/database{192.168.0.2}/name set ( -> some name here)
TRACE CDB_SUB_PROGRESS  --> CONFD_OK
TRACE CDB_SYNC_SUB CDB_DONE_PRIORITY --> CONFD_OK
DONE