config-backend.dox 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 Introduction
  17. Kea is a flexible DHCP protocol engine. It offers a selection of lease database
  18. backends, extensibility via the hooks API and the definition of custom options.
  19. Depending on the environment, one lease database backend may be better than
  20. other. Similarly, because the best way of configuring the server can depend on
  21. the environment, Kea provides different ways of obtaining configuration
  22. information, through the Configuration Backend. Since the means by which
  23. configuration information is received cannot be part of the configuration itself, it
  24. has to be chosen at the compilation time (when configuring the sources).
  25. This page explains the background to the Configuration Backend and how
  26. it is implemented. It is aimed at people who want to develop and
  27. maintain their own backends.
  28. @section configBackendMotivation Motivation for Different Backends
  29. BIND10 (the project under which the first stages of Keas were developed)
  30. used to maintain an extensive framework that was responsible for the
  31. configuration of components. After BIND10 was cancelled, two projects
  32. were created: <a href="http://kea.isc.org">Kea</a> (focused on DHCP)
  33. and <a href="http://www.bundy-dns.de">Bundy</a> (aimed at DNS). The
  34. Kea team decided to remove the BIND10 framework, while the Bundy team
  35. decided to keep it. However, even though the Kea team is focused on a
  36. backend that reads a JSON configuration file from disk, it decided to
  37. make it easy for others to use different backends.
  38. While ISC currently (May 2014) plans to maintain only one configuration backend
  39. (a JSON file read from disk), there may be other organizations (e.g.
  40. the Bundy project community) that will maintain other backends. It is quite
  41. possible that additional backends (e.g. using LDAP or XML) will be
  42. developed and maintained by other organizations.
  43. @section configBackendAdding How to Add a New Configuration Backend
  44. @todo Will be covered in ticket #3400.
  45. @section configBackendJSONDesign The JSON Configuration Backend
  46. The following are some considerations that shaped the design of the configuration
  47. backend framework.
  48. -# A new parameter called --with-kea-config will be implemented in the
  49. configure script. It will allow the selection at compilation time of how the
  50. servers will be configured. For the next 2-3 months (until around June 2014),
  51. there will be two values: JSON (read from file) and BIND10 (use the BIND10 framework).
  52. Once the file based configuration is implemented and the Kea team is ready to switch
  53. (i.e. enough confidence, Forge tests updated for new configuration
  54. mechanism), the BIND10 backend will be removed from the Kea repository. Other projects
  55. (e.g. Bundy) who want to maintain it, are advised to just revert the single
  56. commit that will bring the BIND10 framework back to their repositories.<br/><br/>
  57. This switchable backend concept is quite simple. There are just different
  58. implementations of ControlledXSrv class, so it is a matter of compiling/linking
  59. one file or another. Hence it is easy to remove the old backend (and for
  60. Bundy to keep it if they desire so). It is also easy for other
  61. organizations to add and maintain their own backends (e.g. LDAP).<br/><br/>
  62. -# Each backend must use the common code
  63. for configuration and command processing callbacks. They all assume that
  64. JSON formatted parameters are sent and they are expected to return well
  65. formatted JSON responses. The exact format of configuration and commands is
  66. module specific.<br/><br/>
  67. -# After Kea 0.9 is released, a form of secure socket will be implemented through
  68. which commands can be sent. Whatever the design, it
  69. will allow the sending of configurations and commands in JSON format and
  70. the receiving of responses.<br/><br/>
  71. Once that is done, Kea will have the same capability the BIND10
  72. framework to send additional parameters. One obvious use case will be
  73. to send a new configuration file name as the parameter for "reload".<br/><br/>
  74. -# A command handler needs to be added for reading the configuration from a file. Its main
  75. responsibility is to load the configuration and process it. The JSON backend
  76. must call that handler when starting up the server.<br/><br/>
  77. -# Extend the existing JSON parser. The current JSON parser in
  78. @ref isc::data::Element::fromJSON() needs to be extended to allow optional preprocessing.
  79. For now that capability will simply remove whole-line comments staring with the hash
  80. character, but it is expected
  81. to grow over time (in-line comments and file inclusions are the obvious
  82. envisaged additions).<br/><br/>
  83. -# Implement a common base class for the Kea4, Kea6, and D2 servers. Some operations will be
  84. common for all three components: logger initialization, handling and, at some future point,
  85. control socket. This calls for a small base class that @ref isc::dhcp::Dhcpv4Srv "Dhcpv4Srv",
  86. @ref isc::dhcp::Dhcpv6Srv "Dhcpv6Srv" and the @ref isc::d2::D2Controller "D2Controller" classes can use.
  87. It is expected that the base class
  88. (@ref isc::dhcp::Daemon) will be a small one but will grow over time as the code is unified.<br/><br/>
  89. -# A way is needed to initialize stand-alone logging (i.e. each
  90. Kea component will initialize it on its own).<br/><br/>
  91. -# The current format of the BIND10 configuration file, b10-config.db will be
  92. retained as the configuration file format. This is slight change
  93. from the BIND10 days, as then a subset of the configuration was received by
  94. the daemon processes.<br/><br/>
  95. To take a specific example, the following is how b10-config.db
  96. looks today:<br/><br/>
  97. @code
  98. {
  99. "Init": { ... }
  100. "Dhcp4": {
  101. "subnet4" { subnet definitions here },
  102. "option-data" { option data here },
  103. "interfaces": [ "eth0" ],
  104. ...
  105. },
  106. "Dhcp6": {
  107. "subnet6" { subnet definitions here },
  108. "option-data" { option data here },
  109. "interfaces": [ "eth0" ],
  110. ...
  111. },
  112. "Logging": {
  113. "Loggers": [{"name": *, "severity": "DEBUG" }]
  114. }
  115. }
  116. @endcode
  117. <br/>
  118. The Kea components used to receive only relevant parts of it (e.g. Kea4
  119. received config that contained content of the Dhcp4 element). Now they
  120. will receive all of it. The modification in the code to handle this
  121. is really minor: just iterate over the top level elements and pick the appropriate
  122. tree (or get the element by name). Also, that approach makes the logging
  123. initialization code very easy to share among Kea4, Kea6 and D2.<br/><br/>
  124. -# The .spec files used in BIND 10 by the control program to validate commands
  125. will be retained. They will be kept and maintained even though no use of
  126. them is planned. At some future time syntax validation may be implemented,
  127. although it is out of scope for Kea 0.9 (and probably
  128. for 1.0 as it is pretty big task).<br/><br/>
  129. -# Addition of a shell script to start/stop Kea4,Kea6 and D2. There will be a script that will
  130. start, stop and reconfigure the daemons. Its only
  131. job will be to pass the configuration file to each daemon and remember its PID file, so
  132. that sending signals will be be possible (for configuration reload or shutdown). Optionally,
  133. it could also print out a status based on PID, but that may be tricky to
  134. implement in a portable way. The minimum set of commands will be:
  135. -# Start the processes
  136. - eventually based on configuration, initially start them all
  137. - it could launch a nanny script which restarts them on a crash (past 0.9)
  138. -# Prompt the processes to reload configuration
  139. - for now it will be a matter of sending singal to the right process
  140. - this could also decide if D2 should still be running or not, and react accordingly (post 0.9)
  141. -# Stop the processes in an orderly fashion
  142. -# Perhaps return status of each process
  143. */