Kaynağa Gözat

FD3-140 Se actualiza vendor fiberhome-bundle. Se agrega entidad Onu al
módulo Stats y se le agrega atributos para asociarlas con la OLT y
Servidor al cual pertenecen, se agregan atributos para guardar
estadísticas. Se crea comando para leer valores de redis y guardarlos en
la entidad Onu para poder mostrarlos en listado como se realiza hoy en
FD2.

Maximiliano Schvindt 7 yıl önce
ebeveyn
işleme
f8cf798280

+ 4 - 0
app/config/routing.yml

@@ -40,3 +40,7 @@ base_oauth_client:
     
 base_hwioauthbundle_oauth_client:
     resource: "@BaseOAuthClientBundle/Resources/config/hwioauthbundle/routing.yml"    
+
+admin_tenancy_change_tenancy_global_ajax:
+    path: changeTenancyAjaxAction
+    defaults: { _controller: BaseAdminBundle:RedirectionAjax:changeTenancyAjax }

+ 6 - 6
composer.lock

@@ -1262,7 +1262,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseAdmin.git",
-                "reference": "b6ad2dfffe165ea3965973074fc78735770f2f9d"
+                "reference": "a62ae709daf7f900018c3f56f1e39c36bfbd5e61"
             },
             "type": "library",
             "autoload": {
@@ -1277,7 +1277,7 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2017-08-01 17:52:58"
+            "time": "2017-08-03 18:52:52"
         },
         {
             "name": "ik/device-bundle",
@@ -1331,7 +1331,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseOAuthClientBundle.git",
-                "reference": "0118134e5c0a4731b2f54328a960756bb83ac32e"
+                "reference": "b00d775523cf292ef5a8403f08a88584b36c8a28"
             },
             "require": {
                 "ext-curl": "*",
@@ -1350,7 +1350,7 @@
                 "bundle",
                 "oauth"
             ],
-            "time": "2017-04-06 15:40:13"
+            "time": "2017-08-02 14:10:32"
         },
         {
             "name": "ik/owner-voter-bundle",
@@ -1405,7 +1405,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/FiberhomeBundle.git",
-                "reference": "8f050892e6e5d4604d023b869a401a640755f1fb"
+                "reference": "45ae78218b6e8bb0548f373afafebbbcfed10a70"
             },
             "type": "library",
             "autoload": {
@@ -1418,7 +1418,7 @@
                 "Fiberhome",
                 "Flowdat 3"
             ],
