config-backend.dox 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Copyright (C) 2014-2015 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 configBackend Kea Configuration Backends
  8. @section configBackendIntro Introduction
  9. Kea started as a sub-project in BIND10 that used bindctl to deliver
  10. configuration to its modules. After BIND10 was cancelled, Kea project
  11. briefly tried to maintain backward compatibility with the BIND10 framework,
  12. but the idea has been promptly dropped due to lack interest.
  13. Currently Kea team does not foresee any additional configuration
  14. backends to be developed. Instead, an effort is being made to enhance
  15. current control channel (see @ref ctrlSocket) to be as flexible as
  16. possible. If you are thinking about developing new ways to configure
  17. Kea, the recommendation is to write an external piece of software that
  18. will communicate with Kea using control channel.
  19. @section configBackendHistoric Historic Notes
  20. While this section currently has not practical value, it may become useful
  21. one day to develop a minimalistic, stripped down Kea version that does
  22. not have any command interface at all. This could prove useful for running
  23. Kea in embedded regime.
  24. The following steps are needed were conducted for the DHCPv4 server to
  25. be able to process configuration. (It is assumed that the modified
  26. component is DHCPv4. Similar approach applies to the other components:
  27. DHCPv6 or DHCP-DDNS):
  28. -# Write your own implementation of isc::dhcp::ControlledDhcpv4Srv::init(),
  29. isc::dhcp::ControlledDhcpv4Srv::init() and isc::dhcp::ControlledDhcpv4Srv::cleanup()
  30. and put it in the src/bin/dhcp4 directory (e.g. as foo_controller.cc).
  31. -# Modify src/bin/dhcp4/Makefile.am to include your file (e.g. foo_controller.cc) in
  32. the build.
  33. -# Modify the AC_ARG_WITH(kea-config,...) macro in configure.ac to include an
  34. entry for your configuration backend.
  35. -# Add your own AM_CONDITIONAL(CONFIG_BACKEND_FOO, ...) and
  36. AC_DEFINE(CONFIG_BACKEND_FOO, ...) macros to configure.ac (following the
  37. above-mentioned AC_ARG_WITH macro) to set the C++ macro for your backend.
  38. -# Modify the sanity check in configure.ac to allow your configuration backend name.
  39. Optionally you can also:
  40. -# Implement unit tests for your backend in the src/bin/dhcp4/tests directory.
  41. -# Modify src/bin/dhcp4/tests/Makefile.am to include the file(s) containing the
  42. unit tests.
  43. @section configBackendJSONDesign The JSON Configuration Backend
  44. The following are some details of the JSON backend framework.
  45. -# Each backend uses the common code for configuration and command
  46. processing callbacks. They all assume that JSON formatted parameters are sent
  47. and they are expected to return well formatted JSON responses. The exact
  48. format of configuration and commands is module-specific.<br/><br/>
  49. -# A command handler handles the reading the configuration from a
  50. file. Its main responsibility is to load the configuration and process
  51. it. The JSON backend must call that handler when starting up the server.
  52. This is implemented in configure() in the kea_controller.cc files
  53. in src/bin/dhcp4 and src/bin/dhcp6 directories.<br/><br/>
  54. -# The current JSON parser in @ref
  55. isc::data::Element::fromJSON() has been extended to allow optional
  56. preprocessing. For now, that capability simply removes whole-line
  57. comments starting with the hash character, but it is expected to grow over
  58. time (in-line comments and file inclusions are the obvious envisaged
  59. additions). This is implemented in @ref isc::data::Element::fromJSONFile.<br/><br/>
  60. -# The current format of the BIND10 configuration file (BIND 10 stored its
  61. configuration in (installation directory) /var/bind10/b10-config.db) has been
  62. retained as the configuration file format. Its actual naming is now arbitrary
  63. and left up to the user (it is passed as a parameter to the -c command line
  64. option). From the implementation perspective, this is slight change
  65. from the BIND10 days, as back then a subset of the configuration was received by
  66. the daemon processes. Nowadays the whole configuration is passed. To take a
  67. specific example, the following is how b10-config.db looks today:
  68. @code
  69. {
  70. "Init": { ... }
  71. "Dhcp4": {
  72. "subnet4" { subnet definitions here },
  73. "option-data" { option data here },
  74. "interfaces": [ "eth0" ],
  75. ...
  76. },
  77. "Dhcp6": {
  78. "subnet6" { subnet definitions here },
  79. "option-data" { option data here },
  80. "interfaces": [ "eth0" ],
  81. ...
  82. },
  83. "Logging": {
  84. "Loggers": [{"name": *, "severity": "DEBUG" }]
  85. }
  86. }
  87. @endcode
  88. The Kea components used to receive only relevant parts of it (e.g. Kea4
  89. received configuration data that only contained the content of the Dhcp4 element).
  90. Now each component receives all of it: the code
  91. iterates over the top level elements and picks the appropriate
  92. tree (or get the element by name). That approach makes the common configuration
  93. (such as the logging initialization code) very easy to share among Kea4, Kea6 and
  94. DHCP-DDNS.<br/><br/>
  95. -# The .spec files used in BIND 10 by the control program to validate commands
  96. have been retained. They will be kept and maintained even though no use of
  97. them is currently planned. At some future time syntax validation may be implemented,
  98. although it is out of scope for Kea 0.9 (and probably
  99. for 1.0 as well, as it is a pretty big task).<br/><br/>
  100. -# A shell script has been added (as src/bin/keactrl/keactrl) to
  101. start, stop and reconfigure the daemons. Its only
  102. job is to pass the configuration file to each daemon and remember its PID file, so
  103. that sending signals is possible (for configuration reload or shutdown). It is also
  104. able to print out a status.
  105. */