Browse Source

cambios menores

Luciano Andrade 7 years ago
parent
commit
be65decb8b
1 changed files with 82 additions and 82 deletions
  1. 82 82
      src/StatsBundle/Command/GenerateRemoteCrontabCommand.php

+ 82 - 82
src/StatsBundle/Command/GenerateRemoteCrontabCommand.php

@@ -10,84 +10,84 @@ use Symfony\Component\Console\Output\OutputInterface;
 class GenerateRemoteCrontabCommand extends ContainerAwareCommand
 {
 
-    protected function configure()
-    {
-        $this
-            ->setName('stats:crontab:remote')
-            ->setDescription('Generate Remote Stats Crontab File')
-            ->setHelp('El comando genera/actualiza el archivo crontab de manera remota para realizar consultas a dispositivos')
-            ->setDefinition(array(
-                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),
-                new InputOption('routing_key', false, InputOption::VALUE_OPTIONAL, "AMQP Routing key"),
-            ))
-        ;
-    }
-
-    /**
-     * @param InputInterface $input
-     * @param OutputInterface $output
-     */
-    protected function execute(InputInterface $input, OutputInterface $output)
-    {
-        $this->output = $output;
-        $fileCrontab = $input->getOption('file-crontab');
-        $pathApp = $input->getOption('path-app');
-        $url = $input->getOption('url');
-        if (is_null($url)) {
-            if ($this->getContainer()->hasParameter('url_crontab')) {
-                $url = $this->getContainer()->getParameter('url_crontab');
-            } else {
-                $output->writeln('<error>ERROR:</error> Debe definir una url para generar el crontab.');
-                $output->writeln($this->getSynopsis());
-
-                return;
-            }
-        }
-
-        $times = array();
-        $now = date("d-m-Y H:i:s");
-        $content = PHP_EOL."# NO EDITAR este archivo, se autogenera con el comando stats:crontab:remote. Generado {$now}.".PHP_EOL;
-
-        $doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
-        
-        if(is_null($pathApp)) {
-            $pathApp = $this->getContainer()->getParameter('app_path');
-        }
-        $pathConsole = "root $(wich php) {$pathApp}/bin/console"; 
-        
-        $serverDevices = $doctrine->getRepository('\StatsBundle\Entity\DeviceServer')->findAll();
-        
-        $oltMarks = array('FiberHome','FiberLink','Huawei');
-        $oltLibraries = array('OIDSFiberHomeV1','OIDSHuaweiV1');
-
-        $amqp = $input->getOption('amqp');
-        $amqpRemote = '';
-        $routing_key = '';
-        if ($amqp) {
-            $amqpRemote = 'amqp:remote';
-            
-            // Verifico la routing key si se pasa como parametro o variable de entorno
-            // default routing_key = stats
-            $routing_key = $input->getOption('routing_key');
-            if (!$routing_key) {
-                $routing_key = getenv('AMQP_KEY') !== false ? getenv('AMQP_KEY') : 'stats';
-            }
-            $routing_key = "--route={$routing_key}";
-        }
-        
-        $content .= "*/5 * * * * {$pathConsole} {$amqpRemote} {$routing_key} generate:crontab".PHP_EOL;
-
-        foreach($serverDevices as $server) {
-
-            $content .= PHP_EOL.PHP_EOL."# SERVER {$server->getName()} / {$server->getUrl()}".PHP_EOL;
-        
-            // APARTADO OLT
-            $oltDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'FTTHBundle\Entity\OLT','deviceServer' => $server));
-
-            $serverId = $server->getId();
+	protected function configure()
+	{
+		$this
+			->setName('stats:crontab:remote')
+			->setDescription('Generate Remote Stats Crontab File')
+			->setHelp('El comando genera/actualiza el archivo crontab de manera remota para realizar consultas a dispositivos')
+			->setDefinition(array(
+						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", "/opt/stats""),
+						new InputOption('url', false, InputOption::VALUE_OPTIONAL, "Crontab webservice url"),
+						new InputOption('amqp', false, InputOption::VALUE_OPTIONAL, "Execute the commands via amqp", true),
+						new InputOption('routing_key', false, InputOption::VALUE_OPTIONAL, "AMQP Routing key"),
+					     ))
+			;
+	}
+
+	/**
+	 * @param InputInterface $input
+	 * @param OutputInterface $output
+	 */
+	protected function execute(InputInterface $input, OutputInterface $output)
+	{
+		$this->output = $output;
+		$fileCrontab = $input->getOption('file-crontab');
+		$pathApp = $input->getOption('path-app');
+		$url = $input->getOption('url');
+		if (is_null($url)) {
+			if ($this->getContainer()->hasParameter('url_crontab')) {
+				$url = $this->getContainer()->getParameter('url_crontab');
+			} else {
+				$output->writeln('<error>ERROR:</error> Debe definir una url para generar el crontab.');
+				$output->writeln($this->getSynopsis());
+
+				return;
+			}
+		}
+
+		$times = array();
+		$now = date("d-m-Y H:i:s");
+		$content = PHP_EOL."# NO EDITAR este archivo, se autogenera con el comando stats:crontab:remote. Generado {$now}.".PHP_EOL;
+
+		$doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
+
+		if(is_null($pathApp)) {
+			$pathApp = $this->getContainer()->getParameter('app_path');
+		}
+		$pathConsole = "root $(wich php) {$pathApp}/bin/console"; 
+
+		$serverDevices = $doctrine->getRepository('\StatsBundle\Entity\DeviceServer')->findAll();
+
+		$oltMarks = array('FiberHome','FiberLink','Huawei');
+		$oltLibraries = array('OIDSFiberHomeV1','OIDSHuaweiV1');
+
+		$amqp = $input->getOption('amqp');
+		$amqpRemote = '';
+		$routing_key = '';
+		if ($amqp) {
+			$amqpRemote = 'amqp:remote';
+
+			// Verifico la routing key si se pasa como parametro o variable de entorno
+			// default routing_key = stats
+			$routing_key = $input->getOption('routing_key');
+			if (!$routing_key) {
+				$routing_key = getenv('AMQP_KEY') !== false ? getenv('AMQP_KEY') : 'stats';
+			}
+			$routing_key = "--route={$routing_key}";
+		}
+
+		$content .= "*/5 * * * * {$pathConsole} {$amqpRemote} {$routing_key} generate:crontab".PHP_EOL;
+
+		foreach($serverDevices as $server) {
+
+			$content .= PHP_EOL.PHP_EOL."# SERVER {$server->getName()} / {$server->getUrl()}".PHP_EOL;
+
+			// APARTADO OLT
+			$oltDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'FTTHBundle\Entity\OLT','deviceServer' => $server));
+
+			$serverId = $server->getId();
 
             foreach($oltDevices as $device) {
                 $commands = array();
@@ -123,9 +123,9 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
                 $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:stats {$params}";
                 $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:octets {$params}";
                 
-                $params = '--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}';
+                    $params = "--args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
                 }
                 $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:onu {$params}";
                 $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:ponport {$params}";
@@ -138,9 +138,9 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
             if($this->getContainer()->getParameter('geoserver_service')) {
                 $content .= PHP_EOL.PHP_EOL."# MAPAS".PHP_EOL;
                 
-                $params = '--olt-server-id={$serverId}';
+                $params = "--olt-server-id={$serverId}";
                 if ($amqp) {
-                    $params = '--args=--olt-server-id:{$serverId}';
+                    $params = "--args=--olt-server-id:{$serverId}";
                 }
                 
                 $commands = array();