Quellcode durchsuchen

migracion de plantillas y acciones

Luciano Andrade vor 7 Jahren
Ursprung
Commit
e194ac8586

+ 11 - 3
app/DoctrineMigrations/Version20180221174411.php

@@ -4,11 +4,12 @@ namespace Application\Migrations;
 
 use Doctrine\DBAL\Migrations\AbstractMigration;
 use Doctrine\DBAL\Schema\Schema;
+use MigrationsBundle\Migrations\MigrationsBase;
 
 /**
  * Auto-generated Migration: Please modify to your needs!
  */
-class Version20180221174411 extends AbstractMigration
+class Version20180221174411 extends MigrationsBase
 {
     /**
      * @param Schema $schema
@@ -26,7 +27,7 @@ class Version20180221174411 extends AbstractMigration
 		$this->addSql('ALTER TABLE olt_audit CHANGE execute_snmp execute_snmp BOOLEAN DEFAULT TRUE');
 	}
 
-	$result = $this->connection->query("select o.id id, o.olt_id, nap_id, pon_serial_number, position, slot, link FROM onu o JOIN nap n ON (n.id = o.nap_id) WHERE  o.deleted_at IS NULL;");
+	$result = $this->connection->query("select o.id id, o.olt_id, nap_id, pon_serial_number, position, slot, link, ot.name FROM onu o JOIN nap n ON (n.id = o.nap_id) JOIN olt t ON (t.id = o.olt_id) JOIN oltmodel ot ON(t.model_id = ot.id) WHERE  o.deleted_at IS NULL AND ot.name LIKE 'Huawei MA5608T';");
 
 	$i = 0;
 	$vlangemport_config = array('voip' => array('gemport' => 0, 'vlan' => 13), 'data' => array('gemport' => 1, 'vlan' => 10));
@@ -48,10 +49,17 @@ class Version20180221174411 extends AbstractMigration
 		foreach($service_port as $type => $number){
 			$gemport = $vlangemport_config[$type]['gemport'];
 			$vlan = $vlangemport_config[$type]['vlan'];
-			$sql = "INSERT INTO service_port (olt_id, onu_id, number, type, gemport, vlan) VALUES ($olt_id, $onu_id, $number, '$type', $gemport, $vlan);";
+			$sql = "REPLACE INTO service_port (olt_id, onu_id, number, type, gemport, vlan) VALUES ($olt_id, $onu_id, $number, '$type', $gemport, $vlan);";
 			$this->addSql($sql);
 		}
 	}
+
+
+        // this up() migration is auto-generated, please modify it to your needs
+	$this->executeYaml(__DIR__ . "/Templates20180221174411/", "template-action-2018-02-26.yml");
+        $this->showResult();
+
+
     }
 
     /**

+ 5 - 1
src/FTTHBundle/EventListener/ONUSubscriber.php

@@ -161,9 +161,13 @@ class ONUSubscriber implements EventSubscriber
      */ 
     public function setSerivcePorts(ONU $onu)
     {
+
 	if($onu->getNAP() and $onu->getNAP()->getOLT()){
 	    $sp = $onu->getServicePort();
-	    if(count($sp) == 0){
+
+            $model_extra_data = $onu->getNAP()->getOLT()->getModel()->jsonExtraData();
+	    if((isset($model_extra_data['auto-create-service-ports']) and  $model_extra_data['auto-create-service-ports'] === true)
+	       and count($sp) == 0){
 	    	$olt = $onu->getNAP()->getOLT();
 	    	$used_sp = $this->em->getRepository(ServicePort::class)->findBy(
 	    		array("olt" => $olt)

+ 2 - 2
src/FTTHBundle/Resources/translations/FTTHBundle.es.yml

@@ -115,7 +115,7 @@ list:
     label_id: Id
     label_ip: Ip
     label_mac: Mac
-    label_serial_number: Número Serie
+    label_serial_number: Número Seri
     label_pon_serial_number: Número Serie Pon
     label_client_id: Cliente
     label_current_state: Estado
@@ -191,7 +191,7 @@ show:
     
 helps:
     check_address: Verifique la dirección para el cálculo de distancias.
-    service_port: Los services ports son creados automaticamente, en caso de modificarlos <b>no</b> se actualizaran en la OLT, sino que seran utilizados en el siguiente comando.
+    service_port: Los services ports son creados automaticamente, si el modelo de OLT tiene seteado 'auto-create-service-ports' == true, en caso de modificarlos <b>no</b> se actualizaran en la OLT, sino que seran utilizados en el siguiente comando.
 error:
     address_not_found: La dirección "%client_address%" no fue encontrada en los servicios de google.
 Distance: Distancia

+ 4 - 0
src/FTTHBundle/Resources/translations/messages.es.yml

@@ -0,0 +1,4 @@
+form.service_port.type:  Tipo de servicio, a modo de referencia
+form.service_port.number:  Número de puerto de servicio
+form.service_port.vlan: VLAN
+form.service_port.gemport: gemport