a library. The change was made in Kea 1.0 to facilitate the
specification of library-specific parameters, a capability
available in Kea 1.1.0 onwards. Libraries should allow a parameter
- entry where to put documentation as it is done for many configuration
+ entry where to put comments as it is done for many configuration
scopes with comment and user context.
</para></note>
</para>
<para>
Usually when an entry is defined multiple times in the same scope
- the last value is used overwriting previous values (silently:
- this behavior should be fixed soon). With user contexts values
+ the last value is used overwriting previous values (this
+ behavior will be fixed some time in the future). With user contexts values
are combined at the first level, for instance multiple user context
with a "comment" entry gives an entry with the list of accumulated
values.
operations for example.
</para>
<para>
- The parser translates "comment" entries at locations user context
- are valid into a user context with a "comment" entry. The pretty
- print of a configuration does the opposite operation and puts
- "comment" entries at the beginning of maps as it seems to be the
- common usage.
+ If user context is supported in a given context, the parser translates
+ "comment" entries into user context with a "comment" entry. The pretty
+ print of a configuration does the opposite operation and puts "comment"
+ entries at the beginning of maps as it seems to be the common usage.
</para>
<para>
As of Kea 1.3, the structures that allow user contexts are
pools of all types (addresses and prefixes) and subnets. Kea
- 1.4 extended to the global scope, interfaces config,
+ 1.4 extended user context support to the global scope, interfaces config,
shared networks, subnets, client classes, option datas and definitions,
host reservations, control socket, dhcp ddns, loggers and server id.
These are supported in both DHCPv4 and DHCPv6 at the exception
" ],"
" \"subnet\": \"2001:db8::/32\""
" } ]"
- "}"
+ "}",
+
+ // Configuration 7: comments everywhere
+ "{\n"
+ "\"comment\": \"A DHCPv6 server\",\n"
+ "\"server-id\": {\n"
+ " \"comment\": \"DHCPv6 specific\",\n"
+ " \"type\": \"LL\"\n"
+ "},\n"
+ "\"interfaces-config\": {\n"
+ " \"comment\": \"Use wildcard\",\n"
+ " \"interfaces\": [ \"*\" ] },\n"
+ "\"option-def\": [ {\n"
+ " \"comment\": \"An option definition\",\n"
+ " \"name\": \"foo\",\n"
+ " \"code\": 100,\n"
+ " \"type\": \"ipv6-address\",\n"
+ " \"space\": \"isc\"\n"
+ " } ],\n"
+ "\"option-data\": [ {\n"
+ " \"comment\": \"Set option value\",\n"
+ " \"name\": \"subscriber-id\",\n"
+ " \"data\": \"ABCDEF0105\",\n"
+ " \"csv-format\": false\n"
+ " } ],\n"
+ "\"client-classes\": [\n"
+ " {\n"
+ " \"comment\": \"match all\",\n"
+ " \"name\": \"all\",\n"
+ " \"test\": \"'' == ''\"\n"
+ " },\n"
+ " {\n"
+ " \"name\": \"none\"\n"
+ " },\n"
+ " {\n"
+ " \"comment\": \"first comment\",\n"
+ " \"comment\": \"second comment\",\n"
+ " \"name\": \"two\"\n"
+ " },\n"
+ " {\n"
+ " \"comment\": \"a comment\",\n"
+ " \"name\": \"both\",\n"
+ " \"user-context\": {\n"
+ " \"version\": 1\n"
+ " }\n"
+ " }\n"
+ " ],\n"
+ "\"control-socket\": {\n"
+ " \"comment\": \"REST API\",\n"
+ " \"socket-type\": \"unix\",\n"
+ " \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
+ " \"user-context\": { \"comment\": \"Indirect comment\" }\n"
+ "},\n"
+ "\"shared-networks\": [ {\n"
+ " \"comment\": \"A shared network\"\n,"
+ " \"name\": \"foo\"\n,"
+ " \"subnet6\": [\n"
+ " { \n"
+ " \"comment\": \"A subnet\"\n,"
+ " \"subnet\": \"2001:db1::/48\",\n"
+ " \"id\": 100,\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"comment\": \"A pool\",\n"
+ " \"pool\": \"2001:db1::/64\"\n"
+ " }\n"
+ " ],\n"
+ " \"pd-pools\": [\n"
+ " {\n"
+ " \"comment\": \"A prefix pool\",\n"
+ " \"prefix\": \"2001:db2::\",\n"
+ " \"prefix-len\": 48,\n"
+ " \"delegated-len\": 64\n"
+ " }\n"
+ " ],\n"
+ " \"reservations\": [\n"
+ " {\n"
+ " \"comment\": \"A host reservation\",\n"
+ " \"hw-address\": \"AA:BB:CC:DD:EE:FF\",\n"
+ " \"hostname\": \"foo.example.com\",\n"
+ " \"option-data\": [ {\n"
+ " \"comment\": \"An option in a reservation\",\n"
+ " \"name\": \"domain-search\",\n"
+ " \"data\": \"example.com\"\n"
+ " } ]\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ]\n"
+ " } ],\n"
+ "\"dhcp-ddns\": {\n"
+ " \"comment\": \"No dynamic DNS\",\n"
+ " \"enable-updates\": false\n"
+ "}\n"
+ "}\n"
};
std::string specfile(const std::string& name) {
}
int rcode_; ///< Return code (see @ref isc::config::parseAnswer)
- ControlledDhcpv6Srv srv_; ///< Instance of the ControlledDhcp6Srv used during tests
+ Dhcpv6Srv srv_; ///< Instance of the ControlledDhcp6Srv used during tests
ConstElementPtr comment_; ///< Comment (see @ref isc::config::parseAnswer)
string valid_iface_; ///< Valid network interface name (present in system)
string bogus_iface_; ///< invalid network interface name (not in system)
// This test checks comments. Please keep it last.
TEST_F(Dhcp6ParserTest, comments) {
- string config = "{\n"
- "\"comment\": \"A DHCPv6 server\",\n"
- "\"server-id\": {\n"
- " \"comment\": \"DHCPv6 specific\",\n"
- " \"type\": \"LL\"\n"
- "},\n"
- "\"interfaces-config\": {\n"
- " \"comment\": \"Use wildcard\",\n"
- " \"interfaces\": [ \"*\" ] },\n"
- "\"option-def\": [ {\n"
- " \"comment\": \"An option definition\",\n"
- " \"name\": \"foo\",\n"
- " \"code\": 100,\n"
- " \"type\": \"ipv6-address\",\n"
- " \"space\": \"isc\"\n"
- " } ],\n"
- "\"option-data\": [ {\n"
- " \"comment\": \"Set option value\",\n"
- " \"name\": \"subscriber-id\",\n"
- " \"data\": \"ABCDEF0105\",\n"
- " \"csv-format\": false\n"
- " } ],\n"
- "\"client-classes\": [\n"
- " {\n"
- " \"comment\": \"match all\",\n"
- " \"name\": \"all\",\n"
- " \"test\": \"'' == ''\"\n"
- " },\n"
- " {\n"
- " \"name\": \"none\"\n"
- " },\n"
- " {\n"
- " \"comment\": \"first comment\",\n"
- " \"comment\": \"second comment\",\n"
- " \"name\": \"two\"\n"
- " },\n"
- " {\n"
- " \"comment\": \"a comment\",\n"
- " \"name\": \"both\",\n"
- " \"user-context\": {\n"
- " \"version\": 1\n"
- " }\n"
- " }\n"
- " ],\n"
- "\"control-socket\": {\n"
- " \"comment\": \"REST API\",\n"
- " \"socket-type\": \"unix\",\n"
- " \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
- " \"user-context\": { \"comment\": \"Indirect comment\" }\n"
- "},\n"
- "\"shared-networks\": [ {\n"
- " \"comment\": \"A shared network\"\n,"
- " \"name\": \"foo\"\n,"
- " \"subnet6\": [\n"
- " { \n"
- " \"comment\": \"A subnet\"\n,"
- " \"subnet\": \"2001:db1::/48\",\n"
- " \"id\": 100,\n"
- " \"pools\": [\n"
- " {\n"
- " \"comment\": \"A pool\",\n"
- " \"pool\": \"2001:db1::/64\"\n"
- " }\n"
- " ],\n"
- " \"pd-pools\": [\n"
- " {\n"
- " \"comment\": \"A prefix pool\",\n"
- " \"prefix\": \"2001:db2::\",\n"
- " \"prefix-len\": 48,\n"
- " \"delegated-len\": 64\n"
- " }\n"
- " ],\n"
- " \"reservations\": [\n"
- " {\n"
- " \"comment\": \"A host reservation\",\n"
- " \"hw-address\": \"AA:BB:CC:DD:EE:FF\",\n"
- " \"hostname\": \"foo.example.com\",\n"
- " \"option-data\": [ {\n"
- " \"comment\": \"An option in a reservation\",\n"
- " \"name\": \"domain-search\",\n"
- " \"data\": \"example.com\"\n"
- " } ]\n"
- " }\n"
- " ]\n"
- " }\n"
- " ]\n"
- " } ],\n"
- "\"dhcp-ddns\": {\n"
- " \"comment\": \"No dynamic DNS\",\n"
- " \"enable-updates\": false\n"
- "}\n"
- "}\n";
-
- extractConfig(config);
- configure(config, CONTROL_RESULT_SUCCESS, "");
+ extractConfig(PARSER_CONFIGS[7]);
+ configure(PARSER_CONFIGS[7], CONTROL_RESULT_SUCCESS, "");
// Check global user context.
ConstElementPtr ctx = CfgMgr::instance().getStagingCfg()->getContext();
ASSERT_EQ(1, ctx_d2->size());
ASSERT_TRUE(ctx_d2->get("comment"));
EXPECT_EQ("\"No dynamic DNS\"", ctx_d2->get("comment")->str());
-
-#if 0
- // Loggers section supports comments too.
-
- string logging = "{\n"
- "\"loggers\": [ {\n"
- " \"comment\": \"A logger\",\n"
- " \"name\": \"kea-dhcp6\"\n"
- "} ]\n";
-#endif
}
};