]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[393-global-search-through-leases-by-mac-or-hostname-w-o-specifying-a-subnet-id]...
authorFrancis Dupont <fdupont@isc.org>
Wed, 16 Oct 2019 21:10:01 +0000 (23:10 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 25 Oct 2019 15:26:23 +0000 (17:26 +0200)
doc/sphinx/api-files.txt
doc/sphinx/api/lease4-get-by-client-id.json [new file with mode: 0644]
doc/sphinx/api/lease4-get-by-hostname.json [new file with mode: 0644]
doc/sphinx/api/lease4-get-by-hw-address.json [new file with mode: 0644]
doc/sphinx/api/lease6-get-by-duid.json [new file with mode: 0644]
doc/sphinx/api/lease6-get-by-hostname.json [new file with mode: 0644]
doc/sphinx/arm/hooks-lease-cmds.rst
src/hooks/dhcp/lease_cmds/lease_cmds.cc

index b358a0a93baf550026a89a31e33781b1c6ccf13b..248bea740321240fa117a5915214769822819677 100644 (file)
@@ -26,6 +26,9 @@ api/ha-sync.json
 api/lease4-add.json
 api/lease4-del.json
 api/lease4-get-all.json
+api/lease4-get-by-client-id.json
+api/lease4-get-by-hostname.json
+api/lease4-get-by-hw-address.json
 api/lease4-get.json
 api/lease4-update.json
 api/lease4-wipe.json
@@ -33,6 +36,8 @@ api/lease6-add.json
 api/lease6-bulk-apply.json
 api/lease6-del.json
 api/lease6-get-all.json
+api/lease6-get-by-duid.json
+api/lease6-get-by-hostname.json
 api/lease6-get.json
 api/lease6-update.json
 api/lease6-wipe.json
diff --git a/doc/sphinx/api/lease4-get-by-client-id.json b/doc/sphinx/api/lease4-get-by-client-id.json
new file mode 100644 (file)
index 0000000..a3a199c
--- /dev/null
@@ -0,0 +1,20 @@
+{
+    "avail": "1.7.1",
+    "brief": [
+        "This command retrieves all IPv4 leases with the specified client id."
+    ],
+    "cmd-syntax": [
+        "{",
+        "    \"command\": \"lease4-get-by-client-id\",",
+        "    \"arguments\": {",
+        "        \"client-id\": \"42:42:42:42:42:42:42:42\"",
+        "    }",
+        "}"
+    ],
+    "description": "See <xref linkend=\"command-lease4-get-by-client-id\"/>",
+    "hook": "lease_cmds",
+    "name": "lease4-get-by-client-id",
+    "support": [
+        "kea-dhcp4"
+    ]
+}
diff --git a/doc/sphinx/api/lease4-get-by-hostname.json b/doc/sphinx/api/lease4-get-by-hostname.json
new file mode 100644 (file)
index 0000000..33bb6f7
--- /dev/null
@@ -0,0 +1,20 @@
+{
+    "avail": "1.7.1",
+    "brief": [
+        "This command retrieves all IPv4 leases with the specified hostname."
+    ],
+    "cmd-syntax": [
+        "{",
+        "    \"command\": \"lease4-get-by-hostname\",",
+        "    \"arguments\": {",
+        "        \"hostname\": \"myhost.example.com.\"",
+        "    }",
+        "}"
+    ],
+    "description": "See <xref linkend=\"command-lease4-get-by-hostname\"/>",
+    "hook": "lease_cmds",
+    "name": "lease4-get-by-hostname",
+    "support": [
+        "kea-dhcp4"
+    ]
+}
diff --git a/doc/sphinx/api/lease4-get-by-hw-address.json b/doc/sphinx/api/lease4-get-by-hw-address.json
new file mode 100644 (file)
index 0000000..b864db8
--- /dev/null
@@ -0,0 +1,20 @@
+{
+    "avail": "1.7.1",
+    "brief": [
+        "This command retrieves all IPv4 leases with the specified hardware address."
+    ],
+    "cmd-syntax": [
+        "{",
+        "    \"command\": \"lease4-get-by-hw-address\",",
+        "    \"arguments\": {",
+        "        \"hw-address\": \"08:08:08:08:08:08\"",
+        "    }",
+        "}"
+    ],
+    "description": "See <xref linkend=\"command-lease4-get-by-hw-address\"/>",
+    "hook": "lease_cmds",
+    "name": "lease4-get-by-hw-address",
+    "support": [
+        "kea-dhcp4"
+    ]
+}
diff --git a/doc/sphinx/api/lease6-get-by-duid.json b/doc/sphinx/api/lease6-get-by-duid.json
new file mode 100644 (file)
index 0000000..2d30fec
--- /dev/null
@@ -0,0 +1,20 @@
+{
+    "avail": "1.7.1",
+    "brief": [
+        "This command retrieves all IPv6 leases with the specified hardware address."
+    ],
+    "cmd-syntax": [
+        "{",
+        "    \"command\": \"lease6-get-by-duid\",",
+        "    \"arguments\": {",
+        "        \"duid\": \"1a:1b:1c:1d:1e:1f:20:21:22:23:24\"",
+        "    }",
+        "}"
+    ],
+    "description": "See <xref linkend=\"command-lease6-get-by-duid\"/>",
+    "hook": "lease_cmds",
+    "name": "lease6-get-by-duid",
+    "support": [
+        "kea-dhcp6"
+    ]
+}
diff --git a/doc/sphinx/api/lease6-get-by-hostname.json b/doc/sphinx/api/lease6-get-by-hostname.json
new file mode 100644 (file)
index 0000000..2e894cf
--- /dev/null
@@ -0,0 +1,20 @@
+{
+    "avail": "1.7.1",
+    "brief": [
+        "This command retrieves all IPv6 leases with the specified hostname."
+    ],
+    "cmd-syntax": [
+        "{",
+        "    \"command\": \"lease6-get-by-hostname\",",
+        "    \"arguments\": {",
+        "        \"hostname\": \"myhost.example.com.\"",
+        "    }",
+        "}"
+    ],
+    "description": "See <xref linkend=\"command-lease6-get-by-hostname\"/>",
+    "hook": "lease_cmds",
+    "name": "lease6-get-by-hostname",
+    "support": [
+        "kea-dhcp6"
+    ]
+}
index 639388fae7557d42708713edaf39f62278dd3de3..070f7e366cef2bc06b2aa6e71174e13e36b7196c 100644 (file)
@@ -59,6 +59,20 @@ This library provides the following commands:
    of all IPv6 leases in the database. By iterating through the pages it
    is possible to retrieve all the leases.
 
+-  ``lease4-get-by-hw-address`` - return all IPv4 leases with the specified
+   hardware address.
+
+-  ``lease4-get-by-client-id`` - return all IPv4 leases with the specified
+   client id.
+
+-  ``lease6-get-by-duid`` - returns all IPv6 leases with the specified duid.
+
+-  ``lease4-get-by-hostname`` - return all IPv4 leases with the specified
+   hostname.
+
+-  ``lease6-get-by-hostname`` - return all IPv6 leases with the specified
+   hostname.
+
 -  ``lease4-del`` - deletes an IPv4 lease with the specified parameters.
 
 -  ``lease6-del`` - deletes an IPv6 lease with the specified parameters.
@@ -686,6 +700,50 @@ The client may assume that it has reached the last page when the
 includes the case when the ``count`` is equal to 0, meaning that no
 leases were found.
 
+.. _command-lease4-get-by-hw-address:
+
+.. _command-lease4-get-by-client-id:
+
+.. _command-lease6-get-by-duid:
+
+.. _command-lease4-get-by-hostname:
+
+.. _command-lease6-get-by-hostname:
+
+The lease4-get-by-*, lease6-get-by-* Commands
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``leaseX-get-by-Y`` can be used to query the lease database and
+retrieve all existing leases with a specified hardware address (IPv4
+only), client id IPv4 only), duid (IPv6 only) identifiers or hostname.
+
+An example ``lease4-get-by-hw-address`` command for getting IPv4 leases
+with a given hardware address is:
+
+::
+
+    {
+        "command": "lease4-get-by-hw-address",
+        "arguments": {
+            "hw-address": "08:08:08:08:08:08"
+        }
+    }
+
+An example of the ``lease6-get-by-hostname`` is:
+
+::
+
+    {
+        "command": "lease6-get-by-hostname",
+        "arguments": {
+            "hostname": "myhost.example.org"
+        }
+    }
+
+The by key is the only parameter. The returned response contains a detailed
+list of leases in the same format than ``leaseX-get-all``. This list can be
+empty and usually is never large.
+
 .. _command-lease4-del:
 
 .. _command-lease6-del:
