瀏覽代碼

Se corrige la librería hook en el comando y se añade la posibilidad de enviar la configuración al KEA.

Maxi Schvindt 7 年之前
父節點
當前提交
3c4d6b88c2
共有 1 個文件被更改,包括 12 次插入3 次删除
  1. 12 3
      src/KeaBundle/Command/KeaConfigCommand.php

+ 12 - 3
src/KeaBundle/Command/KeaConfigCommand.php

@@ -17,8 +17,9 @@ 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 Entity ID. e.g.: 1')
-            ->addOption('library', null, InputOption::VALUE_OPTIONAL, 'Hook library path', '/home/iksop/kea-hook-cm/kea-hook-flowdat.so')
+            ->addOption('id', null, InputOption::VALUE_OPTIONAL, 'DHCP Entity ID. e.g.: 1', 1)
+            ->addOption('library', null, InputOption::VALUE_OPTIONAL, 'Hook library path', '/kea-cm-hook/kea-hook-flowdat.so')
+            ->addOption('set', null, InputOption::VALUE_REQUIRED, 'Send Config DHCP4 to KEA', 0)
             ;
     }
 
@@ -28,13 +29,21 @@ class KeaConfigCommand extends ContainerAwareCommand
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
+        $setConfig = (int) $input->getOption('set');
+
         $this->output = $output;
         $class = $input->getOption('class');
         $id = $input->getOption('id');
         $library = $input->getOption('library');
         $keaConfigService = $this->getContainer()->get('kea.config');
 
-        $output->writeln($keaConfigService->getConfig($id, $class, $library));
+        if($setConfig) {
+            $config = $keaConfigService->getConfig($id, $class, $library);
+            $dhcp = $this->getContainer()->get("doctrine.orm.entity_manager")->getRepository("DHCPBundle\Entity\DHCP")->findOneById($id);
+            $output->writeln($keaConfigService->setConfig($dhcp, $config));
+        } else {
+            $output->writeln($keaConfigService->getConfig($id, $class, $library));
+        }
     }
 
 }