Ver código fonte

FD3-405 DHCP y Modelo DHCP

Guillermo Espinoza 7 anos atrás
pai
commit
6bd8f825fa

+ 1 - 0
app/AppKernel.php

@@ -40,6 +40,7 @@ class AppKernel extends Kernel
             new AuthBundle\AuthBundle(),
             new AuditBundle\AuditBundle(),
             new IPv4Bundle\IPv4Bundle(),
+            new DHCPBundle\DHCPBundle(),
         ];
 
         if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {

+ 2 - 0
app/Resources/translations/messages.es.yml

@@ -4,3 +4,5 @@ HostType: Tipo de Host
 NetGroup: Grupo de Red
 Pool: Pool
 SubNet: Subred
+DHCP: DHCP
+DHCPModel: Modelo DHCP

+ 1 - 0
app/config/config.yml

@@ -20,6 +20,7 @@ imports:
     - { resource: "bundles/ik/device-bundle/parameters.yml" }
     - { resource: "bundles/ik/webservice-bundle/parameters.yml" }
     - { resource: "@IPv4Bundle/Resources/config/services.yml" }
+    - { resource: "@DHCPBundle/Resources/config/services.yml" }
 
 # Put parameters here that don't need to change on each machine where the app is deployed
 # http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration

+ 15 - 0
app/config/routing.yml

@@ -1,3 +1,18 @@
+dhcp_dhcp_model_api:
+    resource: "@DHCPBundle/Controller/REST/DHCPModelRESTController.php"
+    type:   rest
+    prefix:   /api
+
+dhcp_dhcp_api:
+    resource: "@DHCPBundle/Controller/REST/DHCPRESTController.php"
+    type:   rest
+    prefix:   /api
+
+dhcp:
+    resource: "@DHCPBundle/Controller/"
+    type:     annotation
+    prefix:   /
+
 i_pv4_sub_net_api:
     resource: "@IPv4Bundle/Controller/REST/SubNetRESTController.php"
     type:   rest

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

@@ -0,0 +1,72 @@
+<?php
+
+namespace DHCPBundle\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;
+
+class DHCPAdmin extends BaseAdmin
+{
+    /**
+     * @param DatagridMapper $datagridMapper
+     */
+    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
+    {
+        $datagridMapper
+            ->add('name')
+            ->add('host')
+        ;
+    }
+
+    /**
+     * @param ListMapper $listMapper
+     */
+    protected function configureListFields(ListMapper $listMapper)
+    {
+        $listMapper
+            ->add('name')
+            ->add('host')
+            ->add('user')
+            ->add('password')
+            ->add('extraData')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                ),
+            ))
+        ;
+    }
+
+    /**
+     * @param FormMapper $formMapper
+     */
+    protected function configureFormFields(FormMapper $formMapper)
+    {
+        $formMapper
+            ->add('name')
+            ->add('host')
+            ->add('user')
+            ->add('password')
+            ->add('extraData')
+        ;
+    }
+
+    /**
+     * @param ShowMapper $showMapper
+     */
+    protected function configureShowFields(ShowMapper $showMapper)
+    {
+        $showMapper
+            ->add('name')
+            ->add('host')
+            ->add('user')
+            ->add('password')
+            ->add('extraData')
+        ;
+    }
+}

+ 62 - 0
src/DHCPBundle/Admin/DHCPModelAdmin.php

@@ -0,0 +1,62 @@
+<?php
+
+namespace DHCPBundle\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;
+
+class DHCPModelAdmin extends BaseAdmin
+{
+    /**
+     * @param DatagridMapper $datagridMapper
+     */
+    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
+    {
+        $datagridMapper
+            ->add('name')
+        ;
+    }
+
+    /**
+     * @param ListMapper $listMapper
+     */
+    protected function configureListFields(ListMapper $listMapper)
+    {
+        $listMapper
+            ->add('name')
+            ->add('extraData')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array(),
+                ),
+            ))
+        ;
+    }
+
+    /**
+     * @param FormMapper $formMapper
+     */
+    protected function configureFormFields(FormMapper $formMapper)
+    {
+        $formMapper
+            ->add('name')
+            ->add('extraData')
+        ;
+    }
+
+    /**
+     * @param ShowMapper $showMapper
+     */
+    protected function configureShowFields(ShowMapper $showMapper)
+    {
+        $showMapper
+            ->add('name')
+            ->add('extraData')
+        ;
+    }
+}

+ 30 - 0
src/DHCPBundle/Controller/REST/DHCPModelRESTController.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace DHCPBundle\Controller\REST;
+
+use DHCPBundle\Form\DHCPModelType;
+use FOS\RestBundle\Controller\Annotations\RouteResource;
+use WebserviceBundle\Controller\RESTController;
+
+/**
+ * DHCPModel controller.
+ * @RouteResource("DHCPModel")
+ */
+class DHCPModelRESTController extends RESTController
+{
+    /**
+     * @return string Retorna el nombre de la Entity de trabajo.
+     */
+    public function getRepository()
+    {
+        return 'DHCPBundle:DHCPModel';
+    }
+
+    /**
+     * @return string Retorna el tipo de la clase.
+     */
+    public function getFormEntityType()
+    {
+        return get_class(new DHCPModelType());
+    }
+}

