|
@@ -196,45 +196,49 @@ class BaseKea implements KeaConfigInterface
|
|
|
$dhcp = $data['dhcp'];
|
|
|
$hosts = $data['hosts'];
|
|
|
|
|
|
- $hook = [
|
|
|
- 'library' => $data['library'],
|
|
|
- ];
|
|
|
-
|
|
|
- $dhcpModelParams = $dhcp && $dhcp->getDhcpModel() ? $dhcp->getDhcpModel()->getData('parameters') : null;
|
|
|
-
|
|
|
- $option122 = isset($dhcpModelParams['option122']) ? $dhcpModelParams['option122'] : null;
|
|
|
- $ip = isset($dhcpModelParams['ip']) ? $dhcpModelParams['ip'] : null;
|
|
|
- if ($option122 && $ip) {
|
|
|
- $macs = [];
|
|
|
- foreach ($hosts as $host) {
|
|
|
- if ($host->getMac() != '' && $host->getMtaEnabled() == true) {
|
|
|
- $macs[] = $host->getMac();
|
|
|
+ if ($hosts) {
|
|
|
+ $hook = [
|
|
|
+ 'library' => $data['library'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $dhcpModelParams = $dhcp && $dhcp->getDhcpModel() ? $dhcp->getDhcpModel()->getData('parameters') : null;
|
|
|
+
|
|
|
+ $option122 = isset($dhcpModelParams['option122']) ? $dhcpModelParams['option122'] : null;
|
|
|
+ $ip = isset($dhcpModelParams['ip']) ? $dhcpModelParams['ip'] : null;
|
|
|
+ if ($option122 && $ip) {
|
|
|
+ $macs = [];
|
|
|
+ foreach ($hosts as $host) {
|
|
|
+ if ($host->getMac() != '' && $host->getMtaEnabled() == true) {
|
|
|
+ $macs[] = $host->getMac();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($macs)) {
|
|
|
+ $hook['parameters']['option122'] = [
|
|
|
+ $ip => $macs
|
|
|
+ ];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- $hook['parameters']['option122'] = [
|
|
|
- $ip => $macs
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- $remote_id_map = isset($dhcpModelParams['remote-id-map']) ? $dhcpModelParams['remote-id-map'] : null;
|
|
|
- if ($remote_id_map) {
|
|
|
- $hostConfig = [];
|
|
|
- foreach ($hosts as $host) {
|
|
|
- if ($host->getMac()) {
|
|
|
- $mac = $host->getMac();
|
|
|
- $state = $host->getState();
|
|
|
- $shortname = $host->getHostType()->getShortname();
|
|
|
-
|
|
|
- $client_class = $state != HostStatus::STATE_NONE ? $state : $shortname;
|
|
|
-
|
|
|
- $hostConfig[$client_class][] = $mac;
|
|
|
+
|
|
|
+ $remote_id_map = isset($dhcpModelParams['remote-id-map']) ? $dhcpModelParams['remote-id-map'] : null;
|
|
|
+ if ($remote_id_map) {
|
|
|
+ $hostConfig = [];
|
|
|
+ foreach ($hosts as $host) {
|
|
|
+ if ($host->getMac()) {
|
|
|
+ $mac = $host->getMac();
|
|
|
+ $state = $host->getState();
|
|
|
+ $shortname = $host->getHostType()->getShortname();
|
|
|
+
|
|
|
+ $client_class = $state != HostStatus::STATE_NONE ? $state : $shortname;
|
|
|
+
|
|
|
+ $hostConfig[$client_class][] = $mac;
|
|
|
+ }
|
|
|
}
|
|
|
+ $hook['parameters']['remote-id-map'] = $hostConfig;
|
|
|
}
|
|
|
- $hook['parameters']['remote-id-map'] = $hostConfig;
|
|
|
+
|
|
|
+ $this->hooks_libraries[] = $hook;
|
|
|
}
|
|
|
-
|
|
|
- $this->hooks_libraries[] = $hook;
|
|
|
}
|
|
|
|
|
|
/**
|