|
@@ -302,9 +302,24 @@ class ONUSubscriber implements EventSubscriber
|
|
|
$model_extra_data = array();
|
|
|
}
|
|
|
|
|
|
+ // Si la ONU no tiene asignadas vlans, busco alguna que este por default
|
|
|
+ $vlans = $onu->getVlans() ?: [];
|
|
|
+ $vlanDefault = $this->em->getRepository(VLanID::class)
|
|
|
+ ->findOneBy(array(
|
|
|
+ "usedByDefault" => true,
|
|
|
+ ));
|
|
|
+ if ((is_null($vlans) || count($vlans) == 0) && $vlanDefault) {
|
|
|
+ $vlans = [
|
|
|
+ $vlanDefault,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
if (isset($model_extra_data['auto-create-service-ports']) and
|
|
|
- $model_extra_data['auto-create-service-ports'] === true and count($sp) == 0) {
|
|
|
+ $model_extra_data['auto-create-service-ports'] === true and count($sp) == 0
|
|
|
+ and count($vlans)) {
|
|
|
$olt = $onu->getNAP()->getOLT();
|
|
|
+
|
|
|
+ // Se buscan los ServicePort utilizados en la OLT
|
|
|
$used_sp = $this->em->getRepository(ServicePort::class)->findBy(array(
|
|
|
"olt" => $olt,
|
|
|
));
|
|
@@ -314,13 +329,9 @@ class ONUSubscriber implements EventSubscriber
|
|
|
}
|
|
|
|
|
|
$foundit = array();
|
|
|
- $found_at_least = 2;
|
|
|
- $service_type = array( "data", "voip", /*'iptv'*/);
|
|
|
- $vlangemport_config = array(
|
|
|
- 'voip' => array('gemport' => 0, 'vlan' => 13),
|
|
|
- 'data' => array('gemport' => 1, 'vlan' => 10)
|
|
|
- );
|
|
|
-
|
|
|
+ $found_at_least = count($vlans);
|
|
|
+
|
|
|
+ // Si existen ServicePort asignados se buscan los números libres
|
|
|
$max_n = 2;
|
|
|
if (count($services)) {
|
|
|
$max_n = @max(array_keys($services)); //Warning: max(): Array must contain at least one element
|
|
@@ -339,18 +350,20 @@ class ONUSubscriber implements EventSubscriber
|
|
|
$foundit[] = 1 + $max_n + $i;
|
|
|
}
|
|
|
|
|
|
+ $vlanNumbers = [];
|
|
|
+ foreach ($vlans as $vlan) {
|
|
|
+ $vlanNumbers[] = $vlan->getValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ $gemport = 0;
|
|
|
foreach ($foundit as $key => $num) {
|
|
|
$sp = new ServicePort();
|
|
|
- $ok = list($skey, $ser) = each($service_type);
|
|
|
- if ($ok === false) {
|
|
|
- reset($service_type);
|
|
|
- $ok = list($skey, $ser) = current($service_type);
|
|
|
- }
|
|
|
$sp->setNumber($num);
|
|
|
- $sp->setGemport($vlangemport_config[$ser]['gemport']);
|
|
|
- $sp->setVlan($vlangemport_config[$ser]['vlan']);
|
|
|
- $sp->setType($ser);
|
|
|
+ $sp->setGemport($gemport);
|
|
|
+ $sp->setVlan(array_shift($vlanNumbers));
|
|
|
$onu->addServicePort($sp);
|
|
|
+
|
|
|
+ $gemport++;
|
|
|
}
|
|
|
$this->em->flush();
|
|
|
}
|