+ 30 - 0
src/DHCPBundle/Controller/REST/DHCPRESTController.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace DHCPBundle\Controller\REST;
+
+use DHCPBundle\Form\DHCPType;
+use FOS\RestBundle\Controller\Annotations\RouteResource;
+use WebserviceBundle\Controller\RESTController;
+
+/**
+ * DHCP controller.
+ * @RouteResource("DHCP")
+ */
+class DHCPRESTController extends RESTController
+{
+    /**
+     * @return string Retorna el nombre de la Entity de trabajo.
+     */
+    public function getRepository()
+    {
+        return 'DHCPBundle:DHCP';
+    }
+
+    /**
+     * @return string Retorna el tipo de la clase.
+     */
+    public function getFormEntityType()
+    {
+        return get_class(new DHCPType());
+    }
+}

+ 9 - 0
src/DHCPBundle/DHCPBundle.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace DHCPBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class DHCPBundle extends Bundle
+{
+}

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

@@ -0,0 +1,170 @@
+<?php
+
+namespace DHCPBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
+
+/**
+ * DHCP
+ *
+ * @ORM\Table
+ * @ORM\Entity
+ */
+class DHCP
+{
+
+    use ExtraDataTrait;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=255)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=255)
+     */
+    private $host;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=255)
+     */
+    private $user;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=255)
+     */
+    private $password;
+
+
+    /**
+    * @return string
+    */
+    public function __toString()
+    {
+        return strval($this->name);
+    }
+
+    /**
+     * Get id
+     *
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     *
+     * @return DHCP
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set host
+     *
+     * @param string $host
+     *
+     * @return DHCP
+     */
+    public function setHost($host)
+    {
+        $this->host = $host;
+
+        return $this;
+    }
+
+    /**
+     * Get host
+     *
+     * @return string
+     */
+    public function getHost()
+    {
+        return $this->host;
+    }
+
+    /**
+     * Set user
+     *
+     * @param string $user
+     *
+     * @return DHCP
+     */
+    public function setUser($user)
+    {
+        $this->user = $user;
+
+        return $this;
+    }
+
+    /**
+     * Get user
+     *
+     * @return string
+     */
+    public function getUser()
+    {
+        return $this->user;
+    }
+
+    /**
+     * Set password
+     *
+     * @param string $password
+     *
+     * @return DHCP
+     */
+    public function setPassword($password)
+    {
+        $this->password = $password;
+
+        return $this;
+    }
+
+    /**
+     * Get password
+     *
+     * @return string
+     */
+    public function getPassword()
+    {
+        return $this->password;
+    }
+}

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

@@ -0,0 +1,77 @@
+<?php
+
+namespace DHCPBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
+
+/**
+ * DHCPModel
+ *
+ * @ORM\Table
+ * @ORM\Entity
+ */
+class DHCPModel
+{
+
+    use ExtraDataTrait;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=255)
+     */
+    private $name;
+
+
+    /**
+    * @return string
+    */
+    public function __toString()
+    {
+        return strval($this->name);
+    }
+
+    /**
+     * Get id
+     *
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     *
+     * @return DHCPModel
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+}

+ 38 - 0
src/DHCPBundle/Form/DHCPModelType.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace DHCPBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class DHCPModelType extends AbstractType
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('name')->add('extraData');
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'DHCPBundle\Entity\DHCPModel'
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'dhcpbundle_dhcpmodel';
+    }
+
+
+}

+ 38 - 0
src/DHCPBundle/Form/DHCPType.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace DHCPBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class DHCPType extends AbstractType
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('name')->add('host')->add('user')->add('password')->add('extraData');
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'DHCPBundle\Entity\DHCP'
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'dhcpbundle_dhcp';
+    }
+
+
+}

+ 18 - 0
src/DHCPBundle/Resources/config/services.yml

@@ -0,0 +1,18 @@
+services:
+    dhcp.admin.dhcp:
+        class: DHCPBundle\Admin\DHCPAdmin
+        arguments: [~, DHCPBundle\Entity\DHCP, BaseAdminBundle:CRUD]
+        tags:
+            - { name: sonata.admin, manager_type: orm, group: DHCP, label: DHCP, label_catalogue: DHCPBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
+        calls:
+            - [setTranslationDomain, [DHCPBundle]]
+        public: true
+
+    dhcp.admin.dhcp_model:
+        class: DHCPBundle\Admin\DHCPModelAdmin
+        arguments: [~, DHCPBundle\Entity\DHCPModel, BaseAdminBundle:CRUD]
+        tags:
+            - { name: sonata.admin, manager_type: orm, group: DHCP, label: DHCPModel, label_catalogue: DHCPBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
+        calls:
+            - [setTranslationDomain, [DHCPBundle]]
+        public: true

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

@@ -0,0 +1,31 @@
+DHCP: DHCP
+DHCPModel: Modelo DHCP
+
+form:
+    label_name: Nombre
+    label_host: Host
+    label_user: Usuario
+    label_password: Password
+
+breadcrumb:
+    link_d_h_c_p_list: Listado DHCP
+    link_d_h_c_p_delete: Eliminar DHCP
+    link_d_h_c_p_model_list: Listado Modelo DHCP
+    link_d_h_c_p_model_delete: Eliminar Modelo DHCP
+
+list:
+    label_name: Nombre
+    label_host: Host
+    label_user: Usuario
+    label_password: Password
+    label__action: Acciones
+
+show:
+    label_name: Nombre
+    label_host: Host
+    label_user: Usuario
+    label_password: Password
+
+filter:
+    label_name: Nombre
+    label_host: Host