Pārlūkot izejas kodu

Se agrega mta enabled en host command

Guillermo Espinoza 6 gadi atpakaļ
vecāks
revīzija
a8906ce98b
1 mainītis faili ar 27 papildinājumiem un 26 dzēšanām
  1. 27 26
      src/CablemodemBundle/Command/DHCPHostCRUDCommand.php

+ 27 - 26
src/CablemodemBundle/Command/DHCPHostCRUDCommand.php

@@ -53,7 +53,7 @@ EOT
     {
         $this->input = $input;
         $this->io = new SymfonyStyle($input, $output);
-        
+
         $this->mac = $input->getArgument('mac');
         $this->webservice = $this->getContainer()->get('webservice');
         $this->credentials = [
@@ -68,7 +68,7 @@ EOT
         foreach ($enabledFilters as $filter_name => $filter) {
             $filters->disable($filter_name);
         }
-        
+
         $this->cablemodem = $em->getRepository('CablemodemBundle:Cablemodem')->findOneByMac($this->mac);
         if ($this->cablemodem) {
             // Crea el Host
@@ -78,7 +78,7 @@ EOT
                 $this->io->section('Deleting DHCP Host if exists');
             }
             $this->io->success('RESULT: ' . $this->createHost());
-            
+
             // Crea o elimina si existe el Host CPE
             $cpeFixedIP = $this->cablemodem->getCpeFixedIP();
             if ($cpeFixedIP) {
@@ -88,7 +88,7 @@ EOT
                 $this->io->section('Deleting DHCP CPE Host if exists');
                 $this->io->success('RESULT: ' . $this->deleteHost('cpe'));
             }
-            
+
             // Crea o elimina si existe el Host MTA
             $mtaFixedIP = $this->cablemodem->getMtaFixedIP();
             if ($mtaFixedIP) {
@@ -101,12 +101,12 @@ EOT
         } else {
             $output->writeln("<error>Cablemodem mac {$this->mac} not found</error>");
         }
-        
+
         foreach ($enabledFilters as $filter_name => $filter) {
             $filters->enable($filter_name);
         }
     }
-    
+
     /**
      * @param string $type HostType name Cablemodem | MTA | CPE
      *
@@ -116,7 +116,7 @@ EOT
     {
         $ws = $this->webservice;
         $urlGET = $this->input->getOption('url-get');
-        
+
         // Consulto en DHCP por Host
         $host = null;
         $url = $ws->buildUrl($urlGET, [
@@ -128,7 +128,7 @@ EOT
                 $host = current($hostDecode);
             }
         }
-        
+
         // Consulto por Host con HostType MTA o CPE relacionado
         if ($host && ($type == 'mta' || $type == 'cpe')) {
             $hostId = $host['id'];
@@ -144,11 +144,11 @@ EOT
             }
             if (!isset($hostId)) {
                 $this->io->error("No existe el hostType {$type} en DHCP");
-                
+
                 return;
             }
         }
-        
+
         // Creo, edito o elimino dependiendo los parámetros
         $method = HttpRequestInterface::METHOD_POST;
         if ($this->input->getOption('delete') == true) {
@@ -157,24 +157,25 @@ EOT
             $this->io->section('Updating');
             $method = HttpRequestInterface::METHOD_PUT;
         }
-        
+
         $fixedIP = $this->cablemodem->getFixedIP();
         $mtaFixedIP = $this->cablemodem->getMtaFixedIP();
         $cpeFixedIP = $this->cablemodem->getCpeFixedIP();
-        
+
         $options = isset($host['options']) ? $host['options'] : [];
-        
+
         $data = [
             'mac' => $this->mac,
             'hostType' => $this->getIdHostType($type),
             'state' => 'active',
             'fixed_address' => $fixedIP ?: null,
             'fixedIP' => $fixedIP ? true : false,
+            'mtaEnabled' => $this->cablemodem->getMtaEnabled(),
         ];
         if (isset($hostId) && ($type == 'mta' || $type == 'cpe')) {
             unset($data['mac']);
             $data['host'] = $hostId;
-            
+
             if ($type == 'mta') {
                 $data['fixed_address'] = $mtaFixedIP ?: null;
                 $data['fixedIP'] = $mtaFixedIP ? true : false;
@@ -186,12 +187,12 @@ EOT
         }
         $dhcpOptions = $this->cablemodem->getDHCPOptions();
         $data = array_merge($data, $dhcpOptions);
-        
+
         $this->io->text('DATA: ' . json_encode($data));
-        
+
         return $ws->makeGetRequest($this->getUrlParameter($method, $host), $method, $data);
     }
-    
+
     /**
      * @param string $type  HostType name Cablemodem | MTA | CPE
      *
@@ -201,7 +202,7 @@ EOT
     {
         $ws = $this->webservice;
         $urlGET = $this->input->getOption('url-get');
-        
+
         // Consulto en DHCP por Host
         $host = null;
         $url = $ws->buildUrl($urlGET, [
@@ -213,7 +214,7 @@ EOT
                 $host = current($hostDecode);
             }
         }
-        
+
         // Consulto por Host con HostType MTA o CPE relacionado
         $deleteHost = null;
         if ($host && ($type == 'mta' || $type == 'cpe')) {
@@ -229,18 +230,18 @@ EOT
                 }
             }
         }
-        
+
         if (!$deleteHost) {
             return null;
-        } 
-        
+        }
+
         $method = HttpRequestInterface::METHOD_DELETE;
 
         $data = [
             'hostType' => isset($deleteHost['hostType']) ? $deleteHost['hostType']['id'] : $this->getIdHostType($type),
             'host' => $hostId,
         ];
-        
+
         $this->io->text('DATA: ' . json_encode($data));
 
         return $ws->makeGetRequest($this->getUrlParameter($method, $deleteHost), $method, $data);
@@ -273,7 +274,7 @@ EOT
 
         return $container->hasParameter($parameter) ? str_replace('{id}', $id, $container->getParameter($parameter)) : $url;
     }
-    
+
     /**
      * @param string $name HostType name Cablemodem | MTA | CPE
      *
@@ -287,7 +288,7 @@ EOT
         $url = $container->hasParameter($parameter) ?
             $container->getParameter($parameter) :
             $this->input->getOption('url-get-hosttype');
-        
+
         $url = $this->webservice->buildUrl($url, [
             'shortname' => $name,
         ]);
@@ -298,7 +299,7 @@ EOT
                 $hostType = current($hostDecode)['id'];
             }
         }
-        
+
         return $hostType;
     }