ソースを参照

Merged in FD3-498 (pull request #10)

FD3-498 DHCP Model para Kea OS. Se agregó asociación entre DHCP y DHCPModel

Approved-by: Maximiliano Schvindt <maximiliano@interlink.com.ar>
Guillermo Espinoza 7 年 前
コミット
489ce178f1

+ 37 - 0
app/DoctrineMigrations/Version20180315120345.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+
+class Version20180315120345 extends AbstractMigration
+{
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $extraData = json_encode([
+            'parameters' => [
+                'option122' => true,
+                'remote-id-map' => true,
+                'ip' => '127.0.0.1',
+            ],
+        ]);
+        $this->addsql(
+            "INSERT INTO dhcpmodel (name, extra_data)
+            SELECT * FROM (SELECT 'Kea OS', '{$extraData}') AS tmp
+            WHERE NOT EXISTS (
+                SELECT name FROM dhcpmodel WHERE name = 'Kea OS'
+            ) LIMIT 1;"
+        );
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+    }
+}

+ 12 - 12
composer.json

@@ -141,17 +141,17 @@
         "doctrine/orm": "^2.5",
         "dwoo/dwoo": "dev-master",
         "hwi/oauth-bundle": "^0.5.3",
-        "ik/audit-bundle": "v0.1.4",
-        "ik/auth-bundle": "v0.1.4",
-        "ik/base-admin-bundle": "v0.1.4",
-        "ik/device-bundle": "v0.1.4",
-        "ik/extra-data-bundle": "v0.1.4",
-        "ik/migrations-bundle": "v0.1.4",
-        "ik/oauthclient-bundle": "v0.1.4",
-        "ik/owner-voter-bundle": "v0.1.4",
-        "ik/template-bundle": "v0.1.4",
-        "ik/webservice-bundle": "v0.1.4",
-        "ik/workflow-bundle": "v0.1.4",
+        "ik/audit-bundle": "dev-master",
+        "ik/auth-bundle": "dev-master",
+        "ik/base-admin-bundle": "dev-master",
+        "ik/device-bundle": "dev-master",
+        "ik/extra-data-bundle": "dev-master",
+        "ik/migrations-bundle": "dev-master",
+        "ik/oauthclient-bundle": "dev-master",
+        "ik/owner-voter-bundle": "dev-master",
+        "ik/template-bundle": "dev-master",
+        "ik/webservice-bundle": "dev-master",
+        "ik/workflow-bundle": "dev-master",
         "incenteev/composer-parameter-handler": "^2.0",
         "jdorn/sql-formatter": "^1.2.17",
         "jms/serializer": "^1.9.0",
@@ -237,4 +237,4 @@
         ],
         "branch-alias": null
     }
-}
+}

+ 41 - 30
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "eed830237ae0da051947fd839cf7abba",
+    "content-hash": "46e2a53e3d3827b941c506850fa3eaca",
     "packages": [
         {
             "name": "behat/transliterator",
@@ -1414,7 +1414,7 @@
         },
         {
             "name": "ik/audit-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/AuditBundle.git",
@@ -1438,11 +1438,11 @@
         },
         {
             "name": "ik/auth-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/AuthBundle.git",
-                "reference": "6355ff9308b0a8e3acb4d50d849ae7fe6df9f137"
+                "reference": "8f28559950fc4e12a96a97084057111fb97156e9"
             },
             "type": "library",
             "autoload": {
@@ -1457,15 +1457,15 @@
                 "auth",
                 "bundle"
             ],
-            "time": "2018-02-19T14:09:39+00:00"
+            "time": "2018-02-19T12:38:29+00:00"
         },
         {
             "name": "ik/base-admin-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseAdmin.git",
-                "reference": "10c4ff5303c45c7f586226ad3a5db8a8a3c5ebb0"
+                "reference": "807fa103f9a0e7d0e22f490de61e1d96645822bc"
             },
             "type": "library",
             "autoload": {
@@ -1480,15 +1480,15 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2018-02-01T14:03:47+00:00"
+            "time": "2018-02-26T17:55:49+00:00"
         },
         {
             "name": "ik/device-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/DeviceBundle.git",
-                "reference": "d50a1db1d54fb7749dbfa8cf7bc8b7c02a578fc4"
+                "reference": "3332f266c84c9b6c9ba8e3bb17fef6aa7d7fdccd"
             },
             "type": "library",
             "autoload": {
@@ -1503,15 +1503,15 @@
                 "bundle",
                 "validators"
             ],
