2023-06-06 13:30:39 +03:00
|
|
|
.. ischooklib:: libdhcp_class_cmds.so
|
2022-05-11 22:05:43 +00:00
|
|
|
.. _hooks-class-cmds:
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:30:39 +03:00
|
|
|
``libdhcp_class_cmds.so``: Class Commands
|
|
|
|
=========================================
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2022-06-13 15:53:14 +00:00
|
|
|
This hook library exposes
|
2019-06-06 18:25:46 +02:00
|
|
|
several control commands for manipulating client classes (part of the
|
|
|
|
Kea DHCP servers' configurations) without the need to restart those
|
|
|
|
servers. Using these commands it is possible to add, update, delete, and
|
2021-11-05 21:32:03 +00:00
|
|
|
list the client classes configured for a given server.
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-13 19:39:12 +03:00
|
|
|
.. note::
|
|
|
|
|
2025-02-12 13:31:51 +02:00
|
|
|
:ischooklib:`libdhcp_class_cmds.so` is part of the open source code and is
|
|
|
|
available to every Kea user.
|
|
|
|
It was previously available only to ISC customers with a paid support contract.
|
2023-06-13 19:39:12 +03:00
|
|
|
|
2019-07-01 14:20:05 -04:00
|
|
|
.. note::
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:43:11 +03:00
|
|
|
This library can only be loaded by the :iscman:`kea-dhcp4` or
|
|
|
|
:iscman:`kea-dhcp6` process.
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:33:44 +03:00
|
|
|
.. isccmd:: class-add
|
2019-06-06 18:25:46 +02:00
|
|
|
.. _command-class-add:
|
|
|
|
|
2021-11-05 21:32:03 +00:00
|
|
|
The ``class-add`` Command
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
The :isccmd:`class-add` command adds a new client class to the DHCP server
|
2019-06-06 18:25:46 +02:00
|
|
|
configuration. This class is appended at the end of the list of classes
|
2019-06-26 16:03:19 -04:00
|
|
|
used by the server and may depend on any of the already-configured
|
2019-06-06 18:25:46 +02:00
|
|
|
client classes.
|
|
|
|
|
|
|
|
The following example demonstrates how to add a new client class to the
|
|
|
|
DHCPv4 server configuration:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"command": "class-add",
|
|
|
|
"arguments": {
|
|
|
|
"client-classes": [
|
|
|
|
{
|
|
|
|
"name": "ipxe_efi_x64",
|
|
|
|
"test": "option[93].hex == 0x0009",
|
|
|
|
"next-server": "192.0.2.254",
|
|
|
|
"server-hostname": "hal9000",
|
|
|
|
"boot-file-name": "/dev/null"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Note that the ``client-classes`` parameter is a JSON list, but it allows
|
|
|
|
only a single client class to be present.
|
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
Here is the response to the :isccmd:`class-add` command in our example:
|
2019-06-06 18:25:46 +02:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"result": 0,
|
|
|
|
"text": "Class 'ipxe_efi_x64' added."
|
|
|
|
}
|
|
|
|
|
2023-06-06 13:33:44 +03:00
|
|
|
.. isccmd:: class-update
|
2019-06-06 18:25:46 +02:00
|
|
|
.. _command-class-update:
|
|
|
|
|
2021-11-05 21:32:03 +00:00
|
|
|
The ``class-update`` Command
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
The :isccmd:`class-update` command updates an existing client class in the
|
2019-06-06 18:25:46 +02:00
|
|
|
DHCP server configuration. If the client class with the given name
|
2019-06-26 16:03:19 -04:00
|
|
|
does not exist, the server returns the result code of 3, which means that
|
2019-06-06 18:25:46 +02:00
|
|
|
the server configuration is not modified and the client class does not
|
2023-06-06 13:43:28 +03:00
|
|
|
exist. The :isccmd:`class-add` command must be used instead to create the new
|
2019-06-06 18:25:46 +02:00
|
|
|
client class.
|
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
The :isccmd:`class-update` command has the same argument structure as the
|
|
|
|
:isccmd:`class-add` command:
|
2019-06-06 18:25:46 +02:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"command": "class-update",
|
|
|
|
"arguments": {
|
|
|
|
"client-classes": [
|
|
|
|
{
|
|
|
|
"name": "ipxe_efi_x64",
|
|
|
|
"test": "option[93].hex == 0x0017",
|
|
|
|
"next-server": "0.0.0.0",
|
|
|
|
"server-hostname": "xfce",
|
|
|
|
"boot-file-name": "/dev/null"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Here is the response for our example:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"result": 0,
|
|
|
|
"text": "Class 'ipxe_efi_x64' updated."
|
|
|
|
}
|
|
|
|
|
|
|
|
Any parameter of the client class can be modified with this command,
|
|
|
|
except ``name``. There is currently no way to rename the class, because
|
|
|
|
the class name is used as a key for searching the class to be updated.
|
|
|
|
To achieve a similar effect to renaming the class, an existing class can
|
2023-06-06 13:43:28 +03:00
|
|
|
be removed with the :isccmd:`class-del` command and then added again with a
|
|
|
|
different name using :isccmd:`class-add`. Note, however, that the class with
|
2019-06-06 18:25:46 +02:00
|
|
|
the new name will be added at the end of the list of configured classes.
|
|
|
|
|
2024-05-16 20:09:54 +00:00
|
|
|
As with other update commands, this command overwrites all the contents of an
|
2023-04-05 18:17:32 +03:00
|
|
|
entry. If the client class previously had a resource assigned to it, and the
|
2023-06-06 13:43:28 +03:00
|
|
|
:isccmd:`class-update` command is missing the resource, it is deleted from the server
|
2024-05-16 20:09:54 +00:00
|
|
|
configuration. If an incremental update of the class is desired, it can
|
|
|
|
be achieved by issuing a :isccmd:`class-get` to get the current state
|
|
|
|
of the client class, selecting the client class from the response, modifying it
|
2023-04-05 18:17:32 +03:00
|
|
|
to the required outcome, and then issuing the ``client-update`` command with the
|
|
|
|
resulting client class attached.
|
|
|
|
|
2023-06-06 13:33:44 +03:00
|
|
|
.. isccmd:: class-del
|
2019-06-06 18:25:46 +02:00
|
|
|
.. _command-class-del:
|
|
|
|
|
2021-11-05 21:32:03 +00:00
|
|
|
The ``class-del`` Command
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
2019-08-16 19:58:41 +02:00
|
|
|
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
The :isccmd:`class-del` command is used to remove a particular class from the server
|
2019-06-06 18:25:46 +02:00
|
|
|
configuration. The class to be removed is identified by name. The class
|
|
|
|
is not removed if there are other classes depending on it; to remove
|
|
|
|
such a class, the dependent classes must be removed first.
|
|
|
|
|
|
|
|
The following is a sample command removing the ``ipxe_efi_x64`` class:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"command": "class-del",
|
|
|
|
"arguments": {
|
2023-05-05 15:04:16 +03:00
|
|
|
"name": "ipxe_efi_x64"
|
2019-06-06 18:25:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
Here is the response to the :isccmd:`class-del` command in our example, when
|
2019-06-06 18:25:46 +02:00
|
|
|
the specified client class has been found:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"result": 0,
|
|
|
|
"text": "Class 'ipxe_efi_x64' deleted."
|
|
|
|
}
|
|
|
|
|
2019-07-16 14:35:04 -04:00
|
|
|
If the class does not exist, the result of 3 is returned.
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:33:44 +03:00
|
|
|
.. isccmd:: class-list
|
2019-06-06 18:25:46 +02:00
|
|
|
.. _command-class-list:
|
|
|
|
|
2021-11-05 21:32:03 +00:00
|
|
|
The ``class-list`` Command
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2019-08-16 19:58:41 +02:00
|
|
|
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
:isccmd:`class-list` is used to retrieve a list of all client classes. This
|
2019-06-06 18:25:46 +02:00
|
|
|
command includes no arguments:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"command": "class-list"
|
|
|
|
}
|
|
|
|
|
|
|
|
Here is the response of the server in our example, including the list of
|
|
|
|
client classes:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"result": 0,
|
|
|
|
"text": "2 classes found",
|
|
|
|
"arguments": {
|
|
|
|
"client-classes": [
|
|
|
|
{
|
|
|
|
"name": "ipxe_efi_x64"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "pxeclient"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Note that the returned list does not contain full class definitions, but
|
|
|
|
merely class names. To retrieve full class information, the
|
2023-06-06 13:43:28 +03:00
|
|
|
:isccmd:`class-get` command should be used.
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:33:44 +03:00
|
|
|
.. isccmd:: class-get
|
2019-06-06 18:25:46 +02:00
|
|
|
.. _command-class-get:
|
|
|
|
|
2021-11-05 21:32:03 +00:00
|
|
|
The ``class-get`` Command
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
:isccmd:`class-get` is used to retrieve detailed information about a specified
|
2019-06-06 18:25:46 +02:00
|
|
|
class. The command structure is very simple:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"command": "class-get",
|
|
|
|
"arguments": {
|
|
|
|
"name": "pxeclient"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
If the class with the specified name does not exist, the status code of
|
|
|
|
3 is returned. If the specified client class exists, the class details
|
|
|
|
are returned in the following format:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"result": 0,
|
|
|
|
"text": "Class 'pxeclient' definition returned",
|
|
|
|
"arguments": {
|
|
|
|
"client-classes": [
|
|
|
|
{
|
|
|
|
"name": "pxeclient",
|
2024-10-18 12:02:04 -04:00
|
|
|
"only-in-additional-list": true,
|
2019-06-06 18:25:46 +02:00
|
|
|
"test": "option[vendor-class-identifier].text == 'PXEClient'",
|
|
|
|
"option-def": [
|
|
|
|
{
|
|
|
|
"name": "configfile",
|
|
|
|
"code": 209,
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"option-data": [ ],
|
|
|
|
"next-server": "0.0.0.0",
|
|
|
|
"server-hostname": "xfce",
|
|
|
|
"boot-file-name": "/dev/null"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Note that the example above is DHCPv4-specific; the last three
|
|
|
|
parameters are only returned by the DHCPv4 server and are never returned
|
|
|
|
by the DHCPv6 server. Also, some of the parameters provided in this
|
|
|
|
example may not be returned if they are not specified for the class.
|
2024-10-18 12:02:04 -04:00
|
|
|
Specifically, ``only-in-additional-list``, ``test``, and ``option-def`` are not
|
2019-06-06 18:25:46 +02:00
|
|
|
returned if they are not specified for the class.
|
2024-10-18 12:02:04 -04:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
As of Kea version 2.7.4, ``only-if-required`` has been replaced with
|
|
|
|
``only-in-additional-list`` and deprecated. In order to allow users time
|
|
|
|
to migrate class commands will still accept it as input but translate it
|
|
|
|
to ``only-in-additional-list`` on output. Eventually support for the
|
2024-10-25 21:58:16 +03:00
|
|
|
old name will be removed.
|