Pārlūkot izejas kodu

FD3-576 listado de leases de kea

Espinoza Guillermo 7 gadi atpakaļ
vecāks
revīzija
b97b7a85fc

+ 5 - 0
app/config/roles.yml

@@ -72,6 +72,11 @@ security:
         ROLE_SONATA_KEA_CONFIG_EDITOR: [ROLE_SONATA_KEA_CONFIG_READER, ROLE_SONATA_ADMIN_KEA_CONFIG_CREATE, ROLE_SONATA_ADMIN_KEA_CONFIG_EDIT]
         ROLE_SONATA_KEA_CONFIG_ADMIN: [ROLE_SONATA_KEA_CONFIG_EDITOR, ROLE_SONATA_ADMIN_KEA_CONFIG_DELETE, ROLE_SONATA_ADMIN_KEA_CONFIG_EXPORT]
 
+        # LEASE_4
+        ROLE_SONATA_LEASE_4_READER: [ROLE_ADMIN, ROLE_SONATA_ADMIN_LEASE_4_LIST, ROLE_SONATA_ADMIN_LEASE_4_VIEW]
+        ROLE_SONATA_LEASE_4_EDITOR: [ROLE_SONATA_LEASE_4_READER, ROLE_SONATA_ADMIN_LEASE_4_CREATE, ROLE_SONATA_ADMIN_LEASE_4_EDIT]
+        ROLE_SONATA_LEASE_4_ADMIN: [ROLE_SONATA_LEASE_4_EDITOR, ROLE_SONATA_ADMIN_LEASE_4_DELETE, ROLE_SONATA_ADMIN_LEASE_4_EXPORT]
+
         ROLE_ADMIN_TENANCIES: ROLE_ADMIN_TENANCIES
         ROLE_ADMIN: [ROLE_USER, ROLE_SONATA_ADMIN]
         ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_USER_CREATE, ROLE_ADMIN_TENANCIES, ROLE_ALLOWED_TO_SWITCH]

+ 4 - 4
composer.lock

@@ -1457,7 +1457,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseAdmin.git",
-                "reference": "40f690b7915e623069777fc919d332a3a0d7d6eb"
+                "reference": "329e1ae099e739ba2770f4c3029c02b139dece91"
             },
             "type": "library",
             "autoload": {
@@ -1472,7 +1472,7 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2018-06-21T11:53:57+00:00"
+            "time": "2018-06-26T14:21:26+00:00"
         },
         {
             "name": "ik/device-bundle",
@@ -1549,7 +1549,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/BaseOAuthClientBundle.git",
-                "reference": "5d423246bfa5a40b05195f36316b57bbcd47be62"
+                "reference": "b554fd50c877a46b9f864be768493710a8f25f27"
             },
             "require": {
                 "ext-curl": "*",
@@ -1568,7 +1568,7 @@
                 "bundle",
                 "oauth"
             ],
-            "time": "2018-06-25T12:54:07+00:00"
+            "time": "2018-07-02T17:29:09+00:00"
         },
         {
             "name": "ik/owner-voter-bundle",

+ 109 - 0
src/KeaBundle/Admin/Lease4Admin.php

@@ -0,0 +1,109 @@
+<?php
+
+namespace KeaBundle\Admin;
+
+use Base\AdminBundle\Admin\BaseAdmin;
+use Sonata\AdminBundle\Datagrid\DatagridMapper;
+use Sonata\AdminBundle\Datagrid\ListMapper;
+use Sonata\AdminBundle\Form\FormMapper;
+use Sonata\AdminBundle\Show\ShowMapper;
+use Sonata\AdminBundle\Route\RouteCollection;
+
+class Lease4Admin extends BaseAdmin
+{
+    /**
+     * @param DatagridMapper $datagridMapper
+     */
+    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
+    {
+        $datagridMapper
+            ->add('address', 'doctrine_orm_callback', array(
+                'callback' => function($queryBuilder, $alias, $field, $value) {
+                    if (!$value['value']) {
+                        return;
+                    }
+
+                    $queryBuilder
+                        ->andWhere("{$alias}.address = :address")
+                        ->setParameter('address', ip2long($value['value']));
+
+                    return true;
+                },
+            ))
+            ->add('hwaddr', 'doctrine_orm_callback', array(
+                'callback' => function($queryBuilder, $alias, $field, $value) {
+                    if (!$value['value']) {
+                        return;
+                    }
+                    
+                    $queryBuilder->andWhere("{$alias}.hwaddr = :hwaddr");
+                    $queryBuilder->setParameter('hwaddr', hex2bin($value['value']));
+
+                    return true;
+                },
+            ))
+        ;
+    }
+
+    /**
+     * @param ListMapper $listMapper
+     */
+    protected function configureListFields(ListMapper $listMapper)
+    {
+        $listMapper
+            ->add('address')
+            ->add('hwaddr')
+            ->add('client_id')
+            ->add('valid_lifetime')
+            ->add('expire')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                ),
+            ))
+        ;
+    }
+
+    /**
+     * @param FormMapper $formMapper
+     */
+    protected function configureFormFields(FormMapper $formMapper)
+    {
+        $formMapper
+            ->add('address')
+            ->add('hwaddr')
+            ->add('client_id')
+            ->add('valid_lifetime')
+            ->add('expire')
+        ;
+    }
+
+    /**
+     * @param ShowMapper $showMapper
+     */
+    protected function configureShowFields(ShowMapper $showMapper)
+    {
+        $showMapper
+            ->add('address')
+            ->add('hwaddr')
+            ->add('client_id')
+            ->add('valid_lifetime')
+            ->add('expire')
+        ;
+    }
+    
+    /**
+     * @param RouteCollection $collection
+     */
+    protected function configureRoutes(RouteCollection $collection)
+    {
+        $collection
+            ->remove('create')
+            ->remove('edit')
+            ->remove('delete')
+        ;
+    }
+    
+}