-            "time": "2018-02-19T11:31:32+00:00"
+            "time": "2018-02-19T11:30:09+00:00"
         },
         {
             "name": "ik/extra-data-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/ExtraDataBundle.git",
-                "reference": "78515b49d977a1fddaa7de07e7ab539156a4f7e9"
+                "reference": "06741a4abbe823cc750f3b1d746745a1ab934a60"
             },
             "type": "library",
             "autoload": {
@@ -1526,11 +1526,11 @@
                 "bundle",
                 "extra-data"
             ],
-            "time": "2018-02-19T11:58:38+00:00"
+            "time": "2018-03-15T12:49:20+00:00"
         },
         {
             "name": "ik/migrations-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@bitbucket.org/ikflowdat/migrations.git",
@@ -1553,11 +1553,11 @@
         },
         {
             "name": "ik/oauthclient-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseOAuthClientBundle.git",
-                "reference": "e16db4c7d4da6145c06eb395702bae55d2ce4d6b"
+                "reference": "f9ed69669cad8e44d0c82b7233a41dfa41c1328d"
             },
             "require": {
                 "ext-curl": "*",
@@ -1576,15 +1576,15 @@
                 "bundle",
                 "oauth"
             ],
-            "time": "2018-02-19T14:10:27+00:00"
+            "time": "2018-02-19T12:41:13+00:00"
         },
         {
             "name": "ik/owner-voter-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/OwnerVoter.git",
-                "reference": "4d9946aa47c1235d8f523d4ba60cdf4dbceb1954"
+                "reference": "9171fd2335cc3d164a97a27f0531e436ef924701"
             },
             "type": "library",
             "autoload": {
@@ -1599,15 +1599,15 @@
                 "bundle",
                 "owner-voter"
             ],
-            "time": "2018-02-19T14:19:47+00:00"
+            "time": "2018-02-19T13:34:58+00:00"
         },
         {
             "name": "ik/template-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/TemplateBundle.git",
-                "reference": "750b067d24770041a79e2430b45830c2d8c135f1"
+                "reference": "54859222f517480ba9e218092170fcd049472a4d"
             },
             "require": {
                 "ik/base-admin-bundle": "*"
@@ -1625,15 +1625,15 @@
                 "bundle",
                 "template"
             ],
-            "time": "2018-02-19T14:24:16+00:00"
+            "time": "2018-03-14T12:13:59+00:00"
         },
         {
             "name": "ik/webservice-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/Webservice.git",
-                "reference": "910dd69791d03f4f6f9d58a963e28c8bdf87fb51"
+                "reference": "f4c224b26d011c99f789cb4bddf68e1d2cc32645"
             },
             "require": {
                 "ext-curl": "*",
@@ -1646,15 +1646,15 @@
                 }
             },
             "description": "The Flowdat3 Webservice Rest",
-            "time": "2018-02-19T14:30:39+00:00"
+            "time": "2018-02-27T11:03:58+00:00"
         },
         {
             "name": "ik/workflow-bundle",
-            "version": "v0.1.2",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
-                "reference": "f4ba321ba7dd7e7e32daae50cd2d4aeefb9ce8b7"
+                "reference": "9c70562562d4513c38873c958d588f5bedf5fda0"
             },
             "require": {
                 "php-amqplib/rabbitmq-bundle": "^1.12"
@@ -1684,7 +1684,7 @@
                 "bundle",
                 "workflow"
             ],
