]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2827] addressed comments
authorRazvan Becheriu <razvan@isc.org>
Thu, 11 May 2023 10:13:21 +0000 (13:13 +0300)
committerRazvan Becheriu <razvan@isc.org>
Thu, 11 May 2023 11:01:29 +0000 (14:01 +0300)
doc/sphinx/arm/dhcp4-srv.rst
doc/sphinx/arm/dhcp6-srv.rst
tools/check-for-json-errors-in-doc.sh

index 9213236b7bb4bbbb9eea2d620adab3cda4acdf7f..30afb478eac9e0999e1c0fd1825cd5eee7080a2a 100644 (file)
@@ -3012,13 +3012,15 @@ configuration looks like this:
        "subnet4": [
            {
                "subnet": "192.0.2.0/24",
-               "option-data": [ {
+               "option-data": [
+               {
                    "name": "domain-name-servers",
                    "code": 6,
                    "data": "192.0.2.200,192.0.2.201",
                    "csv-format": true,
                    "space": "dhcp4"
-               } ]
+               }
+               ]
            }
        ]
    }
@@ -4176,23 +4178,29 @@ ISC tested the following configuration:
 
        "valid-lifetime": 4000,
 
-       "subnet4": [ {
+       "subnet4": [
+       {
            "subnet": "10.10.10.0/24",
            "4o6-interface": "eno33554984",
            "4o6-subnet": "2001:db8:1:1::/64",
            "pools": [ { "pool": "10.10.10.100 - 10.10.10.199" } ]
-       } ],
+       }
+       ],
 
        "dhcp4o6-port": 6767,
 
-       "loggers": [ {
+       "loggers": [
+       {
            "name": "kea-dhcp4",
-           "output_options": [ {
+           "output_options": [
+           {
                "output": "/tmp/kea-dhcp4.log"
-           } ],
+           }
+           ],
            "severity": "DEBUG",
            "debuglevel": 0
-       } ]
+       }
+       ]
    }
 
    }
@@ -4821,7 +4829,8 @@ configuration:
 .. code-block:: json
 
        {
-           "subnet4": [ {
+           "subnet4": [
+           {
                "subnet": "10.0.0.0/24",
                "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ],
                "ddns-qualifying-suffix": "example.isc.org.",
@@ -4831,7 +4840,8 @@ configuration:
                     "hostname": "alice-laptop"
                   }
                ]
-            }],
+           }
+           ],
            "dhcp-ddns": {
                "enable-updates": true
            }
@@ -4848,7 +4858,8 @@ different clients with different domain names:
 .. code-block:: json
 
        {
-           "subnet4": [ {
+           "subnet4": [
+           {
                "subnet": "10.0.0.0/24",
                "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ],
                "reservations": [
@@ -4860,9 +4871,9 @@ different clients with different domain names:
                     "hw-address": "12:34:56:78:99:AA",
                     "hostname": "mark-desktop.example.org."
                   }
-
                ]
-            }],
+           }
+           ],
            "dhcp-ddns": {
                "enable-updates": true
            }
@@ -4888,7 +4899,8 @@ example demonstrates how standard options can be defined:
 ::
 
    {
-       "subnet4": [ {
+       "subnet4": [
+       {
            "reservations": [
            {
                "hw-address": "aa:bb:cc:dd:ee:ff",
@@ -4901,9 +4913,12 @@ example demonstrates how standard options can be defined:
                {
                    "name": "log-servers",
                    "data": "10.1.1.200,10.1.1.201"
-               } ]
-           } ]
-       } ]
+               }
+               ]
+           }
+           ]
+       }
+       ]
    }
 
 Vendor-specific options can be reserved in a similar manner:
@@ -4911,7 +4926,8 @@ Vendor-specific options can be reserved in a similar manner:
 ::
 
    {
-       "subnet4": [ {
+       "subnet4": [
+       {
            "reservations": [
            {
                "hw-address": "aa:bb:cc:dd:ee:ff",
@@ -4925,9 +4941,12 @@ Vendor-specific options can be reserved in a similar manner:
                    "name": "tftp-servers",
                    "space": "vendor-4491",
                    "data": "10.1.1.202,10.1.1.203"
-               } ]
-           } ]
-       } ]
+               }
+               ]
+           }
+           ]
+       }
+       ]
    }
 
 Options defined at the host level have the highest priority. In other words,
