Selaa lähdekoodia

FD3-800 when the status or the host type of a host or subnet has changed, the host reservations are free

Guillermo Espinoza 6 vuotta sitten
vanhempi
commit
fcc9cb90ac

+ 1 - 1
src/HostBundle/EventListener/HostStatusChangeSubscriber.php

@@ -75,7 +75,7 @@ class HostStatusChangeSubscriber implements EventSubscriber
 
             if ($entity instanceof Host && (isset($changeset['state']) || isset($changeset['hostType']))) {
                 // setting fixed address to null
-                if ($updateFixedAddress == true && $entity->getFixedAddress() != '') {
+                if ($updateFixedAddress == true) {
                     $entity->setFixedAddress(null);
                     $entity->setIpv4Address(null);
                     $entity->setFixedIP(false);

+ 6 - 8
src/IPv4Bundle/EventListener/SubnetStatusOrHostTypeChangeSubscriber.php

@@ -80,14 +80,12 @@ class SubnetStatusOrHostTypeChangeSubscriber implements EventSubscriber
                     }
                 }
                 foreach ($hosts as $host) {
-                    if ($host->getFixedAddress() != '') {
-                        $host->setFixedAddress(null);
-                        $host->setIpv4Address(null);
-                        $host->setFixedIP(false);
-    
-                        $em->persist($host);
-                        $em->flush($host);
-                    }
+                    $host->setFixedAddress(null);
+                    $host->setIpv4Address(null);
+                    $host->setFixedIP(false);
+
+                    $em->persist($host);
+                    $em->flush($host);
                 }
             }
         } catch (\Exception $ex) {

+ 6 - 4
src/KeaBundle/Services/KeaConfigService.php

@@ -298,10 +298,12 @@ class KeaConfigService
                 $results = array();
                 if ($hosts) {
                     foreach ($hosts as $host) {
-                        $results[] = [
-                            'hw-address' => "{$host->getMac()}",
-                            'ip-address' => "{$host->getFixedAddress()}"
-                        ];
+                        if ($host->getMac() && $host->getFixedAddress()) {
+                            $results[] = [
+                                'hw-address' => "{$host->getMac()}",
+                                'ip-address' => "{$host->getFixedAddress()}"
+                            ];
+                        }
                     }
 
                     $reservations[$subnet->getId()] = $results;