-            "time": "2018-02-19T14:31:14+00:00"
+            "time": "2018-02-19T13:50:00+00:00"
         },
         {
             "name": "incenteev/composer-parameter-handler",
@@ -6274,6 +6274,17 @@
     "minimum-stability": "stable",
     "stability-flags": {
         "dwoo/dwoo": 20,
+        "ik/audit-bundle": 20,
+        "ik/auth-bundle": 20,
+        "ik/base-admin-bundle": 20,
+        "ik/device-bundle": 20,
+        "ik/extra-data-bundle": 20,
+        "ik/migrations-bundle": 20,
+        "ik/oauthclient-bundle": 20,
+        "ik/owner-voter-bundle": 20,
+        "ik/template-bundle": 20,
+        "ik/webservice-bundle": 20,
+        "ik/workflow-bundle": 20,
         "sonata-project/admin-bundle": 20,
         "voryx/restgeneratorbundle": 20
     },

+ 3 - 0
src/DHCPBundle/Admin/DHCPAdmin.php

@@ -31,6 +31,7 @@ class DHCPAdmin extends BaseAdmin
             ->add('host')
             ->add('user')
             ->add('password')
+            ->add('dhcpModel')
             ->add('extraData')
             ->add('_action', null, array(
                 'actions' => array(
@@ -52,6 +53,7 @@ class DHCPAdmin extends BaseAdmin
             ->add('host')
             ->add('user')
             ->add('password')
+            ->add('dhcpModel')
             ->add('extraData')
         ;
     }
@@ -66,6 +68,7 @@ class DHCPAdmin extends BaseAdmin
             ->add('host')
             ->add('user')
             ->add('password')
+            ->add('dhcpModel')
             ->add('extraData')
         ;
     }

+ 30 - 0
src/DHCPBundle/Entity/DHCP.php

@@ -4,6 +4,7 @@ namespace DHCPBundle\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
 use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
+use JMS\Serializer\Annotation as JMS;
 use Symfony\Component\Validator\Constraints as Assert;
 
 /**
@@ -54,6 +55,14 @@ class DHCP
      */
     private $password;
 
+    /**
+     * @ORM\ManyToOne(targetEntity="DHCPModel", inversedBy="dhcps", fetch="EXTRA_LAZY")
+     * @ORM\JoinColumn(onDelete="SET NULL")
+     *
+     * @JMS\MaxDepth(1)
+     */
+    private $dhcpModel;
+
 
     /**
     * @return string
@@ -168,4 +177,25 @@ class DHCP
     {
         return $this->password;
     }
+
+    /**
+     * @return DHCPModel
+     */
+    public function getDhcpModel()
+    {
+        return $this->dhcpModel;
+    }
+
+    /**
+     * @param DHCPModel $dhcpModel
+     *
+     * @return DHCP
+     */
+    public function setDhcpModel($dhcpModel)
+    {
+        $this->dhcpModel = $dhcpModel;
+
+        return $this;
+    }
+
 }

+ 17 - 0
src/DHCPBundle/Entity/DHCPModel.php

@@ -4,6 +4,7 @@ namespace DHCPBundle\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
 use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
+use JMS\Serializer\Annotation as JMS;
 use Symfony\Component\Validator\Constraints as Assert;
 
 /**
@@ -33,6 +34,13 @@ class DHCPModel
      */
     private $name;
 
+    /**
+     * @ORM\OneToMany(targetEntity="DHCP", mappedBy="dhcpModel", fetch="EXTRA_LAZY")
+     *
+     * @JMS\MaxDepth(2)
+     */
+    private $dhcps;
+
 
     /**
     * @return string
@@ -75,4 +83,13 @@ class DHCPModel
     {
         return $this->name;
     }
+
+    /**
+     * @return array
+     */
+    public function getDhcps()
+    {
+        return $this->dhcps;
+    }
+
 }

+ 1 - 1
src/DHCPBundle/Form/DHCPType.php

@@ -13,7 +13,7 @@ class DHCPType extends AbstractType
      */
     public function buildForm(FormBuilderInterface $builder, array $options)
     {
-        $builder->add('name')->add('host')->add('user')->add('password')->add('extraData');
+        $builder->add('name')->add('host')->add('user')->add('password')->add('extraData')->add('dhcpModel');
     }
 
     /**

+ 5 - 0
src/DHCPBundle/Resources/translations/DHCPBundle.es.yml

@@ -6,6 +6,7 @@ form:
     label_host: Host
     label_user: Usuario
     label_password: Password
+    label_dhcp_model: Modelo DHCP
 
 breadcrumb:
     link_d_h_c_p_list: Listado DHCP
@@ -19,13 +20,17 @@ list:
     label_user: Usuario
     label_password: Password
     label__action: Acciones
+    label_dhcp_model: Modelo DHCP
 
 show:
     label_name: Nombre
     label_host: Host
     label_user: Usuario
     label_password: Password
+    label_dhcp_model: Modelo DHCP
 
 filter:
     label_name: Nombre
     label_host: Host
+
+default: General

+ 4 - 0
src/IPv4Bundle/Admin/HostAdmin.php

@@ -17,6 +17,7 @@ class HostAdmin extends BaseAdmin
     {
         $datagridMapper
             ->add('mac')
+            ->add('state')
         ;
     }
 
@@ -29,6 +30,7 @@ class HostAdmin extends BaseAdmin
             ->add('mac')
             ->add('options')
             ->add('hostType')
+            ->add('state')
             ->add('_action', null, array(
                 'actions' => array(
                     'show' => array(),
@@ -48,6 +50,7 @@ class HostAdmin extends BaseAdmin
             ->add('mac')
             ->add('options')
             ->add('hostType')
+            ->add('state')
         ;
     }
 
@@ -60,6 +63,7 @@ class HostAdmin extends BaseAdmin
             ->add('mac')
             ->add('options')
             ->add('hostType')
+            ->add('state')
         ;
     }
 }

+ 30 - 0
src/IPv4Bundle/Entity/Host.php

@@ -13,6 +13,9 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
 class Host
 {
 
+    const STATE_ACTIVE = 'active';
+    const STATE_SUSPENDED = 'suspended';
+
     /**
      * @var bigint $id
      *
@@ -44,6 +47,13 @@ class Host
      */
     protected $hostType;
 
