How does ConfD identify an action command and status command inside an action command
can you clarify what you mean by action/status command inside an action command and/or give small example (a bit more context)?
An action command is a high-level operation that triggers specific actions or modifications, while a status command inside an action command is a sub-operation used to retrieve relevant information or data during the execution of the parent action command.
Example
yang file
module my-module {
namespace "http://example.com/my-module";
prefix my;
rpc reset-device {
input {
leaf device-id {
type string;
description "Identifier of the device to reset.";
}
}
output {
leaf result {
type string;
description "Result of the device reset operation.";
}
}
}
}
C file
#include <confd_lib.h>
/* Callback function for handling the reset-device action */
int reset_device_action(struct confd_trans_ctx *tctx, confd_hkeypath_t *keypath,
confd_value_t *newval, confd_tag_value_t *oldvals,
int nvals, struct confd_user_info *uinfo, long usrhandle) {
// Extract input parameters from newval
// Perform the reset operation on the device
// Prepare the output result
// Return the output result
}
/* Register the reset-device action command */
void register_action_commands() {
int ret;
ret = confd_action_cbs(&actionpoint, 1);
if (ret != CONFD_OK) {
// Error handling
}
}
Once implemented, you can use NETCONF or other management protocols to invoke the “reset-device” action command, providing the device ID as an input parameter. The ConfD application will handle the action, perform the desired reset operation, and return the result to the client.
sure that’s clear, but i am confused by what do you mean/ask about by your original question (seeing that you know the info you pasted above)…
how do ConfD know a command is status or action command ? is there a flag or something which is used to differentiate between these command
Assuming that by “status command” you mean some operation doing extra reads from ConfD/CDB/data providers etc…
The implementation of the action (that you showed in your C code excerpt above)
can open new “transaction in transaction” to do extra MAAPI calls and read more info from ConfD if it needs to.
Try checking for examples of calls to maapi_attach(...)
in examples.confd/
.
They are shown for various transformation callbacks, CLI commands (maapi_attach2
), or data provider callbacks, but principle is same for your actionpoint
for RPC I believe.
You can then use this MAAPI socket to read/get data from ConfD (if this is what you ment) - using various maapi_get_... (elem, object, int, ... - see
man confd_lib_maapi)
calls in C…