we are using Maapi API’s (maapi_create,maapi_setelem) to load default configuration into CDB.
But we are facing one issue. some of the list elements of our yang model are dynamically
created so we should not have any list element after loading Default configuration.
whenever we try to load without creating this list element into CDB we are getting this error: CONFD_ERR_BAD_KEYREF
if we set these elements then objects are successfully loaded into CDB.
IMO it means that since we have not set some of the list elements we are receiving this error.
Is there any way we can bypass this so that our element creation will be successful ??
container wavelengths {
list wl {
key name;
leaf name {
type string;
}
container connections { **---> Dynamic Entries which should not be loaded into CDB**
list connection {
key id;
leaf id {
type uint32;
}
}
}
}
yes. you are right. maapi_set_elem() is not needed for updating key element but here I am using maapi_set_elem() to set values for leafs inside a list.
Previously I was using maapi_set_elem() for both key element & non-key elements for a list. I think my yang example is not reflecting that part.
I am not getting any error if i use maapi_set_elem() on key element of list.
My Main Query is that, is it possible to create a new entry (/wavelengths/wl{"first"}) in CDB without calling maapi_create() on /wavelengths/wl{"first"}/connections/connection{31} ?
I was getting CONFD_ERR_BAD_KEYREF error if i don’t create connections/connection{31} using maapi_create. so i want to know whether is it possible or not.
I am not using confd_load/confd_cmd to populate these entries in CDB. I am doing it through c program. does it make any difference ?
it is still not completely clear when specifically, for which confd-lib procedure call/operation you get that error…
your sample yang model allows creating instance of “wavelengths/wl{first}” list.
you don’t need to do any internal “wavelengths/wl{first}/connections/connection{31}” entry…
In addition to @josephm 's comment, confd_cmd / confd_load are c programs too that you can use as a reference. That’s why I use them to demo how to do things. See:
$CONFD_DIR/src/confd/tools/confd_cmd.c
$CONFD_DIR/src/confd/tools/confd_load.c
maapi_start_trans()
maapi_create() - wl list entry
maapi_set_elem() - for key leaf -- redundant
maapi_set_elem() - for non key leaf
maapi_apply_trans() -- getting error `CONFD_ERR_BAD_KEYREF`
but if follow the below call flow then it is working –
maapi_start_trans()
maapi_create() - wl list entry
maapi_set_elem() - for key leaf -- redundant
maapi_set_elem() - for non key leaf
maapi_create() - connections list entry
maapi_set_elem() - for key leaf -- redundant
maapi_apply_trans() -- No Error.
I will try by removing the maapi_set_elem() on key leaf element to see whether is it working or not.
try verifying return code of each of the steps - maapi_create()/maapi_set_elem()/… one of them should give you CONFD_ERR giving closer hint on some inconsistent operation - e.g. keypath not prepared correctly etc.
if not, you may have some problem in config you are trying to “commit” due to e.g. YANG must statements failing, validation callpoints rejecting transaction, YANG “mandatory true;” statements being not fulfilled etc.