+    /**
+     * @var string $state
+     *
+     * @ORM\Column(type="string")
+     */
+    protected $state = self::STATE_ACTIVE;
+
 
     /**
      * @return string
@@ -121,4 +131,24 @@ class Host
         return $this->hostType;
     }
 
+    /**
+     * @return string
+     */
+    public function getState()
+    {
+        return $this->state;
+    }
+
+    /**
+     * @param string $state
+     *
+     * @return Host
+     */
+    public function setState($state = self::STATE_ACTIVE)
+    {
+        $this->state = $state;
+
+        return $this;
+    }
+
 }

+ 3 - 1
src/IPv4Bundle/Form/HostType.php

@@ -18,7 +18,9 @@ class HostType extends AbstractType
             ->add('options')
             ->add('hostType', null, [
                 'required' => false
-            ]);
+            ])
+            ->add('state')
+            ;
     }
 
     /**

+ 4 - 0
src/IPv4Bundle/Resources/translations/IPv4Bundle.es.yml

@@ -21,6 +21,7 @@ form:
     label_allowed_host_type: Tipo de Host permitido
     label_net_group: Grupo de red
     label_ip_pool: IP Pool
+    label_state: Estado
 
 list:
     label_mac: Mac
@@ -38,6 +39,7 @@ list:
     label_allowed_host_type: Tipo de Host permitido
     label_net_group: Grupo de red
     label_ip_pool: IP Pool
+    label_state: Estado
 
 show:
     label_mac: Mac
@@ -54,6 +56,7 @@ show:
     label_allowed_host_type: Tipo de Host permitido
     label_net_group: Grupo de red
     label_ip_pool: IP Pool
+    label_state: Estado
 
 filter:
     label_mac: Mac
@@ -65,6 +68,7 @@ filter:
     label_is_static: Estático
     label_address: Dirección
     label_options: Opciones
+    label_state: Estado
 
 breadcrumb:
     link_host_list: Listado Host

+ 2 - 0
src/IPv4Bundle/tests/Controller/REST/HostRESTControllerTest.php

@@ -3,6 +3,7 @@
 namespace IPv4Bundle\tests\Controller\REST;
 
 use WebserviceBundle\tests\WebTestCaseBase;
+use IPv4Bundle\Entity\Host;
 
 /**
  * Class HostRESTControllerTest
@@ -77,6 +78,7 @@ class HostRESTControllerTest extends BaseRESTControllerTest
             'mac' => 'cafecafecafe',
             'options' => 'cafecafecafe',
             'hostType' => null,
+            'state' => Host::STATE_ACTIVE,
         ];
 
         if ($key == null) {

+ 5 - 1
src/KeaBundle/Command/KeaConfigCommand.php

@@ -17,6 +17,8 @@ class KeaConfigCommand extends ContainerAwareCommand
             ->setDescription('Kea DHCP Config')
             ->setHelp('Create Kea DHCP Config')
             ->addOption('class', null, InputOption::VALUE_OPTIONAL, 'Kea Class Config in KeaBundle\Services. e.g. BaseKea', 'BaseKea')
+            ->addOption('id', null, InputOption::VALUE_OPTIONAL, 'DHCP Entity ID. e.g.: 1')
+            ->addOption('library', null, InputOption::VALUE_OPTIONAL, 'Hook library path', '/home/iksop/kea-hook-cm/kea-hook-flowdat.so')
             ;
     }
 
@@ -28,9 +30,11 @@ class KeaConfigCommand extends ContainerAwareCommand
     {
         $this->output = $output;
         $class = $input->getOption('class');
+        $id = $input->getOption('id');
+        $library = $input->getOption('library');
         $keaConfigService = $this->getContainer()->get('kea.config');
 
-        $output->writeln($keaConfigService->getConfig($class));
+        $output->writeln($keaConfigService->getConfig($id, $class, $library));
     }
 
 }

+ 13 - 0
src/KeaBundle/Interfaces/KeaConfigInterface.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace KeaBundle\Interfaces;
+
+interface KeaConfigInterface
+{
+
+    /**
+     * @return string
+     */
+    public function getConfig();
+
+}