-            "time": "2017-07-31 12:18:23"
+            "time": "2017-08-09 13:22:08"
         },
         {
             "name": "ik/statsd-bundle",

+ 85 - 0
src/StatsBundle/Admin/OnuAdmin.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace StatsBundle\Admin;
+
+use Base\AdminBundle\Admin\BaseAdmin;
+use Sonata\AdminBundle\Datagrid\DatagridMapper;
+use Sonata\AdminBundle\Datagrid\ListMapper;
+use Sonata\AdminBundle\Form\FormMapper;
+use Sonata\AdminBundle\Show\ShowMapper;
+use DeviceBundle\Utils\DeviceTypes;
+use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
+
+class OnuAdmin extends BaseAdmin
+{
+
+    /**
+     * @param DatagridMapper $datagridMapper
+     */
+    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
+    {
+        $datagridMapper
+            ->add('oltDeviceId')
+            ->add('deviceServer')
+            ->add('tenancyId')
+            ->add('ponSerialNumber')
+            ->add('ponPort')
+            ->add('status')
+        ;
+    }
+
+    /**
+     * @param ListMapper $listMapper
+     */
+    protected function configureListFields(ListMapper $listMapper)
+    {
+        $listMapper
+            ->add('deviceServer')
+            ->add('oltDeviceId')
+            ->add('tenancyId')
+            ->add('ponSerialNumber')
+            ->add('ponPort')
+            ->add('status')
+            ->add('txPower')
+            ->add('rxPower')
+            ->add('voltage')
+            ->add('temperature')
+            ->add('uptime')
+            ->add('updated')
+            ->add('_action', null, array(
+                'actions' => array('show' => array())
+                ))
+        ;
+    }
+
+    /**
+     * @param FormMapper $formMapper
+     */
+    protected function configureFormFields(FormMapper $formMapper)
+    {
+    }
+
+    /**
+     * @param ShowMapper $showMapper
+     */
+    protected function configureShowFields(ShowMapper $showMapper)
+    {
+    }
+
+    /**
+     * @param string $action
+     * @param Object $object
+     * 
+     * @return array
+     */
+    public function configureActionButtons($action, $object = null)
+    {
+        $actions = parent::configureActionButtons($action, $object);
+        //$actions['update_devices'] = array(
+        //    'template' => 'StatsBundle:Device:update_devices_button.html.twig',
+        //);
+
+        return $actions;
+    }
+
+}

+ 179 - 0
src/StatsBundle/Command/BaseCommand.php

@@ -0,0 +1,179 @@
+<?php
+
+namespace StatsBundle\Command;
+
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+abstract class BaseCommand extends ContainerAwareCommand
+{
+    /**
+     * @var CollectorInterface
+     */
+    protected $collector;
+
+    /**
+     * @var string
+     */
+    protected $pathLock = "/var/run/flowdat3/stats";
+
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        $this->output = $output;
+        $this->setCollector();
+        
+        return;
+    }
+
+    protected function setCollector()
+    {
+        $this->collector = $this->getContainer()->get("redis");
+    }
+    
+    /**
+     * @param string $key
+     * @return array
+     */
+    protected function getData($key, $output = false)
+    {   
+        return $this->collector->get($key, $output);
+    }
+    
+    /**
+     * @param string $key
+     * @param array $data
+     */
+    protected function setData($key, $data, $output = false)
+    {
+        $this->collector->set($key, $data, $output);
+    }
+    
+    /**
+     * @param string $key
+     * @param string $data
+     */
+    protected function getString($key, $output = false)
+    {
+        return $this->collector->getString($key, $output);
+    }
+
+    /**
+     * @param array $queries
+     * @return 
+     */
+    protected function executeQueries($queries)
+    {
+        $result = null;
+        $conn = $this->getContainer()->get('database_connection');
+        foreach ($queries as $query)
+        {
+            $result = $conn->query($query);
+        }
+        $conn->close();
+        
+        return $result;
+    }
+    
+    /**
+     * 
+     * @param string $flag
+     * @return boolean
+     * 
+     * Description: Retorna true si existe el bloqueo. False si no existe bloqueo o no puede determinar la existencia.
+     */
+    
+    protected function lock($flag) {
+
+        $mypid = getmypid();
+        $file = $this->pathLock. "/" . $flag;
+        
+        if (!is_dir($this->pathLock)) {mkdir($this->pathLock, 0777, true);}
+        
+        if (is_null($flag)) return false;
+
+        if (file_exists($file)) {
+
+            $handle = fopen($file, "r");
+            $contenido = fread($handle, filesize($file));
+            fclose($handle);
+            $data = explode("\n", $contenido);
+            
+            if(count($data) == 2) {
+                if (isset($data[0]) && isset($data[1])) {
+                    
+                    $pid = explode("=",$data[0]);
+                    $time = explode("=",$data[1]);
+                    
+                    $pid_flag = (int) $pid[1];
+                    $time_flag = (int) $time[1];
+                    
+                    if (posix_kill($pid_flag, 0)) {
+                        $now = time();
+                        $lapse = $now - $time_flag;
+                        
+                        $limit_time = 60 * 15;
+                        if($lapse > $limit_time) {
+                            print_r("Superado 15 min de ejecución, finalizamos proceso anterior(pid: {$pid_flag}).".PHP_EOL);
+                            if (posix_kill($pid_flag, 9)) {
+                                print_r("Finalizado con éxito".PHP_EOL);
+                            } else {
+                                print_r("Ocurrió un problema, no pudo finalizarse el proceso".PHP_EOL);
+                            }
+                        } else {
+                            print_r("Esperamos el proceso anterior(pid: {$pid_flag}) a que finalice. Tiempo actual de ejecución: {$lapse} segundos.".PHP_EOL);
+                            return true;
+                        }
+                    }
+                }
+            }
+            @unlink($file);
+        }
+
+        $time = time();
+        $data = "pid={$mypid}\ntime={$time}";
+        $handle = fopen($file, "w+");
+        fwrite($handle, $data);
+        fclose($handle);
+
+        return false;
+    }
+    
+    /**
+     * 
+     * @param string $flag
+     * @return boolean
+     * 
+     * Description: Retorna true si pudo borrarse el archivo de bloqueo. False en cualquier otro caso.
+     */
+    
+    protected function removeLock($flag) {
+        
+        if (is_null($flag)) return false;
+
+        $file = $this->pathLock . "/" . $flag;
+        unlink($file);
+        
+        if(!file_exists($file)) return true;
+        
+        return false;
+    }
+    
+    /**
+     * 
+     * @param string $v
+     * @return array
+     * 
+     * Description: Retorna el tipo de valor y el valor mismo de una respuesta SNMP para Octets
+     */
+    protected function parseSnmpOctetsValue($v) {
+        
+        if( $v == '""' || $v == '' ) return array();
+
+        $type = substr( $v, 0, strpos( $v, ':' ) );
+        $value = trim( substr( $v, strpos( $v, ':' ) + 1 ) );
+        
+        return array(0=>$type,1=>(int)$value);
+    }
+}

