2019-06-06 18:25:46 +02:00
|
|
|
.. _class-cmds-library:
|
|
|
|
|
2021-11-05 21:32:03 +00:00
|
|
|
``class_cmds``: Class Commands
|
|
|
|
==============================
|
2019-06-06 18:25:46 +02:00
|
|
|
|
|
|
|
This section describes the Class Commands hooks library, which exposes
|
|
|
|
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
|
|
|
|
2019-07-01 14:20:05 -04:00
|
|
|
.. note::
|
2019-06-06 18:25:46 +02:00
|
|
|
|
2019-06-26 16:03:19 -04:00
|
|
|
This library may only be loaded by the ``kea-dhcp4`` or
|
2019-06-06 18:25:46 +02:00
|
|
|
``kea-dhcp6`` process.
|
|
|
|
|
2019-06-26 16:03:19 -04:00
|
|
|
The Class Commands hooks library is currently available only to ISC
|
|
|
|
customers with a paid support contract.
|
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
|
|
|
|
|
|
|
The ``class-add`` command adds a new client class to the DHCP server
|
|
|
|
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.
|
|
|
|
|
|
|
|
Here is the response to the ``class-add`` command in our example:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"result": 0,
|
|
|
|
"text": "Class 'ipxe_efi_x64' added."
|
|
|
|
}
|
|
|
|
|
|
|
|
.. _command-class-update:
|
|
|
|
|
2021-11-05 21:32:03 +00:00
|
|
|
The ``class-update`` Command
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2019-06-06 18:25:46 +02:00
|
|
|
|
|
|
|
The ``class-update`` command updates an existing client class in the
|
|
|
|
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
|
|
|
|
exist. The ``class-add`` command must be used instead to create the new
|
|
|
|
client class.
|
|
|
|
|
|
|
|
The ``class-update`` command has the same argument structure as the
|
|
|
|
``class-add`` command:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
{
|
|
|
|
"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
|
|
|
|
be removed with the ``class-del`` command and then added again with a
|
|
|
|
different name using ``class-add``. Note, however, that the class with
|
|
|
|
the new name will be added at the end of the list of configured classes.
|
|
|
|
|
|
|
|
.. _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
|
|
|
|
2019-06-26 16:03:19 -04:00
|
|
|
The ``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": {
|
|
|
|
{
|
|
|
|
"name": "ipxe_efi_x64"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Here is the response to the ``class-del`` command in our example, when
|
|
|
|
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
|
|
|
|
|
|
|
.. _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
|
|
|
|
|
|
|
``class-list`` is used to retrieve a list of all client classes. This
|
|
|
|
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
|
|
|
|
``class-get`` command should be used.
|
|
|
|
|
|
|
|
.. _command-class-get:
|
|
|
|
|
2021-11-05 21:32:03 +00:00
|
|
|
The ``class-get`` Command
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
2019-06-06 18:25:46 +02:00
|
|
|
|
|
|
|
``class-get`` is used to retrieve detailed information about a specified
|
|
|
|
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",
|
|
|
|
"only-if-required": true,
|
|
|
|
"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.
|
|
|
|
Specifically, ``only-if-required``, ``test``, and ``option-def`` are not
|
|
|
|
returned if they are not specified for the class.
|