+ 76 - 5
src/KeaBundle/Services/BaseKea.php

@@ -2,14 +2,28 @@
 
 namespace KeaBundle\Services;
 
-class BaseKea
+use IPv4Bundle\Entity\Host;
+use KeaBundle\Interfaces\KeaConfigInterface;
+
+class BaseKea implements KeaConfigInterface
 {
 
-    public $subnet4 = [];
+    /**
+     * @var array
+     */
+    private $subnet4 = [];
+
+    /**
+    * @var array
+    */
+    private $hooks_libraries = [];
 
 
     /**
      * @param array $data
+     * @param boolean $logging
+     *
+     * @return string
      */
     public function getConfig($data = array(), $logging = false)
     {
@@ -17,10 +31,17 @@ class BaseKea
             $this->subnetConfig($data['subnets']);
         }
 
+        if (isset($data['library'])) {
+            $this->hooksLibrariesConfig($data);
+        }
+
         return json_encode([
-            'Dhcp4' => $this,
-            'Logging' => $this->loggingConfig()
-        ]);
+            'Dhcp4' => [
+                'subnet4' => $this->subnet4,
+                'hooks-libraries' => $this->hooks_libraries,
+            ],
+            'Logging' => $this->loggingConfig(),
+        ], JSON_PRETTY_PRINT);
     }
 
     /**
@@ -42,6 +63,56 @@ class BaseKea
         }
     }
 
+    /**
+     * @param array $data
+     */
+    private function hooksLibrariesConfig($data)
+    {
+        $dhcp = $data['dhcp'];
+        $hosts = $data['hosts'];
+
+        $hook = [
+            'library' => $data['library'],
+        ];
+
+        $dhcpModelParams = $dhcp ? $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) {
+                $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) {
+            $active = [];
+            $suspended = [];
+            foreach ($hosts as $host) {
+                $mac = $host->getMac();
+                $state = $host->getState();
+                if ($state == Host::STATE_ACTIVE) {
+                    $active[] = $mac;
+                } elseif ($state == Host::STATE_SUSPENDED) {
+                    $suspended[] = $mac;
+                }
+            }
+
+            $hook['parameters']['remote-id-map'] = [
+                'active' => $active,
+                'suspended' => $suspended,
+            ];
+        }
+
+        $this->hooks_libraries[] = $hook;
+    }
+
     /**
      * @return string
      */

+ 26 - 5
src/KeaBundle/Services/KeaConfigService.php

@@ -2,38 +2,59 @@
 
 namespace KeaBundle\Services;
 
+use KeaBundle\Interfaces\KeaConfigInterface;
+
 class KeaConfigService
 {
 
+    /**
+     * @var Repository
+     */
+    private $dhcpRepository;
+
     /**
      * @var Repository
      */
     private $subnetRepository;
 
+    /**
+     * @var Repository
+     */
+    private $hostRepository;
+
 
     /**
      * @param EntityManager $em
      */
     public function __construct($em)
     {
+        $this->dhcpRepository = $em->getRepository('DHCPBundle:DHCP');
         $this->subnetRepository = $em->getRepository('IPv4Bundle:SubNet');
+        $this->hostRepository = $em->getRepository('IPv4Bundle:Host');
     }
 
     /**
+     * @param int $id
      * @param string $className
+     * @param string $library
      *
      * @return string
      */
-    public function getConfig($className = 'BaseKea')
+    public function getConfig($id, $className = 'BaseKea', $library = '/home/iksop/kea-hook-cm/kea-hook-flowdat.so')
     {
         $config = '';
         $fullClass = 'KeaBundle\\Services\\' . $className;
         if (class_exists($fullClass)) {
-            $data = [
-                'subnets' => $this->subnetRepository->findAll(),
-            ];
             $keaConfig = new $fullClass;
-            $config = $keaConfig->getConfig($data);
+            if ($keaConfig instanceof KeaConfigInterface) {
+                $data = [
+                    'dhcp' => $id ? $this->dhcpRepository->find($id) : null,
+                    'hosts' => $this->hostRepository->findAll(),
+                    'subnets' => $this->subnetRepository->findAll(),
+                    'library' => $library,
+                ];
+                $config = $keaConfig->getConfig($data);
+            }
         }
 
         return $config;