|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
namespace KeaBundle\Services;
|
|
|
|
|
|
-use IPv4Bundle\Entity\Host;
|
|
|
+use IPv4Bundle\Utils\HostStatus;
|
|
|
use KeaBundle\Interfaces\KeaConfigInterface;
|
|
|
|
|
|
class BaseKea implements KeaConfigInterface
|
|
@@ -18,6 +18,11 @@ class BaseKea implements KeaConfigInterface
|
|
|
*/
|
|
|
private $hooks_libraries = [];
|
|
|
|
|
|
+ /**
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ private $interfaces_config = [];
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @param array $data
|
|
@@ -43,6 +48,7 @@ class BaseKea implements KeaConfigInterface
|
|
|
'lease-database' =>$this->leaseDatabaseConfig(),
|
|
|
'subnet4' => $this->subnet4,
|
|
|
'hooks-libraries' => $this->hooks_libraries,
|
|
|
+ 'interfaces-config' => $this->getInterfacesConfig(),
|
|
|
],
|
|
|
'Logging' => $this->loggingConfig(),
|
|
|
))], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
|
@@ -60,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;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -96,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;
|
|
@@ -144,7 +162,7 @@ class BaseKea implements KeaConfigInterface
|
|
|
/**
|
|
|
* @return array
|
|
|
*/
|
|
|
- private function controlSocketConfig()
|
|
|
+ private function controlSocketConfig()
|
|
|
{
|
|
|
/* "control-socket": {"socket-name": "\/tmp\/kea-dhcp4-ctrl.sock","socket-type": "unix"} */
|
|
|
return array(
|
|
@@ -156,14 +174,21 @@ class BaseKea implements KeaConfigInterface
|
|
|
/**
|
|
|
* @return array
|
|
|
*/
|
|
|
- private function leaseDatabaseConfig()
|
|
|
+ private function leaseDatabaseConfig()
|
|
|
{
|
|
|
/* "lease-database": {"lfc-interval": 3600,"type": "memfile"} */
|
|
|
return array(
|
|
|
'lfc-interval' => 3600,
|
|
|
'type' => 'memfile'
|
|
|
);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ private function getInterfacesConfig()
|
|
|
+ {
|
|
|
+ return ['interfaces' => ['*']];
|
|
|
}
|
|
|
|
|
|
}
|