+ 3 - 1
src/StatsBundle/Command/GenerateCrontabCommand.php

@@ -79,7 +79,7 @@ class GenerateCrontabCommand extends ContainerAwareCommand
                 $library = $data['library'];
                 $snmpCommunity = $data['snmpCommunity'];
                 $deviceIp = $device->getIp();
-                $deviceId = $device->getId();
+                $deviceId = $device->getDeviceId();
 
                 $timeScan = $data['timeScan'];
                 $timeOnuStats = $data['timeOnuStats'];
@@ -94,6 +94,8 @@ class GenerateCrontabCommand extends ContainerAwareCommand
                 $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$mark}:pon:stats {$params}";
                 $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$mark}:pon:octets {$params}";
                 
+                $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} stats:onu --olt-device-id={$deviceId} --olt-server-id={$serverId}";
+                
                 fwrite($handle, PHP_EOL."# OLT {$oltName} ({$deviceIp})".PHP_EOL);
                 
                 fwrite($handle, implode(PHP_EOL,$commands));

+ 101 - 0
src/StatsBundle/Command/StatsOnuCommand.php

@@ -0,0 +1,101 @@
+<?php
+
+namespace StatsBundle\Command;
+
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use StatsBundle\Services\DeviceManager;
+
+class StatsOnuCommand extends BaseCommand
+{
+
+    protected function configure()
+    {
+        $this
+            ->setName('stats:onu')
+            ->setDescription('Update ONU Stats')
+            ->setHelp('Actualiza la tabla ONU con los datos obtenidos del OLT definido')
+            ->setDefinition(array(
+                new InputOption('olt-device-id', null, InputOption::VALUE_OPTIONAL, "DeviceId de la OLT", 1),
+                new InputOption('olt-server-id', null, InputOption::VALUE_OPTIONAL, "ServerDevice de la OLT", 1)
+            ))
+        ;
+    }
+
+    /**
+     * @param InputInterface $input
+     * @param OutputInterface $output
+     */
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        parent::execute($input, $output);
+
+        $oltDeviceId = (int) $input->getOption('olt-device-id');
+        $oltServerId = (int) $input->getOption('olt-server-id');
+
+        $now = date("d-m-Y H:i:s");
+
+        $doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
+        
+        $deviceOlt = $doctrine->getRepository('\StatsBundle\Entity\Device')->findOneBy(array('deviceId' => $oltDeviceId, 'deviceServer' => $oltServerId, 'deviceType' => 'FTTHBundle\Entity\OLT'));
+
+        $tenancyId = $deviceOlt->getTenancyId();
+        $deviceServerId = $oltServerId;
+        
+        $key_olt_scan = "olt_scan_d_{$oltDeviceId}_s_{$oltServerId}";
+
+        $metrics = array("txPower" => "onu_tx_", "rxPower" => "onu_rx_", "temperature" => "onu_temperature_", "voltage" => "onu_voltage_", "status" => "onu_status_");
+        $data = $stats = array();
+
+        foreach($metrics as $m => $metric) {
+            $key_onu_stats = "{$metric}d_{$oltDeviceId}_s_{$oltServerId}";
+            $stats[$metric] = $this->getData($key_onu_stats, true);
+        }
+
+        $onus = $this->getData($key_olt_scan, true);
+        
+        foreach($onus as $index => $onu) {
+            $sn = $onu['serialNumber'];
+            $row = array();
+            $row['deviceServer'] = $deviceServerId;
+            $row['deviceId'] = "NULL";
+            $row['oltDeviceId'] = $oltDeviceId;
+            $row['tenancyId'] = $tenancyId;
+            $row['ip'] = "NULL";
+            $row['mac'] = "NULL";
+            $row['serialNumber'] = "NULL";
+            $row['ponSerialNumber'] = "'".strtolower($sn)."'";
+            $row['ponPort'] = "'".$onu['ponport']."'";
+
+            foreach($metrics as $m => $metric) {
+                if(isset($stats[$metric][$sn])) {
+                    $row[$m] = $stats[$metric][$sn];
+                } else {
+                    $row[$m] = "NULL";
+                }
+            }
+
+            $row['uptime'] = "NULL";
+            $row['update'] = "'".date("Y-m-d H:i:s")."'";
+
+            $data[] = "(".implode(",",$row).")".PHP_EOL;
+        }
+
+        //print_r($data);
+
+        $conn = $doctrine->getConnection();
+        $sql = "DELETE FROM `onu` WHERE device_server_id = {$deviceServerId} AND olt_device_id = {$oltDeviceId};";
+        $conn->query($sql);
+        $conn->close();
+
+        $conn = $doctrine->getConnection();
+        $sql = "INSERT LOW_PRIORITY IGNORE INTO `onu` (`device_server_id`,`device_id`,`olt_device_id`,`tenancy_id`,`ip`,`mac`,`serial_number`,`pon_serial_number`,`pon_port`,`tx_power`,`rx_power`,`temperature`,`voltage`,`status`,`uptime`,`updated`) VALUES ".  implode(",", $data).";";
+        $conn->query($sql);
+        $conn->close();
+        
+
+    }
+
+}

