Browse Source

Merge branch 'master' of bitbucket.org:ikflowdat/stats

Conflicts:
	composer.lock
Luciano Andrade 7 years ago
parent
commit
7f2606fe49

+ 6 - 9
.drone.yml

@@ -43,23 +43,20 @@ pipeline:
    image: plugins/docker
    email: luciano@interlink.com.ar
    registry: docker.infra.flowdat.com
-   username: drone
-   password: 6hd2dLfL
    tag: 
-     - latest
+     - "latest"
    when:
-     event: [pull_request, push, tag]
+     event: [push]
      branch: [master]
 
- tag_docker:
+ docker_tag:
    repo : docker.infra.flowdat.com/fd3/stats
    image: plugins/docker
    email: luciano@interlink.com.ar
    registry: docker.infra.flowdat.com
-   username: drone
-   password: 6hd2dLfL
    tag: 
-     - ${DRONE_TAG##v}
+     - "${DRONE_TAG:1:5}"
+     - "${DRONE_TAG:1:3}"
    when:
-     event: [pull_request, push, tag]
+     event: [tag]
      branch: [v*]

+ 4 - 1
Dockerfile

@@ -26,9 +26,12 @@ RUN cp app/config/parameters.yml.docker app/config/parameters.yml ;\
     cp app/config/bundles/hwi/oauth-bundle/parameters.yml.docker app/config/bundles/hwi/oauth-bundle/parameters.yml ;\
     cp app/config/bundles/ik/webservice-bundle/parameters.yml.docker app/config/bundles/ik/webservice-bundle/parameters.yml ;\
     cp app/config/bundles/ik/base-admin-bundle/parameters.yml.dist app/config/bundles/ik/base-admin-bundle/parameters.yml 
- 
+
+RUN apt-get install gdal-bin -yq
+
 CMD  eval $(ssh-agent) ; ssh-add /opt/keys/bitbucket.id_rsa ; composer install --no-scripts --no-interaction ;\
      rm var/cache/* -rf ;\
      composer dump-autoload ;\
      composer run-script post-install-cmd --no-interaction ;\
      bin/console server:run 0.0.0.0
+     

+ 27 - 6
app/AppKernel.php

@@ -2,6 +2,8 @@
 
 use Symfony\Component\HttpKernel\Kernel;
 use Symfony\Component\Config\Loader\LoaderInterface;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\HttpFoundation\Request;
 
 class AppKernel extends Kernel
 {
@@ -15,7 +17,7 @@ class AppKernel extends Kernel
             new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
             new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
             new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
-            
+
             new Sonata\CoreBundle\SonataCoreBundle(),
             new Sonata\BlockBundle\SonataBlockBundle(),
             new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
@@ -30,14 +32,14 @@ class AppKernel extends Kernel
 
             new MigrationsBundle\MigrationsBundle(),
             new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
-            
+
             new WebserviceBundle\WebserviceBundle(),
             new Base\AdminBundle\BaseAdminBundle(),
             new Base\OAuthClientBundle\BaseOAuthClientBundle(),
             new DeviceBundle\DeviceBundle(),
             new ExtraDataBundle\ExtraDataBundle(),
             new OwnerVoterBundle\OwnerVoterBundle(),
-            
+
             new StatsBundle\StatsBundle(),
             new RedisBundle\RedisBundle(),
             new BaseStatsBundle\BaseStatsBundle(),
@@ -74,16 +76,35 @@ class AppKernel extends Kernel
 
     public function getCacheDir()
     {
-        return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
+        return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
     }
 
     public function getLogDir()
     {
-        return dirname(__DIR__).'/var/logs';
+        return dirname(__DIR__) . '/var/logs';
     }
 
     public function registerContainerConfiguration(LoaderInterface $loader)
     {
-        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
+        $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
+    {
+        if (false === $this->booted) {
+            $this->boot();
+        }
+        // se puede sacar la variable nginx-proxy porque es el nombre del docker y puede variar
+        // con REMOTRA_ADDR obtengo el mismo valor (http://symfony.com/doc/current/deployment/proxies.html)
+        //gethostbyname("nginx-proxy") == $request->server->get('REMOTE_ADDR')
+        if ($this->container->hasParameter("nginx_name")) {
+            Request::setTrustedProxies(
+                array('127.0.0.1', $this->container->getParameter("nginx_name")),
+                Request::HEADER_X_FORWARDED_FOR);
+        }
+        return parent::handle($request, $type, $catch);
     }
 }

+ 6 - 4
app/config/parameters.yml.dist

@@ -28,13 +28,13 @@ parameters:
     db_session_name: fd_session
     db_session_user: root
     db_session_password: null
-    app_path: '/var/flowdat/stats'
+    app_path: '/opt/stats'
     geoserver_service: true
-    geoserver_host: 127.0.0.1
-    geoserver_port: 8080
+    geoserver_host: '%env(HOST_GEOSERVER)%'
+    geoserver_port: 8082
     geoserver_user: admin
     geoserver_pass: geoserver
-    geoserver_path_shapes: '/var/flowdat/geoserver-shapes'
+    geoserver_path_shapes: '/var/www/shapes'
     device_server_base: 1
     # Url del webservice de crontab para crear los archivos
     url_crontab: http://127.0.0.1/cron.php?wsdl
@@ -55,6 +55,8 @@ parameters:
     env(HOST_REDIS): "127.0.0.1"
     redis.connection : "tcp://%env(HOST_REDIS)%:6379"
 
+    # nombre del servicio del nginx
+    nginx_name: nginx-proxy
     env(HOST_STATSD): '127.0.0.1'
     statsd:
       host: %env(HOST_STATSD)%

+ 9 - 4
app/config/parameters.yml.docker

@@ -35,13 +35,13 @@ parameters:
     db_session_name: fd_session
     db_session_user: root
     db_session_password: 235r2342gtfsw
-    app_path: '/var/flowdat/stats'
+    app_path: '/opt/stats'
     geoserver_service: true
-    geoserver_host: 127.0.0.1
-    geoserver_port: 8080
+    geoserver_host: '%env(HOST_GEOSERVER)%'
+    geoserver_port: 8082
     geoserver_user: admin
     geoserver_pass: geoserver
-    geoserver_path_shapes: '/var/flowdat/geoserver-shapes'
+    geoserver_path_shapes: '/var/www/shapes'
     device_server_base: 1
     url_crontab: http://supervisord/cron.php?wsdl
     env(HOST_BASE): base
@@ -51,6 +51,11 @@ parameters:
     cookie_domain_client: '%env(CLIENT)%'
     cookie_domain: '%cookie_domain_client%.flowdat.com'
     session_names: [flowdat_base_session, flowdat_ftth_session, flowdat_mapas_session, flowdat_stats_session, flowdat_radius_session, flowdat_cablemodem_session]
+    env(REDIS_HOST): "127.0.0.1"
+    redis.connection : "tcp://%env(REDIS_HOST)%:6379" 
+
+    # nombre del servicio del nginx
+    nginx_name: nginx-proxy
     env(REDIS_HOST): "127.0.0.1" #Hay que borrar y usar HOST_REDIS
     env(HOST_REDIS): "127.0.0.1"
     redis.connection : "tcp://%env(HOST_REDIS)%:6379"

+ 15 - 3
app/config/security.yml

@@ -10,15 +10,27 @@ security:
             
     firewalls:
         dev:
+            # es una llave que se utiliza para guardar y traer los datos de la session. Los firewalls que posean
+            # el mismo context, van a compartir la informacion. PARA QUE FUNCION "stateless" debe estar en FALSE
+            context: ik_share
+            stateless: false
             pattern: ^/(_(profiler|wdt)|css|images|js)/
             security: false
         
         api:
-          pattern: ^/api
-          stateless: true
-          oauth_proxy: true    
+            # es una llave que se utiliza para guardar y traer los datos de la session. Los firewalls que posean
+            # el mismo context, van a compartir la informacion. PARA QUE FUNCION "stateless" debe estar en FALSE
+            context: ik_share
+            stateless: false
+            pattern: ^/api
+            stateless: true
+            oauth_proxy: true
             
         secured_area:
+            # es una llave que se utiliza para guardar y traer los datos de la session. Los firewalls que posean
+            # el mismo context, van a compartir la informacion. PARA QUE FUNCION "stateless" debe estar en FALSE
+            context: ik_share
+            stateless: false
             pattern: ^/
             logout:
                 path:   /logout

+ 27 - 28
composer.json

@@ -28,84 +28,84 @@
             "type": "vcs",
             "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseAdmin.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
             "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/Webservice.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-            "url":  "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseOAuthClientBundle.git",
+            "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseOAuthClientBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-            "url":  "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/DeviceBundle.git",
+            "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/DeviceBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-            "url":  "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/ExtraDataBundle.git",
+            "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/ExtraDataBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-	    "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/OwnerVoter.git",
+            "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/OwnerVoter.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-	    "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/RedisBundle.git",
+            "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/RedisBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-	    "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/StatsDBundle.git",
+            "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/StatsDBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-			"url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseStatsBundle.git",
+            "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseStatsBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-			"url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/FiberhomeBundle.git",
+            "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/FiberhomeBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
-			"url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/HuaweiBundle.git",
+            "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/HuaweiBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
             "type": "vcs",
             "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/FiberlinkBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
@@ -119,7 +119,7 @@
             "type": "vcs",
 			"url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/GeoserverBundle.git",
             "options": {
-                    "local_pk": "./keys/bitbucket.id_rsa"
+                "local_pk": "./keys/bitbucket.id_rsa"
             }
         },
         {
@@ -131,7 +131,7 @@
         },
         {
             "type": "vcs",
-            "url":  "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/LeafletBundle.git"
+            "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/LeafletBundle.git"
         },
         {
             "type": "vcs",
@@ -169,7 +169,7 @@
         "doctrine/doctrine-cache-bundle": "^1.2",
         "doctrine/doctrine-migrations-bundle": "^1.2",
         "doctrine/orm": "^2.5",
-	"jdorn/sql-formatter": "~1.2.17",
+        "jdorn/sql-formatter": "~1.2.17",
         "ik/audit-bundle": "dev-master",
         "ik/auth-bundle": "dev-master",
         "ik/base-admin-bundle": "dev-master",
@@ -224,19 +224,18 @@
             "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
             "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
         ],
-	"doctrine-update": "php bin/console doctrine:schema:update --force",
-        "doctrine-migrations":"php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration",
+        "doctrine-update": "php bin/console doctrine:schema:update --force",
+        "doctrine-migrations": "php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration",
         "mkdir-dir-cache-sessions-logs": "mkdir -p var/cache var/logs var/sessions",
         "chmod-dir-cache-sessions-logs": "chmod 777 -R var/cache var/logs var/sessions",
         "migration-alert-type": "php bin/console doctrine:migrations:execute 20170627144029 --no-interaction",
         "auto-increment": "php bin/console baseadmin:autoincrement",
-
         "post-install-cmd": [
             "@symfony-scripts",
             "@chmod-dir-cache-sessions-logs",
             "@doctrine-update",
             "@doctrine-migrations",
-            "@auto-increment" 
+            "@auto-increment"
         ],
         "post-update-cmd": [
             "@symfony-scripts",

+ 0 - 6
src/StatsBundle/Command/StatsPonPortCommand.php

@@ -44,18 +44,12 @@ class StatsPonPortCommand extends BaseCommand
         $tenancyId = $deviceOlt->getTenancyId();
         $deviceServerId = $oltServerId;
         
-        $flag = "olt_scan_pons_d_{$oltDeviceId}_s_{$oltServerId}.lock";
-        
         $key_pon_stats = "olt_stats_pons_d_{$oltDeviceId}_s_{$oltServerId}";
         
-        /* Control de bloqueo */
-        if($this->lock($flag)) {return;}
-        
         $ponsCached = $this->getData($key_pon_stats, true);
 
         if(empty($ponsCached)) {
             $this->output->writeln("Se requiere {$key_pon_stats}.");
-            $this->removeLock($flag);
             return true;
         }