I’d like to use the example from a different question about module dependency. The modules and the edit-config RPC are as follows:
module test-citizens {
namespace "http://www.example.com/yang/test-citizens";
prefix "tc";
organization "";
contact "";
container citizens {
list citizen {
key "name";
leaf name {
type string;
}
}
}
}
module test-dependency {
namespace "http://www.example.com/yang/test-dependency";
prefix "td";
import test-citizens {
prefix "tc";
}
organization "";
contact "";
container cities {
list city {
key "name";
leaf name {
type string;
}
leaf mayor {
type leafref {
path "/tc:citizens/tc:citizen/tc:name";
}
}
}
}
}
module test-annotation {
namespace "http://www.example.com/yang/test-annotation";
prefix "ta";
import test-citizens {
prefix "tc";
}
import test-dependency {
prefix "td";
}
import tailf-common {
prefix "tailf";
}
organization "";
contact "";
tailf:annotate "/tc:citizens/tc:citizen" {
tailf:callpoint citizen;
}
tailf:annotate "/td:cities/td:city" {
tailf:callpoint city;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<rpc message-id="104"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns:tc="http://www.example.com/yang/test-citizens"
xmlns:td="http://www.example.com/yang/test-dependency">
<edit-config>
<target>
<running />
</target>
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
<td:cities>
<td:city xc:operation="create">
<td:name>Seattle</td:name>
<td:mayor>John</td:mayor>
</td:city>
</td:cities>
<tc:citizens>
<tc:citizen xc:operation="create">
<tc:name>John</tc:name>
</tc:citizen>
</tc:citizens>
</config>
</edit-config>
</rpc>
When I send in the edit-config RPC, and when I implement both the get_elem and get_object callbacks for the “citizen” callpoint, the trace I get is as follows:
test_init(0) for root from 155.53.154.223
--> CONFD_OK
TRACE CALL data get_elem(thandle=7,/cities/city{Seattle}/name)
city_get_elem:176: kp_str /cities/city{Seattle}/name
(NOEXISTS) --> CONFD_OK
TRACE CALL data get_elem(thandle=7,/cities/city{Seattle}/mayor)
city_get_elem:176: kp_str /cities/city{Seattle}/mayor
(NOEXISTS) --> CONFD_OK
TRACE CALL data get_elem(thandle=7,/citizens/citizen{John}/name)
citizen_get_elem:61: kp_str /citizens/citizen{John}/name
(NOEXISTS) --> CONFD_OK
TRACE CALL data create(thandle=7,/citizens/citizen{John})
citizen_create:132: new citizen John
--> CONFD_OK
(0) (0) TRACE CALL data create(thandle=7,/cities/city{Seattle})
city_create:212: kp_str /cities/city{Seattle}
city_create:221: new city Seattle
--> CONFD_OK
(0) (0) TRACE CALL data set_elem(thandle=7, /cities/city{Seattle}/mayor, John) -->
CONFD_ACCUMULATE
(0) (0) TRACE CALL trans prepare(thandle=7)op: SET_ELEM, callpoint city
--> CONFD_OK
TRACE CALL trans commit(thandle=7) --> CONFD_OK
TRACE CALL trans finish(thandle=7) --> CONFD_OK
However, if I implement only the get_object callback (by setting the get_elem callback to NULL), then my trace is as follows:
test_init(0) for root from 155.53.154.223
--> CONFD_OK
TRACE CALL data get_object(thandle=9,/cities/city{Seattle})
city_get_object:241: kp_str /cities/city{Seattle}
(NOEXISTS) --> CONFD_OK
TRACE CALL data get_elem(thandle=9,/citizens/citizen{John}/name)
citizen_get_elem:61: kp_str /citizens/citizen{John}/name
(NOEXISTS) --> CONFD_OK
TRACE CALL data create(thandle=9,/citizens/citizen{John})
citizen_create:132: new citizen John
--> CONFD_OK
(0) (0) TRACE CALL data create(thandle=9,/cities/city{Seattle})
city_create:212: kp_str /cities/city{Seattle}
city_create:221: new city Seattle
--> CONFD_OK
(0) (0) TRACE CALL data set_elem(thandle=9, /cities/city{Seattle}/mayor, John) -->
CONFD_ACCUMULATE
(0) (0) TRACE CALL trans prepare(thandle=9)op: SET_ELEM, callpoint city
--> CONFD_OK
TRACE CALL trans commit(thandle=9) --> CONFD_OK
TRACE CALL trans finish(thandle=9) --> CONFD_OK
I don’t understand why there are two different traces. In the first trace, ConfD calls get_elem twice, rather than calling get_object once. (In the first trace, both get_elem and get_object callbacks are implemented.) Why does ConfD decide that calling the get_elem callback twice is more efficient than calling get_object once? (In the second trace, I set the get_elem callback to NULL, and see that ConfD uses get_object instead.)
Below are the get_elem calls from the first trace above:
TRACE CALL data get_elem(thandle=7,/cities/city{Seattle}/name)
city_get_elem:176: kp_str /cities/city{Seattle}/name
(NOEXISTS) --> CONFD_OK
TRACE CALL data get_elem(thandle=7,/cities/city{Seattle}/mayor)
city_get_elem:176: kp_str /cities/city{Seattle}/mayor
(NOEXISTS) --> CONFD_OK
Below is the get_object call from the second trace above:
TRACE CALL data get_object(thandle=9,/cities/city{Seattle})
city_get_object:241: kp_str /cities/city{Seattle}
(NOEXISTS) --> CONFD_OK