|
@@ -302,9 +302,23 @@ class ONUSubscriber implements EventSubscriber
|
|
|
$model_extra_data = array();
|
|
|
}
|
|
|
|
|
|
+ // Si la ONU no tiene asignadas vlans, busco alguna que este por default
|
|
|
+ $vlans = $onu->getVlans();
|
|
|
+ if (is_null($vlans) || count($vlans) == 0) {
|
|
|
+ $vlans = [
|
|
|
+ $this->em->getRepository(VLanID::class)
|
|
|
+ ->findOneBy(array(
|
|
|
+ "usedByDefault" => true,
|
|
|
+ ))
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
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,28 +328,9 @@ class ONUSubscriber implements EventSubscriber
|
|
|
}
|
|
|
|
|
|
$foundit = array();
|
|
|
- $found_at_least = 2;
|
|
|
-
|
|
|
- $service_type = array("data", "voip", /*'iptv'*/);
|
|
|
- $vlans = $onu->getVlans() ?: [];
|
|
|
- $vlangemport_config = array(
|
|
|
- 'voip' => array(
|
|
|
- 'gemport' => 0,
|
|
|
- 'vlan' => 13,
|
|
|
- ),
|
|
|
- 'data' => array(
|
|
|
- 'gemport' => 1,
|
|
|
- 'vlan' => 10,
|
|
|
- )
|
|
|
- );
|
|
|
- foreach ($service_type as $st) {
|
|
|
- foreach ($vlans as $vlan) {
|
|
|
- if (strpos($vlan->getName(), $st) !== false) {
|
|
|
- $vlangemport_config[$st]['vlan'] = $vlan->getValue();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ $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
|
|
@@ -354,18 +349,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();
|
|
|
}
|