Hello,
kindly asking for help from more experienced ConfD users:
I’m using transaction hook in order to suplement user’s transaction to RUNNING with additional data.
I’m using maapi_trans_in_trans in order to supplement configuration data and it works fine.
However when I try to add some optional operational leafs in the list container that user is creating I get errors from confd whatever method I try.
The hook is a transaction-hook of type ‘subtree’ directly on the container of interest.
When I get a ‘.create’ callback on the item in the list container I’m trying to set the operational leaf directly beneath the node being created. The operational leaf is a regular config:false leaf backed up by CDB without a default value.
First method I tried was to open CDB session to operational and it failed on cdb_set_elem.
Second and last method I tried was to execute this code:
int th = maapi_start_trans2(socket, CONFD_OPERATIONAL, CONFD_READ_WRITE, session);
int ret = maapi_cd(socket, th, “/path/to/the/list{new_entry_key}”); //cd is ok
ret = maapi_set_elem2(socket, th, “123”, “op-leaf”); //fails
int err = dal_db_get_error_code(ret); //err == 1 (CONFD_ERR_NOEXISTS)
ret = maapi_apply_trans(socket, th, session);
ret = maapi_finish_trans(socket, th);
The error I get from the maapi_set_elem2 is CONFD_ERR_NOEXISTS(1).
If I change the key (new_entry_key) to the key for an entry that has been there before the user’s transaction then set_elem2 succeeds and I see it changed after user’s transaction is commited (and even before, that is right after this inner operational transaction is commited).
So the question arises: is it possible to set the operational leafs under nodes just being created by user (and do it in transaction hook as opposed to in subscription callback after user’s transaction is commited)? If so how to accomplish that?