|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
namespace KeaBundle\Services;
|
|
|
|
|
|
-use IPv4Bundle\Entity\Host;
|
|
|
+use IPv4Bundle\Utils\HostStatus;
|
|
|
use KeaBundle\Interfaces\KeaConfigInterface;
|
|
|
|
|
|
class BaseKea implements KeaConfigInterface
|
|
@@ -66,10 +66,27 @@ class BaseKea implements KeaConfigInterface
|
|
|
'pool' => $pool->getFirstIp() . ' - ' . $pool->getLastIp(),
|
|
|
];
|
|
|
}
|
|
|
- $this->subnet4[] = [
|
|
|
+
|
|
|
+ $hostType = $subnet->getAllowedHostType();
|
|
|
+ $client_class = '';
|
|
|
+ if ($hostType) {
|
|
|
+ $client_class = $hostType->getShortname();
|
|
|
+ }
|
|
|
+ if ($subnet->getStatus() != HostStatus::STATE_NONE && $subnet->getStatus() != '') {
|
|
|
+ if ($client_class != '') {
|
|
|
+ $client_class .= '-';
|
|
|
+ }
|
|
|
+ $client_class .= $subnet->getStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ $subnetConf = [
|
|
|
'subnet' => $subnet->getAddress(),
|
|
|
'pools' => $pools,
|
|
|
];
|
|
|
+ if ($client_class != '') {
|
|
|
+ $subnetConf['client-class'] = $client_class;
|
|
|
+ }
|
|
|
+ $this->subnet4[] = $subnetConf;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -102,22 +119,17 @@ class BaseKea implements KeaConfigInterface
|
|
|
|
|
|
$remote_id_map = isset($dhcpModelParams['remote-id-map']) ? $dhcpModelParams['remote-id-map'] : null;
|
|
|
if ($remote_id_map) {
|
|
|
- $active = [];
|
|
|
- $suspended = [];
|
|
|
+ $hostConfig = [];
|
|
|
foreach ($hosts as $host) {
|
|
|
$mac = $host->getMac();
|
|
|
$state = $host->getState();
|
|
|
- if ($state == Host::STATE_ACTIVE) {
|
|
|
- $active[] = $mac;
|
|
|
- } elseif ($state == Host::STATE_SUSPENDED) {
|
|
|
- $suspended[] = $mac;
|
|
|
- }
|
|
|
- }
|
|
|
+ $shortname = $host->getHostType()->getShortname();
|
|
|
|
|
|
- $hook['parameters']['remote-id-map'] = [
|
|
|
- 'active' => $active,
|
|
|
- 'suspended' => $suspended,
|
|
|
- ];
|
|
|
+ $client_class = $state != HostStatus::STATE_NONE ? $state : $shortname;
|
|
|
+
|
|
|
+ $hostConfig[$client_class][] = $mac;
|
|
|
+ }
|
|
|
+ $hook['parameters']['remote-id-map'] = $hostConfig;
|
|
|
}
|
|
|
|
|
|
$this->hooks_libraries[] = $hook;
|