Browse Source

Added xdebug on Dockerfile and implemented min 10 seconds and max 10 seconds to OLT timeout.

Jean Sumara 4 years ago
parent
commit
930e15413f
2 changed files with 20 additions and 29 deletions
  1. 18 0
      Dockerfile
  2. 2 29
      src/FTTHBundle/Admin/OLTAdmin.php

+ 18 - 0
Dockerfile

@@ -43,6 +43,24 @@ RUN chmod 0600 /opt/keys/*; \
     chmod 777 -R var/cache/ var/logs/ var/sessions/; \
     rm -rf /var/lib/apt/lists/*
 
+ARG WITH_XDEBUG=false
+ARG HOST_MACHINE=1.1.1.1
+
+RUN if [ $WITH_XDEBUG = "true" ] ; then \
+        apt-get update; \
+        apt-get install php-xdebug; \
+        echo "error_reporting = E_ALL" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "display_startup_errors = On" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "display_errors = On" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "xdebug.remote_enable=1" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "xdebug.remote_handler=dbgp" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "xdebug.remote_port=10000" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "xdebug.remote_autostart=1" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "xdebug.remote_connect_back=0" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "xdebug.idekey=docker" >> /etc/php/7.0/mods-available/xdebug.ini; \
+        echo "xdebug.remote_host=$HOST_MACHINE" >> /etc/php/7.0/mods-available/xdebug.ini; \
+    fi ;
+
 CMD env; \
     cp /opt/ftth/keys/fullchain.pem /usr/share/ca-certificates/$HOST_BASE; \
     echo $HOST_BASE >> /etc/ca-certificates.conf; \

+ 2 - 29
src/FTTHBundle/Admin/OLTAdmin.php

@@ -12,6 +12,7 @@ use Sonata\AdminBundle\Form\Type\CollectionType;
 use Sonata\AdminBundle\Form\Type\Filter\ChoiceType;
 use Sonata\AdminBundle\Form\Type\ModelType;
 use Sonata\AdminBundle\Show\ShowMapper;
+use Sonata\CoreBundle\Validator\ErrorElement;
 use WorkflowBundle\Admin\WorkflowBaseAdmin;
 
 class OLTAdmin extends WorkflowBaseAdmin
@@ -101,7 +102,7 @@ class OLTAdmin extends WorkflowBaseAdmin
                             'help' => 'form.help_ssh_connect',
                         ])
                         ->add('sshPort')
-                        ->add('oltTimeout')
+                        ->add('oltTimeout','integer', array('attr' => array('min' => 10, 'max' => 50)))
                     ->end()
                 ->end()
                 ->tab('autodiscovery')
@@ -171,32 +172,4 @@ class OLTAdmin extends WorkflowBaseAdmin
         ;
     }
 
-    /**
-     * @param OLT $olt
-     * @throws \Exception
-     */
-    public function prePersist($olt)
-    {
-        $this->validateTimeout($olt);
-    }
-
-    /**
-     * @param OLT $olt
-     * @throws \Exception
-     */
-    public function preUpdate($olt)
-    {
-        $this->validateTimeout($olt);
-    }
-
-    /**
-     * @param OLT $olt
-     * @throws \Exception
-     */
-    private function validateTimeout($olt){
-        if($olt->getOltTimeout() > 50){
-            throw new \Exception("El tiempo de espera debe ser inferior al tiempo de procesamiento");
-        }
-    }
-
 }