# Action command and status command inside an action command

**URL:** <https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441>\
**Category:** General\
**Created:** [May 12, 2023, 4:54am UTC](https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441 "2023-05-12T04:54:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![arodrigues](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arodrigues](https://dmap-community.ductus.global/u/arodrigues)\
**Post date:** [May 12, 2023, 4:54am UTC](https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441/1 "2023-05-12T04:54:41Z")

</div>

How does ConfD identify an action command and status command inside an action command

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [May 12, 2023, 7:17am UTC](https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441/2 "2023-05-12T07:17:34Z")

</div>

can you clarify what you mean by action/status command inside an action command and/or give small example (a bit more context)?

---

<div class="post-metadata">

**Author:** ![arodrigues](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arodrigues](https://dmap-community.ductus.global/u/arodrigues)\
**Post date:** [May 12, 2023, 10:11am UTC](https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441/3 "2023-05-12T10:11:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![arodrigues](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arodrigues](https://dmap-community.ductus.global/u/arodrigues)\
**Post date:** [May 12, 2023, 10:15am UTC](https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441/4 "2023-05-12T10:15:18Z")

</div>

Example

yang file

```plaintext
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

```c
#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.

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [May 12, 2023, 10:18am UTC](https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441/5 "2023-05-12T10:18:43Z")

</div>

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)…

---

<div class="post-metadata">

**Author:** ![arodrigues](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arodrigues](https://dmap-community.ductus.global/u/arodrigues)\
**Post date:** [May 12, 2023, 10:52am UTC](https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441/6 "2023-05-12T10:52:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [May 12, 2023, 11:19am UTC](https://dmap-community.ductus.global/t/action-command-and-status-command-inside-an-action-command/4441/7 "2023-05-12T11:19:13Z")

</div>

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…
