Ver Fonte

FD3-754 Update migrations. Update generación de config de KEA

Espinoza Guillermo há 6 anos atrás
pai
commit
14d8a6423a

+ 1 - 0
.gitignore

@@ -15,6 +15,7 @@
 !var/SymfonyRequirements.php
 /vendor/
 /web/bundles/
+/web/kea/
 /app/Resources/workflows/workflow_list.yml
 /app/config/bundles/hwi/oauth-bundle/parameters.yml
 /app/config/bundles/ik/audit-bundle/parameters.yml

+ 11 - 1
app/DoctrineMigrations/src/action.yml

@@ -2,8 +2,9 @@ insertorupdate:
     action:
         -
           id: 1
-          name: "Configuración KEA"
+          name: "KEA Config Subnet"
           workflow_name: "dhcp_workflow"
+          object_class: "IPv4Bundle\\Entity\\SubNet"
           event: "a:1:{i:0;s:5:\"enter\";}"
           event_reference: "active"
           template: "echo \"Config KEA\"\r\nphp /opt/dhcp/bin/console kea:config --set"
@@ -35,4 +36,13 @@ insertorupdate:
           object_class: "HostBundle\\Entity\\Host"
           event: "a:1:{i:0;s:9:\"preUpdate\";}"
           template: "echo \"Actualizando Cablemodem\"\r\n\r\nphp /opt/dhcp/bin/console cablemodem:update --id={{object.id}}"
+          tenancy_id: 1
+        -
+          id: 6
+          name: "KEA Config Pool"
+          workflow_name: "dhcp_workflow"
+          object_class: "IPv4Bundle\\Entity\\Pool"
+          event: "a:1:{i:0;s:5:\"enter\";}"
+          event_reference: "active"
+          template: "echo \"Config KEA\"\r\nphp /opt/dhcp/bin/console kea:config --set"
           tenancy_id: 1  

+ 4 - 2
src/KeaBundle/Command/KeaConfigCommand.php

@@ -46,8 +46,10 @@ class KeaConfigCommand extends ContainerAwareCommand
             }
             if ($dhcp) {
                 $config = $keaConfigService->getConfig($id, $class, $library);
-                // $output->writeln($keaConfigService->setConfig($dhcp, $config));
-                $output->writeln($keaConfigService->saveFileConfig($config));
+                $result = $keaConfigService->saveFileConfig($config);
+                if ($result) {
+                    $output->writeln($keaConfigService->getConfig($id, $class, $library));
+                }
             } else {
                 $output->writeln("KEA DHCP id:{$id} <error>not found!</error>");
             }

+ 50 - 50
src/KeaBundle/Services/BaseKea.php

@@ -175,58 +175,58 @@ class BaseKea implements KeaConfigInterface
                     "password" => $data['db']['password'],
                 ]
             ],
-            // [
-            //     "library" => "/opt/hooks/amqp/kea-hook-flowdat3.so",
-            //     "parameters" => [
-            //         "host" => $data['amqp']['host'],
-            //         "user" => $data['amqp']['user'],
-            //         "password" => $data['amqp']['password'],
-            //     ],
-            // ],
-        ];
-
-        $dhcp = $data['dhcp'];
-        $hosts = $data['hosts'];
-
-        $hook = [
-            'library' => $data['library'],
+            [
+                "library" => "/opt/hooks/amqp/kea-hook-flowdat3.so",
+                "parameters" => [
+                    "host" => $data['amqp']['host'],
+                    "user" => $data['amqp']['user'],
+                    "password" => $data['amqp']['password'],
+                ],
+            ],
         ];
 
-        $dhcpModelParams = $dhcp && $dhcp->getDhcpModel() ? $dhcp->getDhcpModel()->getData('parameters') : null;
-
-        $option122 = isset($dhcpModelParams['option122']) ? $dhcpModelParams['option122'] : null;
-        $ip = isset($dhcpModelParams['ip']) ? $dhcpModelParams['ip'] : null;
-        if ($option122 && $ip) {
-            $macs = [];
-            foreach ($hosts as $host) {
-                if ($host->getMac()) {
-                    $macs[] = $host->getMac();
-                }
-            }
-
-            $hook['parameters']['option122'] = [
-                $ip => $macs
-            ];
-        }
-
-        $remote_id_map = isset($dhcpModelParams['remote-id-map']) ? $dhcpModelParams['remote-id-map'] : null;
-        if ($remote_id_map) {
-            $hostConfig = [];
-            foreach ($hosts as $host) {
-                if ($host->getMac()) {
-                    $mac = $host->getMac();
-                    $state = $host->getState();
-                    $shortname = $host->getHostType()->getShortname();
-
-                    $client_class = $state != HostStatus::STATE_NONE ? $state : $shortname;
-
-                    $hostConfig[$client_class][] = $mac;
-                }
-            }
-            $hook['parameters']['remote-id-map'] = $hostConfig;
-        }
-
-        $this->hooks_libraries[] = $hook;
+        // $dhcp = $data['dhcp'];
+        // $hosts = $data['hosts'];
+        // 
+        // $hook = [
+        //     'library' => $data['library'],
+        // ];
+        // 
+        // $dhcpModelParams = $dhcp && $dhcp->getDhcpModel() ? $dhcp->getDhcpModel()->getData('parameters') : null;
+        // 
+        // $option122 = isset($dhcpModelParams['option122']) ? $dhcpModelParams['option122'] : null;
+        // $ip = isset($dhcpModelParams['ip']) ? $dhcpModelParams['ip'] : null;
+        // if ($option122 && $ip) {
+        //     $macs = [];
+        //     foreach ($hosts as $host) {
+        //         if ($host->getMac()) {
+        //             $macs[] = $host->getMac();
+        //         }
+        //     }
+        // 
+        //     $hook['parameters']['option122'] = [
+        //         $ip => $macs
+        //     ];
+        // }
+        // 
+        // $remote_id_map = isset($dhcpModelParams['remote-id-map']) ? $dhcpModelParams['remote-id-map'] : null;
+        // if ($remote_id_map) {
+        //     $hostConfig = [];
+        //     foreach ($hosts as $host) {
+        //         if ($host->getMac()) {
+        //             $mac = $host->getMac();
+        //             $state = $host->getState();
+        //             $shortname = $host->getHostType()->getShortname();
+        // 
+        //             $client_class = $state != HostStatus::STATE_NONE ? $state : $shortname;
+        // 
+        //             $hostConfig[$client_class][] = $mac;
+        //         }
+        //     }
+        //     $hook['parameters']['remote-id-map'] = $hostConfig;
+        // }
+
+        // $this->hooks_libraries[] = $hook;
     }
 
     /**