Browse Source

FD3-231 Se ejecuta el comando stats:crontab:remote por amqp. Se agregó ik/workflow-bundle para comandos amqp

Guillermo Espinoza 7 năm trước cách đây
mục cha
commit
5aa69fd1ba

+ 1 - 0
app/AppKernel.php

@@ -48,6 +48,7 @@ class AppKernel extends Kernel
             new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
             new AuditBundle\AuditBundle(),
             new AuthBundle\AuthBundle(),
+            new WorkflowBundle\WorkflowBundle(),
         ];
 
         if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {

+ 1 - 1
bin/symfony_requirements

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 
-require_once dirname(__FILE__).'/./SymfonyRequirements.php';
+require_once dirname(__FILE__).'/../var/SymfonyRequirements.php';
 
 $lineSize = 70;
 $symfonyRequirements = new SymfonyRequirements();

+ 8 - 0
composer.json

@@ -121,6 +121,13 @@
             "options": {
                 "local_pk": "./keys/bitbucket.id_rsa"
             }
+        },
+        {
+            "type": "vcs",
+            "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
+            "options": {
+                "local_pk": "./keys/bitbucket.id_rsa"
+            }
         }
     ],
     "require": {
@@ -144,6 +151,7 @@
         "ik/statsd-bundle": "dev-master",
         "ik/webservice-bundle": "dev-master",
         "ik/auth-bundle": "dev-master",
+        "ik/workflow-bundle": "dev-master",
         "incenteev/composer-parameter-handler": "^2.0",
         "jms/serializer-bundle": "^1.1",
         "opensolutions/oss-snmp": "dev-master",

+ 40 - 1
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": "9537de2fe076710e88c8f05bceddb60a",
+    "content-hash": "526c383a2193f75afd3e8a1536a268de",
     "packages": [
         {
             "name": "behat/transliterator",
@@ -1730,6 +1730,44 @@
             "description": "The Flowdat3 Webservice Rest",
             "time": "2017-09-28 12:29:30"
         },
+        {
+            "name": "ik/workflow-bundle",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
+                "reference": "1dc7182ffb1ee1528d4d216d9069b1ba00aabb8b"
+            },
+            "require": {
+                "php-amqplib/rabbitmq-bundle": "^1.12"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "WorkflowBundle\\": ""
+                }
+            },
+            "scripts": {
+                "workflows-commands": [
+                    "chown -Rf www-data:www-data app/Resources/workflows",
+                    "cp -n app/Resources/workflows/workflow_list.yml.dist app/Resources/workflows/workflow_list.yml",
+                    "chown -Rf www-data:www-data app/Resources/workflows/workflow_list.yml",
+                    "chown -Rf www-data:www-data web/workflows_png"
+                ],
+                "post-install-cmd": [
+                    "@workflows-commands"
+                ],
+                "post-update-cmd": [
+                    "@workflows-commands"
+                ]
+            },
+            "description": "Flowdat 3 Workflow Bundle",
+            "keywords": [
+                "bundle",
+                "workflow"
+            ],
+            "time": "2017-10-02 12:28:48"
+        },
         {
             "name": "incenteev/composer-parameter-handler",
             "version": "v2.1.2",
@@ -6185,6 +6223,7 @@
         "ik/statsd-bundle": 20,
         "ik/webservice-bundle": 20,
         "ik/auth-bundle": 20,
+        "ik/workflow-bundle": 20,
         "opensolutions/oss-snmp": 20,
         "voryx/restgeneratorbundle": 20
     },

+ 31 - 13
src/StatsBundle/Command/GenerateRemoteCrontabCommand.php

@@ -20,6 +20,7 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 new InputOption('file-crontab', false, InputOption::VALUE_OPTIONAL, "File Crontab","/etc/cron.d/fd3_stats"),
                 new InputOption('path-app', false, InputOption::VALUE_OPTIONAL, "Path App"),
                 new InputOption('url', false, InputOption::VALUE_OPTIONAL, "Crontab webservice url"),