@@ -4951,15 +4970,18 @@ message fields:
 ::
 
    {
-       "subnet4": [ {
+       "subnet4": [
+       {
            "reservations": [
            {
                "hw-address": "aa:bb:cc:dd:ee:ff",
                "next-server": "10.1.1.2",
                "server-hostname": "server-hostname.example.org",
                "boot-file-name": "/tmp/bootfile.efi"
-           } ]
-       } ]
+           }
+           ]
+       }
+       ]
    }
 
 Note that those parameters can be specified in combination with other
@@ -5005,7 +5027,8 @@ to them.
           ]
        }
        ],
-       "subnet4": [ {
+       "subnet4": [
+       {
            "subnet": "10.0.0.0/24",
            "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ],
            "reservations": [
@@ -5016,7 +5039,8 @@ to them.
 
            }
            ]
-       } ]
+       }
+       ]
     }
 
 In some cases the host reservations can be used in conjunction with client
@@ -5520,7 +5544,8 @@ following can be used:
        }
        ],
        "valid-lifetime": 600,
-       "subnet4": [ {
+       "subnet4": [
+       {
            "subnet": "10.0.0.0/24",
            # It is replaced by the "reservations-global",
            # "reservations-in-subnet", and "reservations-out-of-pool"
@@ -5535,7 +5560,8 @@ following can be used:
            # is false.
            # "reservations-out-of-pool": false,
            "pools": [ { "pool": "10.0.0.10-10.0.0.100" } ]
-       } ]
+       }
+       ]
    }
 
 When using database backends, the global host reservations are
@@ -5580,10 +5606,12 @@ within the subnet as follows:
         "subnet4": [
             {
                 "subnet": "192.0.2.0/24",
-                "reservations": [{
-                    "hw-address": "aa:bb:cc:dd:ee:fe",
-                    "client-classes": [ "reserved_class" ]
-                 }],
+                "reservations": [
+                    {
+                        "hw-address": "aa:bb:cc:dd:ee:fe",
+                        "client-classes": [ "reserved_class" ]
+                    }
+                ],
                 "pools": [
                     {
                         "pool": "192.0.2.10-192.0.2.20",
@@ -5632,10 +5660,12 @@ following example:
                 "test": "not member('reserved_class')"
             }
         ],
-        "reservations": [{
-            "hw-address": "aa:bb:cc:dd:ee:fe",
-            "client-classes": [ "reserved_class" ]
-        }],
+        "reservations": [
+            {
+                "hw-address": "aa:bb:cc:dd:ee:fe",
+                "client-classes": [ "reserved_class" ]
+            }
+        ],
         # It is replaced by the "reservations-global",
         # "reservations-in-subnet", and "reservations-out-of-pool" parameters.
         # Specify if the server should look up global reservations.
@@ -5647,7 +5677,8 @@ following example:
         # is false, but if specified, it is inherited by "shared-networks"
         # and "subnet4" levels.
         # "reservations-out-of-pool": false,
-        "shared-networks": [{
+        "shared-networks": [
+            {
             "subnet4": [
                 {
                     "subnet": "192.0.2.0/24",
@@ -5668,7 +5699,8 @@ following example:
                     ]
                 }
             ]
-        }]
+            }
+        ]
     }
 
 This is similar to the example described in
@@ -5952,7 +5984,8 @@ introduced:
 
    {
    "Dhcp4": {
-       "shared-networks": [ {
+       "shared-networks": [
+           {
                # Name of the shared network. It may be an arbitrary string
                # and it must be unique among all shared networks.
                "name": "my-secret-lair-level-1",
@@ -5974,7 +6007,8 @@ introduced:
                        "pools": [ { "pool":  "192.0.2.100 - 192.0.2.199" } ]
                    }
                ]
-       } ],
+           }
+       ],
        # end of shared-networks
 
        # It is likely that in the network there will be a mix of regular,