+ 116 - 0
src/KeaBundle/Entity/Lease4.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace KeaBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Table(name="kea.lease4")
+ * @ORM\Entity
+ */
+class Lease4
+{
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="address", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $address;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="string")
+     */
+    private $hwaddr;
+    
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="string")
+     */
+    private $client_id;
+    
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="integer")
+     */
+    private $valid_lifetime;
+    
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="datetime")
+     */
+    private $expire;
+    
+    
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return $this->getAddress();
+    }
+    
+    /**
+     * @return string
+     */
+    public function getAddress()
+    {
+        return long2ip($this->address);
+    }
+        
+    public function getHwaddr()
+    {
+        return bin2hex($this->hwaddr);
+    }
+    
+    public function setHwaddr($hwaddr)
+    {
+        $this->hwaddr = $hwaddr;
+        
+        return $this;
+    }
+        
+    public function getClientId()
+    {
+        return bin2hex($this->client_id);
+    }
+    
+    public function setClientId($client_id)
+    {
+        $this->client_id = $client_id;
+        
+        return $this;
+    }
+        
+    public function getValidLifetime()
+    {
+        return $this->valid_lifetime;
+    }
+    
+    public function setValidLifetime($valid_lifetime)
+    {
+        $this->valid_lifetime = $valid_lifetime;
+        
+        return $this;
+    }
+        
+    public function getExpire()
+    {
+        return $this->expire;
+    }
+    
+    public function setExpire($expire)
+    {
+        $this->expire = $expire;
+        
+        return $this;
+    }
+    
+}

+ 10 - 1
src/KeaBundle/Resources/config/services.yml

@@ -10,4 +10,13 @@ services:
             - { name: sonata.admin, manager_type: orm, group: Kea, label: Config, label_catalogue: KeaBundle, label_translator_strategy: sonata.admin.label.strategy.underscore, audit: false }
         calls:
             - [setTranslationDomain, [KeaBundle]]
-        public: true
+        public: true
+
+    sonata.admin.lease_4:
+        class: KeaBundle\Admin\Lease4Admin
+        arguments: [~, KeaBundle\Entity\Lease4, BaseAdminBundle:CRUD]
+        tags:
+            - { name: sonata.admin, manager_type: orm, group: Kea, label: Lease4, label_catalogue: KeaBundle, label_translator_strategy: sonata.admin.label.strategy.underscore, audit: false }
+        calls:
+            - [setTranslationDomain, [KeaBundle]]
+        public: true

+ 14 - 0
src/KeaBundle/Resources/translations/KeaBundle.es.yml

@@ -1,5 +1,6 @@
 Kea: Kea
 Config: Configuración
+Lease4: Leases ipv4
 
 form:
     label_description: Descripción
@@ -14,6 +15,7 @@ breadcrumb:
     link_d_h_c_p_delete: Eliminar Configuración
     link_config_list: Listado de Configuraciones
     link_config_delete: Eliminar Configuración
+    link_lease4_list: Listado Leases
     
 list:
     label_description: Descripción
@@ -21,18 +23,30 @@ list:
     label_created: Creado
     label_template: Plantilla
     label__action: Acciones
+    label_address: Address
+    label_hwaddr: Hwaddr
+    label_client_id: Client id
+    label_valid_lifetime: Valid lifetime
+    label_expire: Expire
 
 show:
     label_description: Descripción
     label_dhcp: DHCP
     label_created: Creado
     label_template: Plantilla
+    label_address: Address
+    label_hwaddr: Hwaddr
+    label_client_id: Client id
+    label_valid_lifetime: Valid lifetime
+    label_expire: Expire
 
 filter:
     label_description: Descripción
     label_dhcp: DHCP
     label_created: Creado
     label_template: Plantilla
+    label_address: Address
+    label_hwaddr: Hwaddr
 
 msg_import_kea_config: Obtener configuración de Kea
 select_dhcp_and_get_config: Seleccionar DHCP y obtener configuración