瀏覽代碼

Merge branch 'master' of bitbucket.org:ikflowdat/cablemodem

Guillermo Espinoza 7 年之前
父節點
當前提交
e4b15ddea7

+ 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

+ 14 - 7
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'];
                 }
@@ -83,11 +85,16 @@ EOT
                 $method = HttpRequestInterface::METHOD_PUT;
             }
 
-            $result = $webservice->makeGetRequest($this->getUrlParameter($method, $host), $method, [
+            $data = [
                 'mac' => $mac,
-                'options' => $cablemodem->getDHCPOptions(),
                 'hostType' => $hostType,
-            ], $credentials);
+                'state' => 'active',
+            ];
+
+            $dhcpOptions = $cablemodem->getDHCPOptions();
+            $data = array_merge($data, $dhcpOptions);
+
+            $result = $webservice->makeGetRequest($this->getUrlParameter($method, $host), $method, $data, $credentials);
 
             $output->writeln($result);
         } else {

+ 8 - 3
src/CablemodemBundle/Entity/Cablemodem.php

@@ -373,9 +373,14 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
     */
    public function getDHCPOptions()
    {
-       $options = "";
-       if ($this->mtaEnabled) {
-           $options .= "option option122.dhcp-server 255.255.255.255;\r\noption option122.provisioning-type \"BASIC.1\";\r\n";
+       global $kernel;
+       $options = [
+           'filename' => $this->mac . '.bin',
+       ];
+       $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";
        }
 
        return $options;