Преглед изворни кода

FD3-498 se agregaron algunos chequeos en la config de kea

Guillermo Espinoza пре 7 година
родитељ
комит
15916dfb03

+ 2 - 2
src/KeaBundle/Command/KeaConfigCommand.php

@@ -17,8 +17,8 @@ class KeaConfigCommand extends ContainerAwareCommand
             ->setDescription('Kea DHCP Config')
             ->setHelp('Create Kea DHCP Config')
             ->addOption('class', null, InputOption::VALUE_OPTIONAL, 'Kea Class Config in KeaBundle\Services. e.g. BaseKea', 'BaseKea')
-            ->addOption('id', null, InputOption::VALUE_OPTIONAL, 'DHCP ID')
-            ->addOption('library', null, InputOption::VALUE_OPTIONAL, 'Hook library', '/home/iksop/kea-hook-cm/kea-hook-flowdat.so')
+            ->addOption('id', null, InputOption::VALUE_OPTIONAL, 'DHCP Entity ID. e.g.: 1')
+            ->addOption('library', null, InputOption::VALUE_OPTIONAL, 'Hook library path', '/home/iksop/kea-hook-cm/kea-hook-flowdat.so')
             ;
     }
 

+ 5 - 5
src/KeaBundle/Services/BaseKea.php

@@ -11,12 +11,12 @@ class BaseKea implements KeaConfigInterface
     /**
      * @var array
      */
-    public $subnet4 = [];
+    private $subnet4 = [];
 
     /**
     * @var array
     */
-    public $hooks_libraries = [];
+    private $hooks_libraries = [];
 
 
     /**
@@ -31,7 +31,7 @@ class BaseKea implements KeaConfigInterface
             $this->subnetConfig($data['subnets']);
         }
 
-        if (isset($data['dhcp']) && isset($data['library'])) {
+        if (isset($data['library'])) {
             $this->hooksLibrariesConfig($data);
         }
 
@@ -41,7 +41,7 @@ class BaseKea implements KeaConfigInterface
                 'hooks-libraries' => $this->hooks_libraries,
             ],
             'Logging' => $this->loggingConfig(),
-        ]);
+        ], JSON_PRETTY_PRINT);
     }
 
     /**
@@ -75,7 +75,7 @@ class BaseKea implements KeaConfigInterface
             'library' => $data['library'],
         ];
 
-        $dhcpModelParams = $dhcp->getDhcpModel()->getData('parameters');
+        $dhcpModelParams = $dhcp ? $dhcp->getDhcpModel()->getData('parameters') : null;
 
         $option122 = isset($dhcpModelParams['option122']) ? $dhcpModelParams['option122'] : null;
         $ip = isset($dhcpModelParams['ip']) ? $dhcpModelParams['ip'] : null;

+ 1 - 1
src/KeaBundle/Services/KeaConfigService.php

@@ -48,7 +48,7 @@ class KeaConfigService
             $keaConfig = new $fullClass;
             if ($keaConfig instanceof KeaConfigInterface) {
                 $data = [
-                    'dhcp' => $this->dhcpRepository->find($id),
+                    'dhcp' => $id ? $this->dhcpRepository->find($id) : null,
                     'hosts' => $this->hostRepository->findAll(),
                     'subnets' => $this->subnetRepository->findAll(),
                     'library' => $library,