Przeglądaj źródła

FD3-699 Update dhcp options en subnet

Espinoza Guillermo 6 lat temu
rodzic
commit
3aa71e124e

+ 9 - 1
src/HostBundle/Command/DHCPOptionsUpdateCommand.php

@@ -3,7 +3,7 @@
 namespace HostBundle\Command;
 
 use Buzz\Message\RequestInterface as HttpRequestInterface;
-use HostBundle\Entity\Host;
+use IPv4Bundle\Entity\SubNet;
 use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputOption;
@@ -45,6 +45,14 @@ EOT
         $io->success('Total entities updated: ' . $result);
         $io->newLine(2);
         
+        $io->section("Updating SubNet entities:");
+        
+        $result = $dhcpService->formatDhcpOptions($output, SubNet::class);
+        
+        $io->newLine(2);
+        $io->success('Total entities updated: ' . $result);
+        $io->newLine(2);
+        
         $output->writeln(['', 'Done!']);
     }
         

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

@@ -110,7 +110,7 @@ class KEAHostReservationSubscriber implements EventSubscriber
                 // mta|cpe
                 $hex = '';
                 $prefix = $shortname . '-';
-                for ($i = 0; $i < strlen($prefix); $i++){
+                for ($i = 0; $i < strlen($prefix); $i++) {
                     $ord = ord($prefix[$i]);
                     $hexCode = dechex($ord);
                     $hex .= substr('0'.$hexCode, -2);

+ 2 - 2
src/HostBundle/Services/DHCPOptionsService.php

@@ -37,13 +37,13 @@ class DHCPOptionsService
      *
      * @return int
      */
-    public function formatDhcpOptions($output)
+    public function formatDhcpOptions($output, $class = Host::class)
     {
         $i = 0;
         $batchSize = 20;
         $detach = [];
         
-        $hostRepository = $this->em->getRepository(Host::class);
+        $hostRepository = $this->em->getRepository($class);
         $hosts = $hostRepository->findAll();
         
         ProgressBar::setFormatDefinition('custom', ' %current%/%max% [%bar%] %percent:3s%% %message%');