Quellcode durchsuchen

minor bugfix with the order of status in subnet and shared-networks config

Guillermo Espinoza vor 6 Jahren
Ursprung
Commit
65f96407f1
2 geänderte Dateien mit 15 neuen und 5 gelöschten Zeilen
  1. 8 1
      src/IPv4Bundle/Entity/SubNet.php
  2. 7 4
      src/KeaBundle/Services/BaseKea.php

+ 8 - 1
src/IPv4Bundle/Entity/SubNet.php

@@ -275,7 +275,14 @@ class SubNet implements TenancyIdTraitInterface, WorkflowInterface
      */
     public function setStatus($status)
     {
-        $this->status = $status;
+        $statuses = array_values(\HostBundle\Utils\HostStatus::getConstants());
+        $this->status = [];
+        foreach ($statuses as $key => $s) {
+            if (in_array($s, $status)) {
+                $k = array_search($s, $status);
+                $this->status[$key] = $status[$k];
+            }
+        }
 
         return $this;
     }

+ 7 - 4
src/KeaBundle/Services/BaseKea.php

@@ -130,11 +130,12 @@ class BaseKea implements KeaConfigInterface
             $sharedNetworkTmp['subnet4'][] = $this->getSubnetSharedNetwork($subnets[0], $reservations);
             unset($subnets[0]);
         }
+        
         foreach ($subnets as $subnet) {
-            if ($subnet->getAllowedHostType() != $hostType && 
-                $subnet->getNetGroup() != $netGroup && 
+            if ($subnet->getAllowedHostType() != $hostType || 
+                $subnet->getNetGroup() != $netGroup || 
                 $subnet->getStatus() != $status) {
-
+                    
                 $this->shared_networks[] = $sharedNetworkTmp;
 
                 $hostType = $subnet->getAllowedHostType();
@@ -142,11 +143,13 @@ class BaseKea implements KeaConfigInterface
                 $status = $subnet->getStatus();
 
                 $sharedNetworkTmp = $sharedNetwork;
-                $sharedNetworkTmp['name'] = $sharedNetworkTmp['name'] . count($this->shared_networks) + 1;
+                $count = count($this->shared_networks) + 1;
+                $sharedNetworkTmp['name'] = "shared-network-{$count}";
                 $sharedNetworkTmp['relay'] = $this->getOptionDataSharedNetwork($subnet);
             }
             $sharedNetworkTmp['subnet4'][] = $this->getSubnetSharedNetwork($subnet, $reservations);
         }
+        
         $this->shared_networks[] = $sharedNetworkTmp;
     }