@@ -6026,10 +6060,12 @@ then override its value in the subnet scope. For example:
 
            # This option is made available to all subnets in this shared
            # network.
-           "option-data": [ {
+           "option-data": [
+           {
                "name": "log-servers",
                "data": "1.2.3.4"
-           } ],
+           }
+           ],
 
            "subnet4": [
                {
@@ -7266,13 +7302,16 @@ of LED devices could be configured in the following way:
 ::
 
    "Dhcp4": {
-       "subnet4": [{
+       "subnet4": [
+           {
            "subnet": "192.0.2.0/24",
-           "pools": [{
+           "pools": [
+           {
                "pool": "192.0.2.10 - 192.0.2.20",
                # This is pool specific user context
                "user-context": { "color": "red" }
-           } ],
+           }
+           ],
 
            # This is a subnet-specific user context. Any type
            # of information can be entered here as long as it is valid JSON.
@@ -7284,7 +7323,8 @@ of LED devices could be configured in the following way:
                "devices-registered": 42,
                "billing": false
            }
-       } ]
+       }
+       ]
    }
 
 Kea does not interpret or use the user-context information; it simply
@@ -7587,21 +7627,25 @@ database:
      "Dhcp4": {
        "server-tag": "my DHCPv4 server",
        "config-control": {
-           "config-databases": [{
+           "config-databases": [
+           {
                "type": "mysql",
                "name": "kea",
                "user": "kea",
                "password": "kea",
                "host": "192.0.2.1",
                "port": 3302
-           }],
+           }
+           ],
            "config-fetch-wait-time": 20
        },
-       "hooks-libraries": [{
+       "hooks-libraries": [
+       {
            "library": "/usr/local/lib/kea/hooks/libdhcp_mysql_cb.so"
        }, {
            "library": "/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so"
-       }]
+       }
+       ]
      }
    }
 
@@ -7624,21 +7668,25 @@ The following snippet illustrates the use of a PostgreSQL database:
      "Dhcp4": {
        "server-tag": "my DHCPv4 server",
        "config-control": {
-           "config-databases": [{
+           "config-databases": [
+           {
                "type": "postgresql",
                "name": "kea",
                "user": "kea",
                "password": "kea",
                "host": "192.0.2.1",
                "port": 5432
-           }],
+           }
+           ],
            "config-fetch-wait-time": 20
        },
-       "hooks-libraries": [{
+       "hooks-libraries": [
+       {
            "library": "/usr/local/lib/kea/hooks/libdhcp_pgsql_cb.so"
        }, {
            "library": "/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so"
-       }]
+       }
+       ]
      }
    }
 
index 06d97078d5c8756ff0fb1d6fd8b90a1ae25188ff..06197d469b5d70ed8146381af58052ab5c28fb75 100644 (file)
@@ -3666,7 +3666,8 @@ pretty-printed for clarity):
                 "options": "0x00250006010203040506003500086464646464646464",
                 "remote-id": "010203040506",
                 "relay-id": "6464646464646464"
-            }]
+            }
+            ]
         }
     }
 
@@ -4814,10 +4815,12 @@ within the subnet as follows:
         "subnet6": [
             {
                 "subnet": "2001:db8:1::/64",
-                "reservations": [{
-                    "hw-address": "aa:bb:cc:dd:ee:fe",
-                    "client-classes": [ "reserved_class" ]
-                 }],
+                "reservations": [
+                    {
+                        "hw-address": "aa:bb:cc:dd:ee:fe",
+                        "client-classes": [ "reserved_class" ]
+                    }
+                ],
                 "pools": [
                     {
                         "pool": "2001:db8:1::10-2001:db8:1::20",
@@ -4866,10 +4869,12 @@ following example:
                 "test": "not member('reserved_class')"
             }
         ],
-        "reservations": [{
-            "hw-address": "aa:bb:cc:dd:ee:fe",
-            "client-classes": [ "reserved_class" ]
-        }],
+        "reservations": [
+            {
+                "hw-address": "aa:bb:cc:dd:ee:fe",
+                "client-classes": [ "reserved_class" ]
+            }
+        ],
         # It is replaced by the "reservations-global",
         # "reservations-in-subnet", and "reservations-out-of-pool" parameters.
         # Specify if the server should look up global reservations.
@@ -4881,7 +4886,8 @@ following example:
         # is false, but if specified, it is inherited by "shared-networks"
         # and "subnet6" levels.
         # "reservations-out-of-pool": false,
-        "shared-networks": [{
+        "shared-networks": [
+            {
             "subnet6": [
                 {
                     "subnet": "2001:db8:1::/64",
@@ -4902,7 +4908,8 @@ following example:
                     ]
                 }
             ]
-        }]
+            }
+        ]
     }
 
 This is similar to the example described in the
