1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace FTTHBundle\Command;
- use FTTHBundle\Entity\ONU;
- use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- /**
- * Class ONUStatusOLTCommand
- * Update the status of olt comunication
- * @package FTTHBundle\Command
- */
- class ONUStatusOLTCommand extends ContainerAwareCommand
- {
- protected function configure()
- {
- $this
- ->setName('ik:onu:statusolt')
- ->setDescription('Set the status of the execution of the script against the olt')
- ->setHelp('Set the status of the execution of the script against the olt')
- ->addArgument('onuid', InputArgument::REQUIRED, 'Pon serial number')
- ->addArgument('file', InputArgument::REQUIRED, 'File log')
- ->addArgument('status', InputArgument::REQUIRED, 'Status 0 (OK), 1 (ERROR) other value (PENDING)');
- }
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- try {
- $em = $this->getContainer()->get('doctrine')->getManager();
- $onuid = $input->getArgument('onuid');
- $file = $input->getArgument('file');
- $status = $input->getArgument('status');
- $onu = $em->getRepository(ONU::class)->findById($onuid);
- if ($onu && count($onu) > 0) {
- $onu = $onu[0];
- if ($status == 1) {
- $status = "ERROR";
- } elseif ($status == 0) {
- $status = "OK";
- } else {
- $status = "PENDING";
- }
- $onu->getLogOLT()->setStatus($status);
- $onu->getLogOLT()->setDirectory($file);
- $onu->getLogOLT()->setDate(new \DateTime());
- $em->flush();
- }
- } catch (\Throwable $e) {
- echo("\nERROR CODE: " . $e->getCode() . "\nERROR MESSAGE: " . $e->getMessage() . "\n");
- echo("\nTRACE: \n" . $e->getTraceAsString() . "\n\n");
- }
- }
- }
|