Where to locate call point?

Hi,

We are working with external DB.
We have YANG model with container x and sub container Y and Z. each of them has other attrinutes are well (A, B, C, D, E):
container X
{
attribute A;
container Y
{
attribute B;
attribute C;
container Z
{
attribute D;
attribute E;
}
}
}
can you advice where to locate the call point?
should I have one under X and another one under Y and Z? in this case, what will be the key for Y - the key for X as well as the key for Y? what will be the key of Z?
If you have an example for that it can be helpful.
thanks in advanced
Inbal

You can have multiple callpoints if you want but unless you have multiple clients registering for the callponts it makes most sense to have one at the root of the tree (inside container X).

As usual, the keypath array will be in reverse order:

/X/A
keypath->[0][0] is A
keypath->[1][0] is X

/X/Y/B
keypath->[0][0] is B
keypath->[1][0] is Y
keypath->[2][0] is X

and so on.

The simple_trans example demonstrates how this works. If trace is enabled (it is by default) you will see the key paths sent from ConfD to the application in the console.

You can read a detailed description of key paths in section 6.6 in the User Guide.

Hi,

What I don’t understand is if I will have only 1 callpoint at the root container (X), when get_elem will be issued. how can I know if keypath [0][0] is related to A or B?

thanks
Inbal

Look at get_elem() in the simple_trans example:

/* switch on xml elem tag */
switch (CONFD_GET_XMLTAG(&(keypath->v[0][0]))) {
case smp_name:
    CONFD_SET_STR(&v, s->name);
    break;
case smp_ip:
    CONFD_SET_IPV4(&v, s->ip);
    break;
case smp_port:
    CONFD_SET_UINT16(&v, s->port);
    break;
case smp_max_num:
    if (s->max_num >= 0) {
        CONFD_SET_INT8(&v, s->max_num);
    }
    else {
        CONFD_SET_DEFAULT(&v);
    }
    break;
default:
    confd_trans_seterr(tctx, "xml tag not handled");
    return CONFD_ERR;
}

You use CONFD_GET_XMLTAG() to extract the value and use switch (or if) to test against expected values. In the example smp_name, smp_ip etc comes from the h-file generated from the data model by the confd compiler.

In your case the values would be <prefix>_A or <prefix>_B.

Hi,

I am not sure you were following my example. Let me ask my question again.
If the follwoing is my yang model with call point in the root container X:

container X
{
attribute A;
container Y
{
attribute B;
attribute C;
container Z
{
attribute D;
attribute E;
}
}
}

If a get_elem will be called and I will implement the switch case as you suggested:
switch (CONFD_GET_XMLTAG(&(keypath->v[0][0]))) {

}
what will be the cases in my switch-case?
will it be:
{
case A: …
Case Y: …
}
or will be:
{
case A: …
case B: …

}

please elaborate.

thanks
Inbal

The case-statements can come in any order but you only have case-statements for leafs, not containers.