index 7ded5be594c973daf2a348e83a19cfcb3719ac92..a2b5866340058e8ca922fab8fccdffa957f715e9 100644 (file)
@@ -800,9 +800,8 @@ LeaseCmdsImpl::leaseGetByHwAddressHandler(CalloutHandle& handle) {
         extractCommand(handle);
 
         // arguments must always be present
-        if (!cmd_args_) {
-            isc_throw(BadValue, "no parameters specified for the " << cmd_name_
-                      << " command");
+        if (!cmd_args_ || (cmd_args_->getType() != Element::map)) {
+            isc_throw(BadValue, "Command arguments missing or a not a map.");
         }
 
         // the hw-address parameter is mandatory.
@@ -851,9 +850,8 @@ LeaseCmdsImpl::leaseGetByClientIdHandler(CalloutHandle& handle) {
         extractCommand(handle);
 
         // arguments must always be present
-        if (!cmd_args_) {
-            isc_throw(BadValue, "no parameters specified for the " << cmd_name_
-                      << " command");
+        if (!cmd_args_ || (cmd_args_->getType() != Element::map)) {
+            isc_throw(BadValue, "Command arguments missing or a not a map.");
         }
 
         // the client-id parameter is mandatory.
@@ -902,9 +900,8 @@ LeaseCmdsImpl::leaseGetByDuidHandler(CalloutHandle& handle) {
         extractCommand(handle);
 
         // arguments must always be present
-        if (!cmd_args_) {
-            isc_throw(BadValue, "no parameters specified for the " << cmd_name_
-                      << " command");
+        if (!cmd_args_ || (cmd_args_->getType() != Element::map)) {
+            isc_throw(BadValue, "Command arguments missing or a not a map.");
         }
 
         // the duid parameter is mandatory.
@@ -955,9 +952,8 @@ LeaseCmdsImpl::leaseGetByHostnameHandler(CalloutHandle& handle) {
         v4 = (cmd_name_ == "lease4-get-by-hostname");
 
         // arguments must always be present
-        if (!cmd_args_) {
-            isc_throw(BadValue, "no parameters specified for the " << cmd_name_
-                      << " command");
+        if (!cmd_args_ || (cmd_args_->getType() != Element::map)) {
+            isc_throw(BadValue, "Command arguments missing or a not a map.");
         }
 
         // the hostname parameter is mandatory.