+                new InputOption('amqp', false, InputOption::VALUE_OPTIONAL, "Execute the commands via amqp", true),
             ))
         ;
     }
@@ -61,7 +62,12 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
         $oltMarks = array('FiberHome','FiberLink','Huawei');
         $oltLibraries = array('OIDSFiberHomeV1','OIDSHuaweiV1');
 
-        $content .= "*/5 * * * * {$pathConsole} generate:crontab".PHP_EOL;
+        $amqp = $input->getOption('amqp');
+        $amqpRemote = '';
+        if ($amqp) {
+            $amqpRemote = 'amqp:remote';
+        }
+        $content .= "*/5 * * * * {$pathConsole} {$amqpRemote} generate:crontab".PHP_EOL;
 
         foreach($serverDevices as $server) {
 
@@ -95,30 +101,42 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $timeOltOctets = $data['timeOltOctets'];
 
                 $params = "--olt-ip={$deviceIp} --olt-community={$snmpCommunity} --olt-snmp-library={$library} --olt-device-id={$deviceId} --olt-server-id={$serverId}";
-                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$mark}:pon:scan {$params}";
-                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$mark}:onu:scan {$params}";
+                if ($amqp) {
+                    $params = "--args=--olt-ip:{$deviceIp} --args=--olt-community:{$snmpCommunity} --args=--olt-snmp-library:{$library} --args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
+                }
+
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$mark}:pon:scan {$params}";
+                $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$mark}:onu:scan {$params}";
                 
-                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$mark}:onu:stats {$params}";
-                $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$mark}:pon:stats {$params}";
-                $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$mark}:pon:octets {$params}";
+                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$mark}:onu:stats {$params}";
+                $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$amqpRemote} {$mark}:pon:stats {$params}";
+                $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$mark}:pon:octets {$params}";
                 
-                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} stats:onu --olt-device-id={$deviceId} --olt-server-id={$serverId}";
-                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} stats:ponport --olt-device-id={$deviceId} --olt-server-id={$serverId}";
+                $params = '--olt-device-id={$deviceId} --olt-server-id={$serverId}';
+                if ($amqp) {
+                    $params = '--args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}';
+                }
+                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} stats:onu {$params}";
+                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} stats:ponport {$params}";
                 
                 $content .= PHP_EOL."# OLT {$oltName} ({$deviceIp})".PHP_EOL;
                 
-                $content .= implode(PHP_EOL,$commands);
+                $content .= implode(PHP_EOL, $commands);
             }
             
             if($this->getContainer()->getParameter('geoserver_service')) {
                 $content .= PHP_EOL.PHP_EOL."# MAPAS".PHP_EOL;
                 
-                $commands = array();
-                $commands[] = "*/5 * * * * {$pathConsole} stats:onu:geo --olt-server-id={$serverId}";
-                $commands[] = "*/10 * * * * {$pathConsole} stats:ponport:geo --olt-server-id={$serverId}";
+                $params = '--olt-server-id={$serverId}';
+                if ($amqp) {
+                    $params = '--args=--olt-server-id:{$serverId}';
+                }
                 
-                $content .= implode(PHP_EOL,$commands);
+                $commands = array();
+                $commands[] = "*/5 * * * * {$pathConsole} {$amqpRemote} stats:onu:geo {$params}";
+                $commands[] = "*/10 * * * * {$pathConsole} {$amqpRemote} stats:ponport:geo {$params}";
                 
+                $content .= implode(PHP_EOL, $commands);
                 $content .= PHP_EOL;
             }
         }

+ 1 - 1
web/config.php

@@ -22,7 +22,7 @@ if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
     exit('This script is only accessible from localhost.');
 }
 
-require_once dirname(__FILE__).'/./SymfonyRequirements.php';
+require_once dirname(__FILE__).'/../var/SymfonyRequirements.php';
 
 $symfonyRequirements = new SymfonyRequirements();