ConfD User Community

Maapi_request_action and tailf:confirm text


#1

Is there a way to programmatically provide the confirmation required by tailf:confirm text when using the maapi_request_action APIs?


#2

There are functions maapi_cli_prompt, maapi_cli_prompt2 and maapi_cli_prompt_oneof which are intended to be called from inside action callpopint when invoked from CLI. See ConfD user guide confd_lib_maapi. Example of maapi_cli_prompt_oneof can be found in examples.confd/cli/c_cli/actions.c (in ConfD premium).


#3

Consider a custom northbound interface invoking maapi_request_action APIs (no CLI in this use case), and a backend that processes the action requests via action callback. How does the northbound interface (written using maapi APIs) issue the confirmation?


Show status Statement in CLI
#4

You can for example do something like this:

  container myContainer {
    tailf:meta-data "myaction-confirm-text" {
      tailf:meta-value "Really want to do this?";
    }
    tailf:action myAction {
      tailf:exec "./myaction.sh" {
	...
      }
      input {
	...
      }
      output {
	...
      }
      tailf:confirm-text 'Really want to do this?' {
	tailf:confirm-default true;
      }
    }
  }

tailf:meta-data example:


#5

We are finding our action never occurs when we have tailf:confirm-text and issue the action via maapi_request_action(), apparently because it is waiting for the confirmation. However, I see no way of passing the confirmation y/n using the maapi_request_action APIs. Can the confirmation be passed programmatically somehow via maapi? Or only confirmed by typing y/n in the CLI?


#6

MAAPI doesn’t wait for confirmation.
See your developer log (set to trace level).

You can print out the resulting values array for debug purposes using something like this:

    char buf[BUFSIZ];
    confd_tag_value_t *values;
    int i, nvalues = 0;

    maapi_request_action(sock, params, nparams, &values, &nvalues, myprefix__ns, "/path/to/action");

    for (i = 0; i < nvalues; i++) {
      confd_pp_value(buf, sizeof(buf), CONFD_GET_TAG_VALUE(&values[i]));
      printf("param %2d: %9u:%-9u, %s\n", i, CONFD_GET_TAG_NS(&values[i]),
             CONFD_GET_TAG_TAG(&values[i]), buf);
...

#7

The maapi_request_action_str_th() API will fail with an “Aborted: by user” error when the default confirm-text in the Yang Model is set to false. The tailf:cli-batch-confirm-default can be used to override the default (setting to “true”) for non-interactive interfaces including MAAPI.


Can tailf:confirm-text be made conditional?