]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1405] fixed unittests
authorRazvan Becheriu <razvan@isc.org>
Fri, 9 Oct 2020 18:41:55 +0000 (21:41 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 18 Nov 2020 13:55:22 +0000 (15:55 +0200)
24 files changed:
doc/examples/kea4/all-keys-netconf.json
doc/examples/kea4/all-keys.json
doc/examples/kea4/global-reservations.json
doc/examples/kea4/reservations.json
doc/examples/kea4/shared-network.json
doc/examples/kea6/all-keys-netconf.json
doc/examples/kea6/all-keys.json
doc/examples/kea6/global-reservations.json
doc/examples/kea6/reservations.json
doc/examples/kea6/shared-network.json
doc/sphinx/arm/dhcp4-srv.rst
doc/sphinx/arm/dhcp6-srv.rst
doc/sphinx/arm/hooks.rst
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp4/tests/host_unittest.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
src/lib/dhcpsrv/network.cc
src/lib/dhcpsrv/parsers/simple_parser4.cc
src/lib/dhcpsrv/parsers/simple_parser6.cc
src/lib/dhcpsrv/srv_config.cc
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc
src/lib/dhcpsrv/tests/shared_network_unittest.cc

index 9ab0f99951769fce23fce576bae0c9dc3e75fcfd..0972fadd249c0180fa85e0804264e0eb11946004 100644 (file)
                 // 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
                         // 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.
         // 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.
index 3a75c3259c6e386af9e67e0f459ae10661acc60f..8d4cb5fb51026a868059d8adac8f3643feda94e1 100644 (file)
                 // 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
                         // 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.
         // 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.
index d5bb5ef9f8d43ad714b7e0df06120a087f130535..cf4ce31e50da5df924b76dcdd91e9f4b021b1c05 100644 (file)
@@ -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.
index 4f1864f80538cc1e09266c5a4f74ec56ce55b481..eb7fbd55bc500e30b38e60af9bc97465275d05e0 100644 (file)
@@ -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": [
index 08c3bf2bfa4a99c184cb92f2fdaffd99c926e367..42885cd3d7d84b611a6a18aff7efe8a279ff867f 100644 (file)
@@ -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.
                     // 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
                     // 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
index 7585399fb69aab81816dad9a68ccd5cc19362784..563a6dd453fe3c668abea82137d4087da46f5dac 100644 (file)
                 // 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
                         // 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.
         // 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.
index 9482db752144d4f89dc733efd31da5596780d25d..46695e982323e5a82badb90aa9c6e2af24473ecd 100644 (file)
                 // 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
                         // 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.
         // 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.
index 53e253a8d96dd63bc8f78d9e6db285015f0d7f9e..6a11a40dde69bcb95123b5228c38c1011370cad8 100644 (file)
@@ -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.
index 5005b5100e4748c3dd230e4c2394b6f094ec95ad..decc673243f360ef81901dd7e73b2a0b3d397da7 100644 (file)
@@ -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" } ],
index 49f1c998eabe0e19e46db903736d0d08cca80543..8fc3464b78dae23d8616d728157f8a64780731f6 100644 (file)
@@ -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" } ],
                     // 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
index d8ce6e24536bd5899bef5f5e6519605f89a9987d..17c5e09962cfc45c4028eed045782e13fc4e638c 100644 (file)
@@ -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         |
index 269c9ca5e3a7b64c2defcc422cb230c47d3e5514..f5370603784f26c8684c44a5ec1841dcce4515de 100644 (file)
@@ -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        |
index 6f81132bc9e80b8949a67fdd0c38be00b9bcaa40..453c590f46d2919e2002f7b2be9e1f60ad767d62 100644 (file)
@@ -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": [
                    {
index 6900615e0360f0bc27f80dff36d888fcbdcd7d35..aa0ebf5d594b0a7eca50efe3d3216ea6a1218382 100644 (file)
@@ -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"
index 9f9f7f38a22443bc09e3ccb2d02a272ee60da886..4e246515a55d651933071fac8083d6d6f8962591 100644 (file)
@@ -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"
index 37651e7e2fb5c1bb85cf6e322cc0577c8afa5017..cc8ca4c88ea4afbe27cdbd4ea633d3fcfa7cab0a 100644 (file)
@@ -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"
index 614d07260dd189796bb18251a1e3ff4699490679..58e6f782293b0b56ed3c11637909d5e278af2b12 100644 (file)
@@ -204,25 +204,36 @@ Network::toElement() const {
     // Set reservation mode
     Optional<Network::HRMode> 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
index fe3a7059a2b5a8c648ce6d70bfbaec6d8ca181df..72a5a8cf70a3c24bd2f418d2c612429459a17616 100644 (file)
@@ -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 },
index 66780a697a81cc4ab62e40c1645fa6763b9735e3..190b8a58a7b11e03b4adfeb5e7ce7937ff3d37d1 100644 (file)
@@ -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 },
index d0c2646a7c1c079a3820308c59a7c3fb1f9c7a7b..814909bce5c8d40e40bbe95a5c6c0eca6d7cbd35 100644 (file)
@@ -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_);
index 62809c955ab93ecc1f0e79b094ddc13d8dfbf6be..944160f91a27f65ce6a71805d0981b6b7656909e 100644 (file)
@@ -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"
index 55419d4fc8d5b6422376575f0312d76f04b4fbff..add98d9e8521606574d061785a41ec4f9951af31 100644 (file)
@@ -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;
index f3d0b8f13d27c3543ba08e99f16df585742c2718..3ef856ea5bc54c7f5828cc89788666e3ee04dccb 100644 (file)
@@ -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"
                 "        }"
                 "    ]"
index a1f6c30e4cafd29a6d076eb2a20004b2aec27bd5..985edafd176bf10627ce310f340556862832a93d 100644 (file)
@@ -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"