+ 1 - 1
src/StatsBundle/Entity/Device.php

@@ -86,7 +86,7 @@ class Device
      */
     public function getId()
     {
-        return "id";
+        return $this->id;
     }
 
     /**

+ 482 - 0
src/StatsBundle/Entity/Onu.php

@@ -0,0 +1,482 @@
+<?php
+
+namespace StatsBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\Validator\Constraints as Assert;
+
+/**
+ * @ORM\Table
+ * @ORM\Entity
+ * 
+ */
+class Onu
+{
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="integer", nullable=true)
+     * 
+     */
+    private $deviceId;
+    
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="integer", nullable=true)
+     * 
+     */
+    private $oltDeviceId;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="DeviceServer", inversedBy="devices", fetch="EXTRA_LAZY")
+     * 
+     */
+    protected $deviceServer;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="integer", nullable=false, options={"default":1})
+     */
+    protected $tenancyId = 1;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=255, nullable=true)
+     * 
+     * @Assert\Ip
+     */
+    private $ip;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=12, nullable=true)
+     */
+    private $mac;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=25, nullable=true)
+     */
+    private $serialNumber;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=25, nullable=true)
+     */
+    private $ponSerialNumber;
+
+    /**
+     * @ORM\Column(type="string", length=25, nullable=true)
+     */
+    private $ponPort;
+
+    /**
+     * @ORM\Column(name="status", type="boolean", nullable=true, columnDefinition="BOOLEAN DEFAULT FALSE")
+     */
+    public $status = false;
+    
+    /**
+     * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
+     */
+    public $txPower;
+    
+    /**
+     * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
+     */
+    public $rxPower;
+    
+    /**
+     * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
+     */
+    public $voltage;
+    
+    /**
+     * @ORM\Column(type="decimal", precision=6, scale=3, nullable=true)
+     */
+    public $temperature;
+
+    /**
+     * @ORM\Column(type="string", length=25, nullable=true)
+     */
+    public $uptime;
+
+    /**
+     * @ORM\Column(type="datetime")
+     */
+    protected $updated;
+    
+
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return sprintf('%s %s', $this->deviceType, $this->ip);
+    }
+
+    /**
+     * @return string
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @param string $ip
+     *
+     * @return Device
+     */
+    public function setIp($ip = null)
+    {
+        $this->ip = $ip;
+
+        return $this;
+    }
+
+    /**
+     * @return string
+     */
+    public function getIp()
+    {
+        return $this->ip;
+    }
+
+    /**
+     * Set mac
+     *
+     * @param string $mac
+     *
+     * @return ONU
+     */
+    public function setMac($mac)
+    {
+        $this->mac = $mac;
+
+        return $this;
+    }
+
+    /**
+     * Get mac
+     *
+     * @return string
+     */
+    public function getMac()
+    {
+        return $this->mac;
+    }
+
+    /**
+     * Set serialNumber
+     *
+     * @param string $serialNumber
+     *
+     * @return ONU
+     */
+    public function setSerialNumber($serialNumber)
+    {
+        $this->serialNumber = $serialNumber;
+
+        return $this;
+    }
+
+    /**
+     * Get serialNumber
+     *
+     * @return string
+     */
+    public function getSerialNumber()
+    {
+        return $this->serialNumber;
+    }
+
+    /**
+     * Set ponSerialNumber
+     *
+     * @param string $ponSerialNumber
+     *
+     * @return ONU
+     */
+    public function setPonSerialNumber($ponSerialNumber)
+    {
+        $this->ponSerialNumber = $ponSerialNumber;
+
+        return $this;
+    }
+
+    /**
+     * Get ponSerialNumber
+     *
+     * @return string
+     */
+    public function getPonSerialNumber()
+    {
+        return $this->ponSerialNumber;
+    }
+
+     /**
+     * Set ponPort
+     *
+     * @param string $ponPort
+     *
+     * @return ONU
+     */
+    public function setPonPort($ponPort)
+    {
+        $this->ponPort = $ponPort;
+
+        return $this;
+    }
+
+    /**
+     * Get ponPort
+     *
+     * @return string
+     */
+    public function getPonPort()
+    {
+        return $this->ponPort;
+    }
+
+    /**
+     * @param int $deviceId
+     *
+     * @return ONU
+     */
+    public function setDeviceId($deviceId)
+    {
+        $this->deviceId = $deviceId;
+
+        return $this;
+    }
+
+    /**
+     * @return int
+     */
+    public function getDeviceId()
+    {
+        return $this->deviceId;
+    }
+    
+    /**
+     * @param int $oltDeviceId
+     *
+     * @return ONU
+     */
+    public function setOltDeviceId($oltDeviceId)
+    {
+        $this->oltDeviceId = $oltDeviceId;
+
+        return $this;
+    }
+
+    /**
+     * @return int
+     */
+    public function getOltDeviceId()
+    {
+        return $this->oltDeviceId;
+    }
+
+    /**
+     * @return DeviceServer
+     */
+    public function getDeviceServer()
+    {
+        return $this->deviceServer;
+    }
+
+    /**
+     * @param DeviceServer $deviceServer
+     *
+     * @return ONU
+     */
+    public function setDeviceServer($deviceServer)
+    {
+        $this->deviceServer = $deviceServer;
+
+        return $this;
+    }
+
+    public function getShortType() 
+    {
+        return str_replace("FTTHBundle\\Entity\\","",$this->deviceType);
+    }
+
+    /**
+     * Set tenancyId
+     *
+     * @param int $tenancyId
+     *
+     * @return ONU
+     */
+    public function setTenancyId($tenancyId)
+    {
+        $this->tenancyId = $tenancyId;
+
+        return $this;
+    }
+
+    /**
+     * Get tenancyId
+     *
+     * @return int
+     */
+    public function getTenancyId()
+    {
+        return $this->tenancyId;
+    }
+
+    /**
+     * Set updated
+     *
+     * @param Datetime $tenancyId
+     *
+     * @return ONU
+     */
+    public function setUpdated($updated)
+    {
+        $this->updated = $updated;
+
+        return $this;
+    }
+
+    /**
+     * Get updated
+     *
+     * @return \DateTime
+     */
+    public function getUpdated()
+    {
+        return $this->updated;
+    }
+
+    /**
+     * Set txPower
+     *
+     * @param decimal $txPower
+     * @return ONU
+     */
+    public function setTxPower($txPower)
+    {
+        $this->txPower = $txPower;
+        return $this;
+    }
+
+    /**
+     * Get txPower
+     *
+     * @return decimal 
+     */
+    public function getTxPower()
+    {
+        return $this->txPower;
+    }
+
+    /**
+     * Set rxPower
+     *
+     * @param decimal $rxPower
+     * @return ONU
+     */
+    public function setRxPower($rxPower)
+    {
+        $this->rxPower = $rxPower;
+        return $this;
+    }
+
+    /**
+     * Get rxPower
+     *
+     * @return decimal 
+     */
+    public function getRxPower()
+    {
+        return $this->rxPower;
+    }
+
+    /**
+     * Set voltage
+     *
+     * @param decimal $voltage
+     * @return ONU
+     */
+    public function setVoltage($voltage)
+    {
+        $this->voltage = $voltage;
+        return $this;
+    }
+
+    /**
+     * Get voltage
+     *
+     * @return decimal 
+     */
+    public function getVoltage()
+    {
+        return $this->voltage;
+    }
+
+    /**
+     * Set temperature
+     *
+     * @param decimal $temperature
+     * @return ONU
+     */
+    public function setTemperature($temperature)
+    {
+        $this->temperature = $temperature;
+        return $this;
+    }
+
+    /**
+     * Get temperature
+     *
+     * @return decimal 
+     */
+    public function getTemperature()
+    {
+        return $this->temperature;
+    }
+
+    /**
+     * Set uptime
+     *
+     * @param string $uptime
+     * @return ONU
+     */
+    public function setUptime($uptime)
+    {
+        $this->uptime = $uptime;
+        return $this;
+    }
+
+    /**
+     * Get uptime
+     *
+     * @return string 
+     */
+    public function getUptime()
+    {
+        return $this->uptime;
+    }
+
+}

