From: Razvan Becheriu Date: Fri, 9 Oct 2020 18:41:55 +0000 (+0300) Subject: [#1405] fixed unittests X-Git-Tag: Kea-1.9.2~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d1fac920aefdc210a07a5bfdacd71a47936a87a;p=thirdparty%2Fkea.git [#1405] fixed unittests --- diff --git a/doc/examples/kea4/all-keys-netconf.json b/doc/examples/kea4/all-keys-netconf.json index 9ab0f99951..0972fadd24 100644 --- a/doc/examples/kea4/all-keys-netconf.json +++ b/doc/examples/kea4/all-keys-netconf.json @@ -569,9 +569,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // List of client classes which must be evaluated when this shared @@ -700,9 +700,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // Subnet level compute T1 and T2 timers. @@ -825,9 +825,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // Global compute T1 and T2 timers. diff --git a/doc/examples/kea4/all-keys.json b/doc/examples/kea4/all-keys.json index 3a75c3259c..8d4cb5fb51 100644 --- a/doc/examples/kea4/all-keys.json +++ b/doc/examples/kea4/all-keys.json @@ -701,9 +701,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // List of client classes which must be evaluated when this shared @@ -873,9 +873,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // Subnet level compute T1 and T2 timers. @@ -1010,9 +1010,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // Global compute T1 and T2 timers. diff --git a/doc/examples/kea4/global-reservations.json b/doc/examples/kea4/global-reservations.json index d5bb5ef9f8..cf4ce31e50 100644 --- a/doc/examples/kea4/global-reservations.json +++ b/doc/examples/kea4/global-reservations.json @@ -57,9 +57,9 @@ // Since Kea 1.9.1, a more flexible option of configuring the way Kea uses host // reservations is available through the 'reservation-modes' map. "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false }, // Define several global host reservations. diff --git a/doc/examples/kea4/reservations.json b/doc/examples/kea4/reservations.json index 4f1864f805..eb7fbd55bc 100644 --- a/doc/examples/kea4/reservations.json +++ b/doc/examples/kea4/reservations.json @@ -72,9 +72,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, "reservations": [ diff --git a/doc/examples/kea4/shared-network.json b/doc/examples/kea4/shared-network.json index 08c3bf2bfa..42885cd3d7 100644 --- a/doc/examples/kea4/shared-network.json +++ b/doc/examples/kea4/shared-network.json @@ -70,9 +70,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // This starts a list of subnets allowed in this shared network. @@ -100,9 +100,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, "subnet": "10.0.0.0/8", "valid-lifetime": 30 @@ -122,9 +122,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, "subnet": "192.0.2.0/24", "valid-lifetime": 30 diff --git a/doc/examples/kea6/all-keys-netconf.json b/doc/examples/kea6/all-keys-netconf.json index 7585399fb6..563a6dd453 100644 --- a/doc/examples/kea6/all-keys-netconf.json +++ b/doc/examples/kea6/all-keys-netconf.json @@ -534,9 +534,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // List of client classes which must be evaluated when this shared @@ -691,9 +691,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // Subnet level compute T1 and T2 timers. @@ -816,9 +816,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // Data directory. diff --git a/doc/examples/kea6/all-keys.json b/doc/examples/kea6/all-keys.json index 9482db7521..46695e9823 100644 --- a/doc/examples/kea6/all-keys.json +++ b/doc/examples/kea6/all-keys.json @@ -659,9 +659,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // List of client classes which must be evaluated when this shared @@ -854,9 +854,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // Subnet level compute T1 and T2 timers. @@ -988,9 +988,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // Data directory. diff --git a/doc/examples/kea6/global-reservations.json b/doc/examples/kea6/global-reservations.json index 53e253a8d9..6a11a40dde 100644 --- a/doc/examples/kea6/global-reservations.json +++ b/doc/examples/kea6/global-reservations.json @@ -46,9 +46,9 @@ // Since Kea 1.9.1, a more flexible option of configuring the way Kea uses host // reservations is available through the 'reservation-modes' map. "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false }, // Define several global host reservations. diff --git a/doc/examples/kea6/reservations.json b/doc/examples/kea6/reservations.json index 5005b5100e..decc673243 100644 --- a/doc/examples/kea6/reservations.json +++ b/doc/examples/kea6/reservations.json @@ -54,9 +54,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, "pools": [ { "pool": "2001:db8:1::/120" } ], diff --git a/doc/examples/kea6/shared-network.json b/doc/examples/kea6/shared-network.json index 49f1c998ea..8fc3464b78 100644 --- a/doc/examples/kea6/shared-network.json +++ b/doc/examples/kea6/shared-network.json @@ -75,9 +75,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, // List of subnets belonging to this particular shared-network @@ -99,9 +99,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, "subnet": "2001:db8:1::/64", "pools": [ { "pool": "2001:db8:1:abcd::/64" } ], @@ -123,9 +123,9 @@ // Reservation modes specifying server's mode of operation when it // fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, "subnet": "3000::/16", "valid-lifetime": 40 diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index d8ce6e2453..17c5e09962 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -4637,9 +4637,9 @@ The correspondence of old values are: "Dhcp4": { "reservation-modes": { - "global": False, - "in-subnet": False, - "out-of-pool": False + "global": false, + "in-subnet": false, + "out-of-pool": false } } @@ -4650,9 +4650,9 @@ The correspondence of old values are: "Dhcp4": { "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false } } @@ -4663,9 +4663,9 @@ The correspondence of old values are: "Dhcp4": { "reservation-modes": { - "global": False, - "in-subnet": False, - "out-of-pool": True + "global": false, + "in-subnet": false, + "out-of-pool": true } } @@ -4676,9 +4676,9 @@ The correspondence of old values are: "Dhcp4": { "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true } } @@ -4689,9 +4689,9 @@ To activate both ``global`` and ``all``, the following combination can be used: "Dhcp4": { "reservation-modes": { - "global": True, - "in-subnet": True, - "out-of-pool": True + "global": true, + "in-subnet": true, + "out-of-pool": true } } @@ -4707,9 +4707,9 @@ An example configuration that disables reservation looks as follows: { "subnet": "192.0.2.0/24", "reservation-modes": { - "global": False, - "in-subnet": False, - "out-of-pool": False + "global": false, + "in-subnet": false, + "out-of-pool": false }, ... } @@ -4725,9 +4725,9 @@ An example configuration using global reservations is shown below: "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false }, "reservations": [ { @@ -4858,9 +4858,9 @@ following can be used: # Reservation modes specifying server's mode of operation when it # fetches host reservations. "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false }, "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ] } ] @@ -4969,9 +4969,9 @@ following example: # Reservation modes specifying server's mode of operation when it # fetches host reservations. "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false }, "shared-networks": [{ "subnet4": [ @@ -5005,8 +5005,8 @@ will be assigned an address from the subnet 192.0.3.0/24. Clients having a reservation for the ``reserved_class`` will be assigned an address from the subnet 192.0.2.0/24. The subnets must belong to the same shared network. In addition, the reservation for the client class must be specified at the -global scope (global reservation) and the ``reservation-mode`` must be -set to ``global``. +global scope (global reservation) and the ``reservation-modes`` must +set ``global`` to true. In the example above the ``client-class`` could also be specified at the subnet level rather than pool level yielding the same effect. @@ -6737,6 +6737,8 @@ used by all servers connecting to the configuration database. +-----------------------------+----------------------------+-------------+-------------+-------------+ | reservation-mode | yes | yes | yes | n/a | +-----------------------------+----------------------------+-------------+-------------+-------------+ + | reservation-modes | yes | yes | yes | n/a | + +-----------------------------+----------------------------+-------------+-------------+-------------+ | t1-percent | yes | yes | yes | n/a | +-----------------------------+----------------------------+-------------+-------------+-------------+ | t2-percent | yes | yes | yes | n/a | diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 269c9ca5e3..f537060378 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -4082,9 +4082,9 @@ The correspondence of old values are: "Dhcp6": { "reservation-modes": { - "global": False, - "in-subnet": False, - "out-of-pool": False + "global": false, + "in-subnet": false, + "out-of-pool": false } } @@ -4095,9 +4095,9 @@ The correspondence of old values are: "Dhcp6": { "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false } } @@ -4108,9 +4108,9 @@ The correspondence of old values are: "Dhcp6": { "reservation-modes": { - "global": False, - "in-subnet": False, - "out-of-pool": True + "global": false, + "in-subnet": false, + "out-of-pool": true } } @@ -4121,9 +4121,9 @@ The correspondence of old values are: "Dhcp6": { "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true } } @@ -4134,9 +4134,9 @@ To activate both ``global`` and ``all``, the following combination can be used: "Dhcp6": { "reservation-modes": { - "global": True, - "in-subnet": True, - "out-of-pool": True + "global": true, + "in-subnet": true, + "out-of-pool": true } } @@ -4152,9 +4152,9 @@ An example configuration that disables reservation looks as follows: { "subnet": "2001:db8:1::/64", "reservation-modes": { - "global": False, - "in-subnet": False, - "out-of-pool": False + "global": false, + "in-subnet": false, + "out-of-pool": false }, ... } @@ -4170,9 +4170,9 @@ An example configuration using global reservations is shown below: "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false }, "reservations": [ { @@ -4299,9 +4299,9 @@ following can be used: # Reservation modes specifying server's mode of operation when it # fetches host reservations. "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false }, "pools": [ { "pool": "2001:db8:1::-2001:db8:1::100" } ] } ] @@ -4410,9 +4410,9 @@ following example: # Reservation modes specifying server's mode of operation when it # fetches host reservations. "reservation-modes": { - "global": True, - "in-subnet": False, - "out-of-pool": False + "global": true, + "in-subnet": false, + "out-of-pool": false }, "shared-networks": [{ "subnet6": [ @@ -4446,8 +4446,8 @@ will be assigned an address from the subnet 2001:db8:2::/64. Clients having a reservation for the ``reserved_class`` will be assigned an address from the subnet 2001:db8:1::/64. The subnets must belong to the same shared network. In addition, the reservation for the client class must be specified at the -global scope (global reservation) and the ``reservation-mode`` must be -set to ``global``. +global scope (global reservation) and the ``reservation-modes`` must +set ``global`` to true. In the example above the ``client-class`` could also be specified at the subnet level rather than pool level yielding the same effect. @@ -6739,6 +6739,8 @@ the global DHCPv6 options (``option-data``) are modified using +-----------------------------+----------------------------+-----------+-----------+-----------+------------+ | reservation-mode | yes | yes | yes | n/a | n/a | +-----------------------------+----------------------------+-----------+-----------+-----------+------------+ + | reservation-modes | yes | yes | yes | n/a | n/a | + +-----------------------------+----------------------------+-----------+-----------+-----------+------------+ | t1-percent | yes | yes | yes | n/a | n/a | +-----------------------------+----------------------------+-----------+-----------+-----------+------------+ | t2-percent | yes | yes | yes | n/a | n/a | diff --git a/doc/sphinx/arm/hooks.rst b/doc/sphinx/arm/hooks.rst index 6f81132bc9..453c590f46 100644 --- a/doc/sphinx/arm/hooks.rst +++ b/doc/sphinx/arm/hooks.rst @@ -2660,9 +2660,9 @@ An example response could look as follows: # Reservation modes specifying server's mode of operation when it # fetches host reservations. "reservation-modes": { - "global": False, - "in-subnet": True, - "out-of-pool": True + "global": false, + "in-subnet": true, + "out-of-pool": true }, "subnet4": [ { diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index 6900615e03..aa0ebf5d59 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -5387,31 +5387,31 @@ TEST_F(Dhcp4ParserTest, hostReservationModesPerSubnet) { " \"pools\": [ { \"pool\": \"192.0.1.0/24\" } ]," " \"subnet\": \"192.0.1.0/24\", " " \"reservation-modes\": {" - " \"in-subnet\": True," - " \"out-of-pool\": True" + " \"in-subnet\": true," + " \"out-of-pool\": true" " }" " }," " {" " \"pools\": [ { \"pool\": \"192.0.2.0/24\" } ]," " \"subnet\": \"192.0.2.0/24\", " " \"reservation-modes\": {" - " \"out-of-pool\": True" + " \"out-of-pool\": true" " }" " }," " {" " \"pools\": [ { \"pool\": \"192.0.3.0/24\" } ]," " \"subnet\": \"192.0.4.0/24\", " " \"reservation-modes\": {" - " \"in-subnet\": False," - " \"out-of-pool\": False," - " \"global\": False" + " \"in-subnet\": false," + " \"out-of-pool\": false," + " \"global\": false" " }" " }," " {" " \"pools\": [ { \"pool\": \"192.0.4.0/24\" } ]," " \"subnet\": \"192.0.4.0/24\", " " \"reservation-modes\": {" - " \"global\": True" + " \"global\": true" " }" " }," " {" @@ -5422,9 +5422,9 @@ TEST_F(Dhcp4ParserTest, hostReservationModesPerSubnet) { " \"pools\": [ { \"pool\": \"192.0.6.0/24\" } ]," " \"subnet\": \"192.0.6.0/24\", " " \"reservation-modes\": {" - " \"in-subnet\": True," - " \"out-of-pool\": True," - " \"global\": True" + " \"in-subnet\": true," + " \"out-of-pool\": true," + " \"global\": true" " }" " } ]," "\"valid-lifetime\": 4000 }"; @@ -5554,14 +5554,14 @@ TEST_F(Dhcp4ParserTest, hostReservationModesGlobal) { "\"rebind-timer\": 2000, " "\"renew-timer\": 1000, " "\"reservation-modes\": {" - " \"out-of-pool\": True" + " \"out-of-pool\": true" " }," "\"subnet4\": [ { " " \"pools\": [ { \"pool\": \"192.0.2.0/24\" } ]," " \"subnet\": \"192.0.2.0/24\", " " \"reservation-modes\": {" - " \"in-subnet\": True," - " \"out-of-pool\": True" + " \"in-subnet\": true," + " \"out-of-pool\": true" " }" " }," " {" @@ -6462,7 +6462,7 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) { " \"ip-address\": \"5.6.7.8\"\n" " },\n" " \"reservation-modes\": {" - " \"out-of-pool\": True" + " \"out-of-pool\": true" " }," " \"renew-timer\": 10,\n" " \"rebind-timer\": 20,\n" @@ -6490,7 +6490,7 @@ TEST_F(Dhcp4ParserTest, sharedNetworksDerive) { " \"ip-address\": \"55.66.77.88\"\n" " },\n" " \"reservation-modes\": {" - " \"global\": False" + " \"global\": false" " }" " }\n" " ]\n" diff --git a/src/bin/dhcp4/tests/host_unittest.cc b/src/bin/dhcp4/tests/host_unittest.cc index 9f9f7f38a2..4e246515a5 100644 --- a/src/bin/dhcp4/tests/host_unittest.cc +++ b/src/bin/dhcp4/tests/host_unittest.cc @@ -67,7 +67,7 @@ const char* CONFIGS[] = { "\"valid-lifetime\": 600,\n" "\"subnet4\": [ { \n" " \"subnet\": \"10.0.0.0/24\", \n" - " \"reservation-modes\": { \"global\": True }," + " \"reservation-modes\": { \"global\": true }," " \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]\n" "} ]\n" "}\n" @@ -102,7 +102,7 @@ const char* CONFIGS[] = { " \"id\": 20," " \"pools\": [ { \"pool\": \"192.0.2.10-192.0.2.63\" } ],\n" " \"interface\": \"eth1\",\n" - " \"reservation-modes\": { \"global\": True }," + " \"reservation-modes\": { \"global\": true }," " \"reservations\": [ \n" " {\n" " \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n" @@ -129,7 +129,7 @@ const char* CONFIGS[] = { " \"id\": 10," " \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ],\n" " \"interface\": \"eth0\",\n" - " \"reservation-modes\": { \"out-of-pool\": True }," + " \"reservation-modes\": { \"out-of-pool\": true }," " \"reservations\": [ \n" " {\n" " \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n" @@ -157,7 +157,7 @@ const char* CONFIGS[] = { " \"id\": 10," " \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ],\n" " \"interface\": \"eth0\",\n" - " \"reservation-modes\": { \"in-subnet\": True, \"out-of-pool\": True }," + " \"reservation-modes\": { \"in-subnet\": true, \"out-of-pool\": true }," " \"reservations\": [ \n" " {\n" " \"hw-address\": \"aa:bb:cc:dd:ee:ff\",\n" @@ -183,7 +183,7 @@ const char* CONFIGS[] = { " \"test\": \"not member('reserved_class')\"" "}" "],\n" - "\"reservation-modes\": { \"global\": True }," + "\"reservation-modes\": { \"global\": true }," "\"valid-lifetime\": 600,\n" "\"reservations\": [ \n" "{\n" diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index 37651e7e2f..cc8ca4c88e 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -5760,31 +5760,31 @@ TEST_F(Dhcp6ParserTest, hostReservationModesPerSubnet) { " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ]," " \"subnet\": \"2001:db8:1::/48\", " " \"reservation-modes\": {" - " \"in-subnet\": True," - " \"out-of-pool\": True" + " \"in-subnet\": true," + " \"out-of-pool\": true" " }" " }," " {" " \"pools\": [ { \"pool\": \"2001:db8:2::/64\" } ]," " \"subnet\": \"2001:db8:2::/48\", " " \"reservation-modes\": {" - " \"out-of-pool\": True" + " \"out-of-pool\": true" " }" " }," " {" " \"pools\": [ { \"pool\": \"2001:db8:3::/64\" } ]," " \"subnet\": \"2001:db8:3::/48\", " " \"reservation-modes\": {" - " \"in-subnet\": False," - " \"out-of-pool\": False," - " \"global\": False" + " \"in-subnet\": false," + " \"out-of-pool\": false," + " \"global\": false" " }" " }," " {" " \"pools\": [ { \"pool\": \"2001:db8:4::/64\" } ]," " \"subnet\": \"2001:db8:4::/48\", " " \"reservation-modes\": {" - " \"global\": True" + " \"global\": true" " }" " }," " {" @@ -5795,9 +5795,9 @@ TEST_F(Dhcp6ParserTest, hostReservationModesPerSubnet) { " \"pools\": [ { \"pool\": \"2001:db8:6::/64\" } ]," " \"subnet\": \"2001:db8:6::/48\", " " \"reservation-modes\": {" - " \"in-subnet\": True," - " \"out-of-pool\": True," - " \"global\": True" + " \"in-subnet\": true," + " \"out-of-pool\": true," + " \"global\": true" " }" " } ]," "\"valid-lifetime\": 4000 }"; @@ -5925,14 +5925,14 @@ TEST_F(Dhcp6ParserTest, hostReservationModesGlobal) { "\"rebind-timer\": 2000, " "\"renew-timer\": 1000, " "\"reservation-modes\": {" - " \"out-of-pool\": True" + " \"out-of-pool\": true" " }," "\"subnet6\": [ { " " \"pools\": [ { \"pool\": \"2001:db8:1::/64\" } ]," " \"subnet\": \"2001:db8:1::/48\", " " \"reservation-modes\": {" - " \"in-subnet\": True," - " \"out-of-pool\": True" + " \"in-subnet\": true," + " \"out-of-pool\": true" " }" " }," " {" @@ -6892,7 +6892,7 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) { " },\n" " \"rapid-commit\": true,\n" " \"reservation-modes\": {" - " \"global\": False" + " \"global\": false" " }" " \"subnet6\": [\n" " { \n" @@ -6916,7 +6916,7 @@ TEST_F(Dhcp6ParserTest, sharedNetworksDerive) { " \"interface-id\": \"twotwo\",\n" " \"rapid-commit\": true,\n" " \"reservation-modes\": {" - " \"out-of-pool\": True" + " \"out-of-pool\": true" " }" " }\n" " ]\n" diff --git a/src/lib/dhcpsrv/network.cc b/src/lib/dhcpsrv/network.cc index 614d07260d..58e6f78229 100644 --- a/src/lib/dhcpsrv/network.cc +++ b/src/lib/dhcpsrv/network.cc @@ -204,25 +204,36 @@ Network::toElement() const { // Set reservation mode Optional hrmode = host_reservation_mode_; if (!hrmode.unspecified()) { - std::string mode; - switch (hrmode.get()) { - case HR_DISABLED: - mode = "disabled"; - break; - case HR_OUT_OF_POOL: - mode = "out-of-pool"; - break; - case HR_GLOBAL: - mode = "global"; - break; - case HR_ALL: - mode = "all"; - break; - default: - isc_throw(ToElementError, - "invalid host reservation mode: " << hrmode.get()); + bool hr_global = false; + bool hr_in_sunbet = false; + bool hr_out_of_pool = false; + if (hrmode & Network::HR_GLOBAL) { + hr_global = true; } - map->set("reservation-mode", Element::create(mode)); + if (hrmode & Network::HR_IN_SUBNET) { + hr_in_sunbet = true; + } + if (hrmode & Network::HR_OUT_OF_POOL) { + hr_out_of_pool = true; + } + ElementPtr reservation_modes = Element::createMap(); + if (hrmode == Network::HR_DISABLED) { + reservation_modes->set("global", Element::create(false)); + reservation_modes->set("in-subnet", Element::create(false)); + reservation_modes->set("out-of-pool", Element::create(false)); + } else { + if (hr_global) { + reservation_modes->set("global", Element::create(true)); + } + if (hr_in_sunbet) { + reservation_modes->set("in-subnet", Element::create(true)); + } + if (hr_out_of_pool) { + reservation_modes->set("out-of-pool", Element::create(true)); + } + } + + map->set("reservation-modes", reservation_modes); } // Set options diff --git a/src/lib/dhcpsrv/parsers/simple_parser4.cc b/src/lib/dhcpsrv/parsers/simple_parser4.cc index fe3a7059a2..72a5a8cf70 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser4.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser4.cc @@ -71,6 +71,7 @@ const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = { { "config-control", Element::map }, { "server-tag", Element::string }, { "reservation-mode", Element::string }, + { "reservation-modes", Element::map }, { "calculate-tee-times", Element::boolean }, { "t1-percent", Element::real }, { "t2-percent", Element::real }, @@ -111,6 +112,7 @@ const SimpleDefaults SimpleParser4::GLOBAL4_DEFAULTS = { { "boot-file-name", Element::string, "" }, { "server-tag", Element::string, "" }, { "reservation-mode", Element::string, "all" }, + { "reservation-modes", Element::map, "{\"in-subnet\": true, \"out-of-pool\": true}" }, { "calculate-tee-times", Element::boolean, "false" }, { "t1-percent", Element::real, ".50" }, { "t2-percent", Element::real, ".875" }, @@ -207,6 +209,7 @@ const SimpleKeywords SimpleParser4::SUBNET4_PARAMETERS = { { "require-client-classes", Element::list }, { "reservations", Element::list }, { "reservation-mode", Element::string }, + { "reservation-modes", Element::map, }, { "relay", Element::map }, { "match-client-id", Element::boolean }, { "authoritative", Element::boolean }, @@ -324,6 +327,7 @@ const SimpleKeywords SimpleParser4::SHARED_NETWORK4_PARAMETERS = { { "boot-file-name", Element::string }, { "relay", Element::map }, { "reservation-mode", Element::string }, + { "reservation-modes", Element::map }, { "client-class", Element::string }, { "require-client-classes", Element::list }, { "valid-lifetime", Element::integer }, diff --git a/src/lib/dhcpsrv/parsers/simple_parser6.cc b/src/lib/dhcpsrv/parsers/simple_parser6.cc index 66780a697a..190b8a58a7 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser6.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser6.cc @@ -72,6 +72,7 @@ const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = { { "config-control", Element::map }, { "server-tag", Element::string }, { "reservation-mode", Element::string }, + { "reservation-modes", Element::map }, { "calculate-tee-times", Element::boolean }, { "t1-percent", Element::real }, { "t2-percent", Element::real }, @@ -107,6 +108,7 @@ const SimpleDefaults SimpleParser6::GLOBAL6_DEFAULTS = { { "dhcp4o6-port", Element::integer, "0" }, { "server-tag", Element::string, "" }, { "reservation-mode", Element::string, "all" }, + { "reservation-modes", Element::map, "{\"in-subnet\": true, \"out-of-pool\": true}" }, { "calculate-tee-times", Element::boolean, "true" }, { "t1-percent", Element::real, ".50" }, { "t2-percent", Element::real, ".80" }, @@ -209,6 +211,7 @@ const SimpleKeywords SimpleParser6::SUBNET6_PARAMETERS = { { "require-client-classes", Element::list }, { "reservations", Element::list }, { "reservation-mode", Element::string }, + { "reservation-modes", Element::map }, { "relay", Element::map }, { "user-context", Element::map }, { "comment", Element::string }, @@ -333,6 +336,7 @@ const SimpleKeywords SimpleParser6::SHARED_NETWORK6_PARAMETERS = { { "option-data", Element::list }, { "relay", Element::map }, { "reservation-mode", Element::string }, + { "reservation-modes", Element::map }, { "client-class", Element::string }, { "require-client-classes", Element::list }, { "preferred-lifetime", Element::integer }, diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc index d0c2646a7c..814909bce5 100644 --- a/src/lib/dhcpsrv/srv_config.cc +++ b/src/lib/dhcpsrv/srv_config.cc @@ -375,8 +375,28 @@ SrvConfig::applyDefaultsConfiguredGlobals(const SimpleDefaults& defaults) { x.reset(new DoubleElement(dbl_value, pos)); break; } + case Element::map: { + auto data = Element::fromJSON(def_value.value_); + if (data->getType() != Element::map) { + isc_throw(BadValue, + "Internal error. Incorrect map value type for " + << def_value.name_ << " : " << def_value.value_); + } + x = data; + break; + } + case Element::list: { + auto data = Element::fromJSON(def_value.value_); + if (data->getType() != Element::list) { + isc_throw(BadValue, + "Internal error. Incorrect list value type for " + << def_value.name_ << " : " << def_value.value_); + } + x = data; + break; + } default: - // No default values for null, list or map + // No default values for null isc_throw(BadValue, "Internal error. Incorrect default value type for " << def_value.name_); diff --git a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc index 62809c955a..944160f91a 100644 --- a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc @@ -1115,7 +1115,7 @@ TEST(CfgSubnets4Test, unparseSubnet) { " \"4o6-interface-id\": \"\",\n" " \"4o6-subnet\": \"\",\n" " \"authoritative\": false,\n" - " \"reservation-mode\": \"all\",\n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n" " \"option-data\": [ ],\n" " \"pools\": [ ]\n," " \"require-client-classes\": [ \"foo\", \"bar\" ],\n" @@ -1282,7 +1282,7 @@ TEST(CfgSubnets4Test, teeTimePercentValidation) { " \"boot-file-name\": \"\", \n" " \"client-class\": \"\", \n" " \"require-client-classes\": [] \n," - " \"reservation-mode\": \"all\", \n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n" " \"4o6-interface\": \"\", \n" " \"4o6-interface-id\": \"\", \n" " \"4o6-subnet\": \"\" \n" @@ -1349,7 +1349,7 @@ TEST(CfgSubnets4Test, validLifetimeValidation) { " \"boot-file-name\": \"\", \n" " \"client-class\": \"\", \n" " \"require-client-classes\": [] \n," - " \"reservation-mode\": \"all\", \n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n" " \"4o6-interface\": \"\", \n" " \"4o6-interface-id\": \"\", \n" " \"4o6-subnet\": \"\" \n" @@ -1591,7 +1591,7 @@ TEST(CfgSubnets4Test, hostnameSanitizierValidation) { " \"boot-file-name\": \"\", \n" " \"client-class\": \"\", \n" " \"require-client-classes\": [] \n," - " \"reservation-mode\": \"all\", \n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n" " \"4o6-interface\": \"\", \n" " \"4o6-interface-id\": \"\", \n" " \"4o6-subnet\": \"\" \n" @@ -1669,7 +1669,7 @@ TEST(CfgSubnets4Test, cacheParamValidation) { " \"boot-file-name\": \"\", \n" " \"client-class\": \"\", \n" " \"require-client-classes\": [] \n," - " \"reservation-mode\": \"all\", \n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n" " \"4o6-interface\": \"\", \n" " \"4o6-interface-id\": \"\", \n" " \"4o6-subnet\": \"\" \n" diff --git a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc index 55419d4fc8..add98d9e85 100644 --- a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc @@ -710,7 +710,7 @@ TEST(CfgSubnets6Test, unparseSubnet) { " \"min-valid-lifetime\": 100,\n" " \"max-valid-lifetime\": 300,\n" " \"rapid-commit\": false,\n" - " \"reservation-mode\": \"all\",\n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true},\n" " \"pools\": [ ],\n" " \"pd-pools\": [ ],\n" " \"option-data\": [ ],\n" @@ -1079,7 +1079,7 @@ TEST(CfgSubnets6Test, teeTimePercentValidation) { " \"valid-lifetime\": 300, \n" " \"client-class\": \"\", \n" " \"require-client-classes\": [] \n," - " \"reservation-mode\": \"all\" \n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}\n" " }"; @@ -1142,7 +1142,7 @@ TEST(CfgSubnets6Test, preferredLifetimeValidation) { " \"valid-lifetime\": 300, \n" " \"client-class\": \"\", \n" " \"require-client-classes\": [] \n," - " \"reservation-mode\": \"all\" \n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}\n" " }"; @@ -1377,7 +1377,7 @@ TEST(CfgSubnets6Test, hostnameSanitizierValidation) { " \"valid-lifetime\": 300, \n" " \"client-class\": \"\", \n" " \"require-client-classes\": [] \n," - " \"reservation-mode\": \"all\" \n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}\n" " }"; data::ElementPtr elems; @@ -1447,7 +1447,7 @@ TEST(CfgSubnets6Test, cacheParamValidation) { " \"valid-lifetime\": 300, \n" " \"client-class\": \"\", \n" " \"require-client-classes\": [] \n," - " \"reservation-mode\": \"all\" \n" + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}\n" " }"; data::ElementPtr elems; diff --git a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc index f3d0b8f13d..3ef856ea5b 100644 --- a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc @@ -128,7 +128,7 @@ public: " \"rebind-timer\": 199," " \"relay\": { \"ip-addresses\": [ \"10.1.1.1\" ] }," " \"renew-timer\": 99," - " \"reservation-modes\": {\"out-of-pool\": True}," + " \"reservation-modes\": {\"out-of-pool\": true}," " \"server-hostname\": \"example.org\"," " \"require-client-classes\": [ \"runner\" ]," " \"user-context\": { \"comment\": \"example\" }," @@ -173,11 +173,10 @@ public: " \"boot-file-name\": \"\"," " \"client-class\": \"\"," " \"require-client-classes\": []\n," - " \"reservation-mode\": \"all\"," + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}," " \"4o6-interface\": \"\"," " \"4o6-interface-id\": \"\"," " \"4o6-subnet\": \"\"," - " \"reservation-mode\": \"all\"," " \"calculate-tee-times\": true," " \"t1-percent\": .45," " \"t2-percent\": .65," @@ -199,11 +198,10 @@ public: " \"boot-file-name\": \"\"," " \"client-class\": \"\"," " \"require-client-classes\": []\n," - " \"reservation-mode\": \"all\"," + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}," " \"4o6-interface\": \"\"," " \"4o6-interface-id\": \"\"," " \"4o6-subnet\": \"\"," - " \"reservation-mode\": \"all\"," " \"calculate-tee-times\": false," " \"t1-percent\": .40," " \"t2-percent\": .80," @@ -549,7 +547,7 @@ public: " \"relay\": { \"ip-addresses\": [ \"2001:db8:1::1\" ] }," " \"renew-timer\": 99," " \"require-client-classes\": [ \"runner\" ]," - " \"reservation-modes\": {\"out-of-pool\": True}," + " \"reservation-modes\": {\"out-of-pool\": true}," " \"user-context\": { }," " \"valid-lifetime\": 399," " \"min-valid-lifetime\": 299," @@ -591,7 +589,7 @@ public: " \"max-valid-lifetime\": 500," " \"client-class\": \"\"," " \"require-client-classes\": []\n," - " \"reservation-mode\": \"all\"," + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}," " \"rapid-commit\": false," " \"hostname-char-set\": \"\"" " }," @@ -606,7 +604,7 @@ public: " \"valid-lifetime\": 40," " \"client-class\": \"\"," " \"require-client-classes\": []\n," - " \"reservation-mode\": \"all\"," + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}," " \"rapid-commit\": false" " }" " ]" diff --git a/src/lib/dhcpsrv/tests/shared_network_unittest.cc b/src/lib/dhcpsrv/tests/shared_network_unittest.cc index a1f6c30e4c..985edafd17 100644 --- a/src/lib/dhcpsrv/tests/shared_network_unittest.cc +++ b/src/lib/dhcpsrv/tests/shared_network_unittest.cc @@ -640,7 +640,7 @@ TEST(SharedNetwork4Test, unparse) { " },\n" " \"renew-timer\": 100,\n" " \"require-client-classes\": [ \"foo\" ],\n" - " \"reservation-mode\": \"all\"," + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}," " \"subnet4\": [\n" " {\n" " \"4o6-interface\": \"\",\n" @@ -1331,7 +1331,7 @@ TEST(SharedNetwork6Test, unparse) { " },\n" " \"renew-timer\": 100,\n" " \"require-client-classes\": [ \"foo\" ],\n" - " \"reservation-mode\": \"all\"," + " \"reservation-modes\": {\"in-subnet\": true, \"out-of-pool\": true}," " \"subnet6\": [\n" " {\n" " \"id\": 1,\n"