agent_hooks.dox 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. /**
  7. @page agentHooks The Hooks API for the Control Agent
  8. @section agentHooksIntroduction Introduction
  9. The Kea Control Agent features "Hooks" API that allows the user-written
  10. code to be integrated with the Control Agent and handle some
  11. of the control commands. The hooks library can be either used to provide
  12. support for the new commands (not supported natively by the Control Agent)
  13. or "override" implementation of the existing handlers. The hooks library
  14. signals to the Control Agent that it has processed the given command by
  15. setting "next step status" value to SKIP.
  16. The hooks library can also be used to perform some additional tasks
  17. related to reception of the control command instead of handling it, e.g.
  18. logging or notifying some external service about reception of the
  19. command.
  20. @section agentHooksHookPoints Hooks in the Control Agent
  21. @subsection agentHooksControlCommandReceive control_command_receive
  22. - @b Arguments:
  23. - name: @b command, type: isc::data::ConstElementPtr, direction: <b>in/out</b>
  24. - name: @b response, type: isc::data::ConstElementPtr, direction: <b>in/out</b>
  25. - @b Description: this callout is executed when Control Agent receives a
  26. control command over the RESTful interface (HTTP).
  27. The "command" argument is a pointer to the parsed JSON structure
  28. including command name and command arguments. If the callout implements
  29. the specified command, it handles the command and creates appropriate
  30. response. The response should be returned in the "response" argument.
  31. In most cases, the callout which handles the command will set the next
  32. step action to SKIP, to prevent the server from trying to handle the
  33. command on its own and overriding the response created by the callouts.
  34. A notable exception is the 'list-commands' command for which the callouts
  35. should not set the next step action to SKIP. The server has a special
  36. code path for this command which combines the list of commands returned
  37. by the callouts with the list of commands supported by the server. If
  38. the callout sets the next step action to SKIP in this case, the server
  39. will only return the list of commands supported by the hook library.
  40. The callout can modify the command arguments to influence the command
  41. processing by the Command Manager. For example, it may freely modify
  42. the configuration received in 'config-set' before it is processed by
  43. the server. The SKIP action is not set in this case.
  44. - <b>Next step status</b>: if any callout sets the next step action to SKIP,
  45. the server will assume that the command has been handled by the callouts
  46. and will expect that the response is provided in the "response" argument.
  47. The Control Agent will not handle the command in this case but simply
  48. return the response returned by the callout to the caller.
  49. */