+ 8 - 0
src/StatsBundle/Resources/config/services.yml

@@ -20,3 +20,11 @@ services:
     stats.device.manager:
         class: StatsBundle\Services\DeviceManager
         arguments: ['@doctrine.orm.entity_manager','@validator','@webservice']
+    
+    stats.admin.onu:
+        class: StatsBundle\Admin\OnuAdmin
+        arguments: [~, StatsBundle\Entity\Onu, SonataAdminBundle:CRUD]
+        tags:
+            - { name: sonata.admin, manager_type: orm, group: List, label: ONU, label_catalogue: StatsBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
+        calls:    
+            - [setTranslationDomain, [StatsBundle]]

+ 21 - 0
src/StatsBundle/Resources/translations/StatsBundle.es.yml

@@ -4,6 +4,7 @@ breadcrumb:
     link_stats_device_list: Listado Dispositivos
     link_device_list: Listado de Dispositivos
     link_device_create: Crear Dispositivo
+    link_onu_list: Listado de ONUs
 
 filter:
     label_name: Nombre
@@ -15,6 +16,16 @@ filter:
     label_device_server: Servidor
     label_short_type: Tipo
     label_tenancy_id: Tenencia
+    label_olt_device_id: OLT
+    label_pon_serial_number: Pon Serial Number
+    label_pon_port: PonPort
+    label_status: Online
+    label_rx_power: RX Power
+    label_tx_power: TX Power
+    label_voltage: Voltage
+    label_temperature: Temperatura
+    label_uptime: Uptime
+    label_updated: Actualizado
 
 form:
     label_name: Nombre
@@ -49,6 +60,16 @@ list:
     label_device_server: Servidor
     label_short_type: Tipo
     label_tenancy_id: Tenencia
+    label_olt_device_id: OLT
+    label_pon_serial_number: Pon Serial Number
+    label_pon_port: PonPort
+    label_status: Online
+    label_rx_power: RX Power
+    label_tx_power: TX Power
+    label_voltage: Voltage
+    label_temperature: Temperatura
+    label_uptime: Uptime
+    label_updated: Actualizado
     
 help:
     url: Url a consultar dispositivos