Explorar el Código

FD3-504 refactory dhcp:host:crud command

Guillermo Espinoza hace 7 años
padre
commit
34d23a14dc

+ 2 - 0
app/config/parameters.yml.dist

@@ -45,3 +45,5 @@ parameters:
 
     # App Dummy URL
     env(HOST_DUMMY): http://www.flowdat.com/
+
+    dhcp_server_ip: 255.255.255.255

+ 5 - 3
app/config/parameters.yml.docker

@@ -18,7 +18,7 @@ parameters:
 
     # A secret key that's used to generate certain security-related tokens
     secret:            ThisTokenIsNotSoSecretChangeIt
-    
+
     jms_serializer.camel_case_naming_strategy.class: JMS\Serializer\Naming\IdenticalPropertyNamingStrategy
 
     # amqp queue config
@@ -39,8 +39,10 @@ parameters:
     cookie_domain_client: '%env(CLIENT)%'
     cookie_domain: '%cookie_domain_client%.flowdat.com'
     session_names: [flowdat_base_session, flowdat_ftth_session, flowdat_mapas_session, flowdat_stats_session, flowdat_radius_session, flowdat_cablemodem_session]
-    
+
     nginx_name: nginx-proxy
 
     # App Dummy URL
-    env(HOST_DUMMY): http://www.flowdat.com/
+    env(HOST_DUMMY): http://www.flowdat.com/
+
+    dhcp_server_ip: 255.255.255.255

+ 7 - 4
src/CablemodemBundle/Command/DHCPHostCRUDCommand.php

@@ -57,9 +57,10 @@ EOT
             $webservice = $this->getContainer()->get('webservice');
             // consulto si hay un DHCP Host para la mac y traigo el HostType
             $host = null;
-            $hostJSON = $webservice->makeGetRequest($input->getOption('url-get'), HttpRequestInterface::METHOD_GET, [
+            $url = $webservice->buildUrl($input->getOption('url-get'), [
                 'mac' => $mac,
-            ], $credentials);
+            ]);
+            $hostJSON = $webservice->makeGetRequest($url, HttpRequestInterface::METHOD_GET, [], $credentials);
             if ($hostJSON != '') {
                 $host = current(json_decode($hostJSON, true));
             }
@@ -68,9 +69,10 @@ EOT
             if (isset($host['hostType'])) {
                 $hostType = $host['hostType']['id'];
             } else {
-                $hostTypeJSON = $webservice->makeGetRequest($this->getUrlParameterHostType(), HttpRequestInterface::METHOD_GET, [
+                $url = $webservice->buildUrl($this->getUrlParameterHostType(), [
                     'name' => 'Cablemodem',
-                ], $credentials);
+                ]);
+                $hostTypeJSON = $webservice->makeGetRequest($url, HttpRequestInterface::METHOD_GET, [], $credentials);
                 if ($hostTypeJSON != '') {
                     $hostType = current(json_decode($hostTypeJSON, true))['id'];
                 }
@@ -86,6 +88,7 @@ EOT
             $data = [
                 'mac' => $mac,
                 'hostType' => $hostType,
+                'state' => 'active',
             ];
 
             $dhcpOptions = $cablemodem->getDHCPOptions();

+ 4 - 2
src/CablemodemBundle/Entity/Cablemodem.php

@@ -373,11 +373,13 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     */
    public function getDHCPOptions()
    {
+       global $kernel;
        $options = [
            'filename' => $this->mac . '.bin',
        ];
-       if ($this->mtaEnabled) {
-           $options['option122_dhcp_server'] = "255.255.255.255";
+       $container = $kernel->getContainer();
+       if ($this->mtaEnabled && $container->hasParameter('dhcp_server_ip')) {
+           $options['option122_dhcp_server'] = $container->getParameter('dhcp_server_ip');
            $options['option122_provisioning_type'] = "BASIC.1";
        }