config-backend.dox 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. /**
  15. @page configBackend Kea configuration backends
  16. @section configBackendIntro Configuration backend introdution
  17. Kea is a flexible DHCP protocol engine. It offers a selection of lease database
  18. backends, extensibility via hooks API and definition of custom options.
  19. Depending on the environment, one lease database backend may be better than
  20. other. Similarly, depending on the deployment, it would also make sense to
  21. provide different ways to configure the server. The capability to have different
  22. ways to configure the servers is called Configuration Backend. As the way
  23. how configuration is received cannot be part of the configuration itself, it
  24. has to be chosen at the compilation time (when configuring sources). This page
  25. explains why we chose that path and how it is implemented. It can be used by
  26. people who want to develop and maintain their own configuration backends.
  27. @section configBackendMotivation Motivation for configuration backends
  28. BIND10 used to maintain an extensive framework that was responsible for
  29. components configuration. After BIND10 was cancelled, two projects were
  30. created: Kea and Bundy. Kea team decided to remove BIND10 framework, while Bundy
  31. team decided to keep it. Even though Kea team is focused on JSON backend, which
  32. reads the JSON configuration file from disk, we try to make it easy for others
  33. to use different backends.
  34. While ISC currently (May 2014) plans to maintain only one configuration backend
  35. (JSON: a JSON file read from disk), there may be other organizations (e.g.
  36. possibly Bundy project community) that will maintain other backends. It is quite
  37. possible that other configuration backends (e.g. using LDAP or XML) will be
  38. developed and maintained by other organizations.
  39. @section configBackendAdding How to add a new configuration backend?
  40. @todo: Will be covered in ticket #3400.
  41. @section configBackendJSONDesign Design for JSON configuration backend
  42. -# A new parameter called --with-kea-config will be implemented in
  43. configure script. It will allow selecting at compilation time how the
  44. servers will be configured. For the next 2-3 months (until around June 2014),
  45. we'll have 2 values: JSON (read from file) and BIND10 (use bind10 framework).
  46. Once we have file based configuration implemented and we're ready to switch
  47. (i.e. enough confidence, Forge tests updated for new configuration
  48. mechanism), BIND10 backend will be removed from Kea repo. Other projects
  49. (e.g. Bundy) who want to maintain it, are advisaged to just revert a single
  50. commit that will bring back the BIND10 framework to their repos.
  51. This switchable backend concept is really simple. There are just different
  52. implementations of ControlledXSrv class, so it's a matter with compiling/linking
  53. one file or another. Hence it is easy for us to remove the old backend (and for
  54. Bundy folks to keep it if they desire so). It is also easy for other
  55. organizations to add and maintain their own backends (e.g. LDAP based).
  56. For detailed description of DHCPv6 backend, see @ref dhcpv6ConfigBackend.
  57. -# Retain config and command callbacks. Each backend must use the common code
  58. for configuration and command processing callbacks. They all assume that
  59. JSON formatted parameters are sent and they are expected to return well
  60. formatted JSON responses. Exact format of configuration and commands is
  61. module specific.
  62. -# After Kea 0.9 is released, we will design some form of secure socket that
  63. we'll be able to send commands over. Whatever the design we end up with, it
  64. will allow to send configs and commands in JSON format and get responses.
  65. Once that is done, we'll have the same capability as we did in BIND10
  66. framework: to send additional parameters. One obvious use case will be
  67. to send new config file name as parameter for "reload".
  68. -# We need to add command handler for reading config from a file. Its main
  69. responsibility is to load config from file and process it. The JSON backend
  70. must call that handler when starting up the server.
  71. -# Extend existing JSON parser. We need to extend current JSON parser in
  72. @ref isc::data::Element::fromJSON() to allow optional preprocessing.
  73. For now that capability will simply remove hash comments, but it is expected
  74. to grow over time (in-line comments and file inclusions are the obvious
  75. envisaged additions).
  76. -# Implement common base class for Kea4, Kea6, D2 server. Some operations will be
  77. common for all 3 components: logger initialization, handling, and some time
  78. later control socket. This calls for a small base class that Dhcpv4Srv,
  79. Dhcpv6Srv and D2Controller can use. We will start that base class (@ref
  80. isc::dhcp::Daemon) as very small one. It is expected to grow over time as we
  81. do more code unification.
  82. -# We need to implement a way to initialized stand-alone logging (i.e. each
  83. Kea component will initialize it on its own).
  84. -# Config file format.
  85. We will use the current format of b10-config.db. This is slight change
  86. to what we did in Kea during BIND10 days, because we were receiving a subset
  87. of that configuration. Let me give specific example. That's how b10-config.db
  88. looks like today:
  89. @code
  90. {
  91. "Init": { ... }
  92. "Dhcp4": {
  93. "subnet4" { subnet definitions here },
  94. "option-data" { option data here },
  95. "interfaces": [ "eth0" ],
  96. ...
  97. },
  98. "Dhcp6": {
  99. "subnet6" { subnet definitions here },
  100. "option-data" { option data here },
  101. "interfaces": [ "eth0" ],
  102. ...
  103. },
  104. "Logging": {
  105. "Loggers": [{"name": *, "severity": "DEBUG" }]
  106. }
  107. }
  108. @endcode
  109. Kea components used to receive only relevant parts of it (e.g. Kea4
  110. received config that contained content of the Dhcp4 element). We'll be
  111. receiving the whole config now. The modification in the code is really
  112. minor: just iterate over top level elements and pick the appropriate
  113. tree (or get element by name). Also, that approach makes the logging
  114. initialization code very easy to share among Kea4, Kea6 and D2.
  115. -# We keep .spec files. We'll keep and maintain them even though we won't do
  116. anything with them. Those files were used by bindctl to do syntax checking.
  117. We will be lacking that capability for a while. Implementing C++ code for
  118. .spec validation of received config is out of scope for 0.9 (and probably
  119. for 1.0 as this is pretty big task).
  120. -# Shell script to start/stop Kea4,Kea6 and D2. There will be a script that will
  121. start, stop and reconfigure the daemons. It will be rather simple. Its only
  122. job will be to pass config file to each daemon and remember its PID file, so
  123. sending signals would be possible (for config reload or shutdown). Optionally,
  124. it could also print out a status based on PID, but that may be tricky to
  125. implement in a portable way. The minimum set of commands would be:
  126. -# Start the processes
  127. - eventually based on config, initially start them all
  128. - it could launch a nanny script which restarts them on a crash (past 0.9)
  129. -# Prompt the processes to reload configuration
  130. - for now it will be a matter of sending singal to the right process
  131. - this could also decide if D2 should still be running or not,
  132. and react accordingly (past 0.9)
  133. -# Stop the processes in an orderly fashion
  134. -# Perhaps return status of each process
  135. */