Set priority to field

Hi,

I have list named “neighbors” and it has key named “neighbor-address”.
In addition this list have another “must” attribute named “peer-group” which is leafref.

I would like that after create of new item in the list the first set_elem will be to the attribute “peer-group” which is must.

How can I do it?

Thanks,

Evyatar

This is not possible.
you should not make your implementation dependent on a certain order.

But, in your case, you can always read the changes in a transaction using MAAPI and be able to process these according to your logic.

Could you explain a bit more the need for processing certain leafs before others?

I guess you are using an external running datastore right?

Hi,

Yes, I am using external DB.
Can I use MAAPI in a middle of commit transaction to get any information I need from the current transaction?

Thanks,

Evyatar

Hi,

I would like to clear the question.
We are working with external running DB. It is existing DB with other user interfaces (e.g. SNMP, cli) that already implemented.
For each set/create/delete operation we reply with “CONFD_ACCUMULATE”.
when the transaction is committed, we go over the accumulated list and conficure it in the DB.
since the DB exist before implementing the NetConf and yang, sometimes we dont have all the needed DB data (keys) from the yang.
Is there a way to get a leaf’s value from the candidate DB which is in confd?
how can we use the MAAPI in the case I described?

thanks
Inbal

You can attach to the current transaction using maapi_attach(). See confd_lib_maapi(3) man page.

Hi,

thank you for your answer.
I see in the user guide that in order to read value we should:

  1. maapi_attach
  2. get the parameter value (e.g. maapi_get_int64_elem(maapi_socket, tctx->thandle, &b_val, “/mtest/b_number”)
  3. maapi_detach
    Since we use CONFD_DAEMON_FLAG_STRINGSONLY flag, I wonder how we should read value of a leaf which was defined as integer for example.
    should we do maapi_get_int64_elem or other API as maapi_get_str_elem or maapi_get_buf_elem.

Regards
Inbal

Hi,

As the UG says regarding CONFD_DAEMON_FLAG_STRINGSONLY, the type you will receive will always be a C_BUF. Choose our MAAPI get call based on that.

CONFD_DAEMON_FLAG_STRINGSONLY applies only to the callbacks for a data provider daemon, i.e. set_elem() etc - there is no corresponding MAAPI function that returns values as strings regardless of the actual type. But if you have loaded schema information, you can use confd_val2str() to produce a string for a confd_value_t that you have read via MAAPI.