@@ -5184,7 +5191,8 @@ introduced:
 
    {
    "Dhcp6": {
-       "shared-networks": [ {
+       "shared-networks": [
+           {
            # Name of the shared network. It may be an arbitrary string
            # and it must be unique among all shared networks.
            "name": "ipv6-lab-1",
@@ -5202,14 +5210,15 @@ introduced:
            "subnet6": [
                {
                    "subnet": "2001:db8::/48",
-                   "pools": [{ "pool":  "2001:db8::1 - 2001:db8::ffff" }]
+                   "pools": [ { "pool":  "2001:db8::1 - 2001:db8::ffff" } ]
                },
                {
                    "subnet": "3ffe:ffe::/64",
-                   "pools": [{ "pool":  "3ffe:ffe::/64" }]
+                   "pools": [ { "pool":  "3ffe:ffe::/64" } ]
                }
            ]
-       } ],
+           }
+       ],
        # end of shared-networks
 
        # It is likely that in the network there will be a mix of regular,
@@ -5220,7 +5229,7 @@ introduced:
        "subnet6": [
            {
                "subnet": "2001:db9::/48",
-               "pools": [{ "pool":  "2001:db9::/64" }],
+               "pools": [ { "pool":  "2001:db9::/64" } ],
                "relay": {
                    "ip-addresses": [ "2001:db8:1:2::1" ]
                }
index 91704b877d09d34e33cc4f06a8e2b8c9f556c68b..49f40508c8cb1fcba976fff5258844dc5ed8aa12 100755 (executable)
@@ -1,34 +1,46 @@
 #!/bin/bash
-work_file=`mktemp`
-for file in `find ./ | grep -v "\.git" | grep -v "_build" | grep -v "\/man\/" | grep "\.rst\|\.json" | sort`; do
+# Change directory to the root of the repository.
+script_path=$(cd "$(dirname "${0}")" && pwd)
+cd "${script_path}/.."
+# Parse parameters.
+if test ${#} -gt 0; then
+  files="${*}"
+else
+  files='doc src'
+fi
+
+# Get the files.
+files=$(find ${files} -type f \( -name '*.rst' -or -name '*.json' \) -and -not -path '/_build/*' -and -not -path '/man/*' | sort)
+work_file=$(mktemp)
+for file in $files; do
        json=0
        comment=0
        line_num=0
        echo "processing: $file"
-       while IFS= read line; do
+       while IFS= read -r line; do
                line_num=$((line_num+1))
-               if [ $comment -eq 0 -a $json -eq 0 -a `echo "$line" | grep -e "^[A-Za-z]+\|^\s*\\\`" | wc -l` -eq 1 ]; then
+               if [ $comment -eq 0 -a $json -eq 0 -a $(echo "$line" | grep "^[A-Za-z]+\|^\s*\`" | wc -l) -eq 1 ]; then
                        # ignore line if it starts with 'A-Za-z' or spaces followed by '`'
                        continue
-               elif [ $comment -eq 0 -a `echo "$line" | grep -e "\/\*" | grep -v -e "\*\/" | wc -l` -eq 1 ]; then
+               elif [ $comment -eq 0 -a $(echo "$line" | grep "/\*" | grep -v "\*/" | wc -l) -eq 1 ]; then
                        # if the line contains /* and it does not contain */ on the same line
                        comment=1
                        echo "" >> $work_file
                        continue
-               elif [ $comment -eq 1 -a `echo "$line" | grep "\*\/" | wc -l` -eq 1 ]; then
+               elif [ $comment -eq 1 -a $(echo "$line" | grep "\*/" | wc -l) -eq 1 ]; then
                        # if the line contains */
                        comment=0
                        echo "" >> $work_file
                        continue
-               elif [ $comment -eq 0 -a $json -eq 0 -a `echo "$line" | grep "^\s*{\|^\s*\".*{" | grep -v "}" | grep -v "key\|pre" | wc -l` -eq 1 ]; then
-                       # if this is not a commend and the line starts with spaces followed by '{' or by '"' followed by "{"
+               elif [ $comment -eq 0 -a $json -eq 0 -a $(echo "$line" | grep "^\s*{\|^\s*\".*{" | grep -v "}" | grep -v "key\|pre" | wc -l) -eq 1 ]; then
+                       # if this is not a comment and the line starts with spaces followed by '{' or by '"' followed by "{"
                        # ignore dns config:
                        #      key "key.four.example.com." {
                        #          algorithm hmac-sha224;
                        #          secret "bZEG7Ow8OgAUPfLWV3aAUQ==";
                        #      };
                        # ignore detailed html:
-                       #                       .. raw:: html
+                       #    .. raw:: html
                        #    <details><summary>Expand here!</summary>
                        #    <pre>{
                        #    ...
@@ -36,9 +48,9 @@ for file in `find ./ | grep -v "\.git" | grep -v "_build" | grep -v "\/man\/" |
                        #    </details><br>
                        json=1
                        # ignore any map name before top level map
-                       line=`echo "$line" | sed "s/.*{/{/g"`
+                       line=$(echo "$line" | sed "s/.*{/{/g")
                        echo "" > $work_file
-               elif [ $comment -eq 0 -a $json -eq 1 -a `echo "$line" | grep -e "^\s*[A-Za-z]\|^\s*\\\`" | wc -l` -eq 1 ]; then
+               elif [ $comment -eq 0 -a $json -eq 1 -a $(echo "$line" | grep "^\s*[A-Za-z]\|^\s*\`" | wc -l) -eq 1 ]; then
                        # if the line is not a comment and the line starts with spaces followed by 'A-Za-z' or followed by "`" and the parser is processing a json structure
                        json=0
                        cat $work_file | jq . > /dev/null
@@ -51,7 +63,7 @@ for file in `find ./ | grep -v "\.git" | grep -v "_build" | grep -v "\/man\/" |
                        fi
                fi
                if [ $comment -eq 0 -a $json -eq 1 ]; then
-                       if [ `echo "$line" | grep -e "^\s*\.\.\s" | wc -l` -eq 1 ]; then
+                       if [ $(echo "$line" | grep "^\s*\.\.\s" | wc -l) -eq 1 ]; then
                                echo "" >> $work_file
                        else
                                        # if file is .json the following replace in line are done:
@@ -65,7 +77,7 @@ for file in `find ./ | grep -v "\.git" | grep -v "_build" | grep -v "\/man\/" |
                                        # 8. replace ', ... ' with ' '
                                        # 9. replace '   <DATA>' with '   "placeholder": "value"'
                                        # 10. replace ' <DATA>' with ' "placeholder"'
-                               if [ `echo "$file" | grep "\.json" | wc -l` -eq 0 ]; then
+                               if [ $(echo "$file" | grep "\.json" | wc -l) -eq 0 ]; then
                                        echo "$line" | cut -d "#" -f 1 | sed "s/\/\/ .*//g" | sed "s/<?.*?>//g" | sed "s/\[ <\([-A-Za-z0-9 ]*\)> \]/\[ \"<\1>\" \]/g" | sed "s/ <\(.*\)>:/ \"<\1>\":/g" | sed "s/: <\(.*\)>/: \"<\1>\"/g" | sed "s/   \.\.\./   \"placeholder\": \"value\"/g" | sed "s/, \.\.\. / /g" | sed "s/   <\(.*\)>/   \"placeholder\": \"value\"/g" | sed "s/ <\(.*\)>/ \"placeholder\"/g" >> $work_file
                                else
                                        # if file is .rst the following replace in line are done: