Revert "[VOL-4746] removing sub based on programmed data"
Reverted because of ONUAutoDiscovery test failures in periodic bbsim tests
This reverts commit 89e2f040e1eae7306839ff0bbc61ba7f774d09ef.
Change-Id: Iddc95adf8341572c947abbd024a1bb55fe1e3cab
diff --git a/impl/src/main/java/org/opencord/olt/impl/Olt.java b/impl/src/main/java/org/opencord/olt/impl/Olt.java
index f6537e5..3b3c2b9 100644
--- a/impl/src/main/java/org/opencord/olt/impl/Olt.java
+++ b/impl/src/main/java/org/opencord/olt/impl/Olt.java
@@ -68,7 +68,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
@@ -86,7 +85,6 @@
import static org.onlab.util.Tools.groupedThreads;
import static org.opencord.olt.impl.OltUtils.getPortName;
import static org.opencord.olt.impl.OltUtils.portWithName;
-import static org.opencord.olt.impl.OltUtils.getProgrammedSubscriber;
import static org.opencord.olt.impl.OsgiPropertyConstants.*;
/**
@@ -327,7 +325,7 @@
return false;
}
- log.info("Provisioning subscriber on {}", accessDevicePort);
+ log.info("Provisioning subscriber on {}, deviceId {}", accessDevicePort, cp.deviceId());
if (oltFlowService.isSubscriberServiceProvisioned(accessDevicePort)) {
log.error("Subscriber on {} is already provisioned", accessDevicePort);
@@ -369,27 +367,21 @@
return false;
}
- log.info("Un-provisioning subscriber on {}", accessDevicePort);
+ log.info("Unprovisioning subscriber on {}", accessDevicePort);
if (!oltFlowService.isSubscriberServiceProvisioned(accessDevicePort)) {
log.error("Subscriber on {} is not provisioned", accessDevicePort);
return false;
}
- //First check if the subscriber is in the programmed subscriber map, if not fallback to sadis
- SubscriberAndDeviceInformation si = getProgrammedSubscriber(oltFlowService, accessDevicePort);
+ SubscriberAndDeviceInformation si = subsService.get(getPortName(port));
if (si == null) {
- si = subsService.get(getPortName(port));
- }
- // if it's still null we can't proceed
- if (si == null) {
- log.error("Subscriber information not found in programmed subscribers or sadis for port {}",
+ log.error("Subscriber information not found in sadis for port {}",
accessDevicePort);
// NOTE that we are returning true so that the subscriber is removed from the queue
// and we can move on provisioning others
return false;
}
-
DiscoveredSubscriber sub = new DiscoveredSubscriber(device, port,
DiscoveredSubscriber.Status.ADMIN_REMOVED, true, si);
@@ -409,7 +401,7 @@
@Override
public boolean provisionSubscriber(ConnectPoint cp, VlanId cTag, VlanId sTag, Integer tpId) {
- log.debug("Provisioning subscriber on {}, with cTag {}, stag {}, tpId {}",
+ log.info("Provisioning subscriber on {}, with cTag {}, stag {}, tpId {}",
cp, cTag, sTag, tpId);
Device device = deviceService.getDevice(cp.deviceId());
Port port = deviceService.getPort(device.id(), cp.port());
@@ -421,7 +413,7 @@
}
SubscriberAndDeviceInformation si = new SubscriberAndDeviceInformation();
- UniTagInformation specificService = getUniTagInformation(port, cTag, sTag, tpId);
+ UniTagInformation specificService = getUniTagInformation(getPortName(port), cTag, sTag, tpId);
if (specificService == null) {
log.error("Can't find Information for subscriber on {}, with cTag {}, " +
"stag {}, tpId {}", cp, cTag, sTag, tpId);
@@ -448,7 +440,7 @@
@Override
public boolean removeSubscriber(ConnectPoint cp, VlanId cTag, VlanId sTag, Integer tpId) {
- log.debug("Un-provisioning subscriber on {} with cTag {}, stag {}, tpId {}",
+ log.info("Unprovisioning subscriber on {} with cTag {}, stag {}, tpId {}",
cp, cTag, sTag, tpId);
Device device = deviceService.getDevice(cp.deviceId());
Port port = deviceService.getPort(device.id(), cp.port());
@@ -461,7 +453,7 @@
}
SubscriberAndDeviceInformation si = new SubscriberAndDeviceInformation();
- UniTagInformation specificService = getUniTagInformation(port, cTag, sTag, tpId);
+ UniTagInformation specificService = getUniTagInformation(getPortName(port), cTag, sTag, tpId);
if (specificService == null) {
log.error("Can't find Information for subscriber on {}, with cTag {}, " +
"stag {}, tpId {}", cp, cTag, sTag, tpId);
@@ -624,30 +616,16 @@
* using the pon c tag, pon s tag and the technology profile id
* May return Optional<null>
*
- * @param port port of the subscriber
+ * @param portName port of the subscriber
* @param innerVlan pon c tag
* @param outerVlan pon s tag
* @param tpId the technology profile id
* @return the found uni tag information
*/
- private UniTagInformation getUniTagInformation(Port port, VlanId innerVlan,
+ private UniTagInformation getUniTagInformation(String portName, VlanId innerVlan,
VlanId outerVlan, int tpId) {
- String portName = portWithName(port);
log.debug("Getting uni tag information for {}, innerVlan: {}, outerVlan: {}, tpId: {}",
portName, innerVlan, outerVlan, tpId);
- //First check if the subscriber is in the programmed subscriber map, if not fallback to sadis
- //there should be only one sub service with these characteristics.
- Optional<Map.Entry<ServiceKey, UniTagInformation>> service = oltFlowService.getProgrammedSubscribers()
- .entrySet().stream()
- .filter(entry -> entry.getKey().getPort().equals(new AccessDevicePort(port))
- && entry.getValue().getPonSTag().equals(outerVlan)
- && entry.getValue().getPonCTag().equals(innerVlan))
- .findFirst();
- if (service.isPresent()) {
- log.debug("Subscriber was programmed with uni tag info for {}, innerVlan: {}, outerVlan: {}, tpId: {}",
- portName, innerVlan, outerVlan, tpId);
- return service.get().getValue();
- }
SubscriberAndDeviceInformation subInfo = subsService.get(portName);
if (subInfo == null) {
log.warn("Subscriber information doesn't exist for {}", portName);
@@ -660,22 +638,22 @@
return null;
}
- UniTagInformation uniTagInformation = OltUtils.getUniTagInformation(subInfo, innerVlan, outerVlan, tpId);
- if (uniTagInformation == null) {
+ UniTagInformation service = OltUtils.getUniTagInformation(subInfo, innerVlan, outerVlan, tpId);
+ if (service == null) {
// Try again after invalidating cache for the particular port name.
subsService.invalidateId(portName);
subInfo = subsService.get(portName);
- uniTagInformation = OltUtils.getUniTagInformation(subInfo, innerVlan, outerVlan, tpId);
+ service = OltUtils.getUniTagInformation(subInfo, innerVlan, outerVlan, tpId);
}
- if (uniTagInformation == null) {
+ if (service == null) {
log.warn("SADIS doesn't include the service with ponCtag {} ponStag {} and tpId {} on {}",
innerVlan, outerVlan, tpId, portName);
return null;
}
- return uniTagInformation;
+ return service;
}
protected void bindSadisService(SadisService service) {
@@ -905,7 +883,6 @@
log.debug("Ignoring PORT_ADD on UNI port {}", portWithName(port));
return;
}
- AccessDevicePort accessDevicePort = new AccessDevicePort(port);
if (port.isEnabled()) {
if (isNni) {
@@ -925,17 +902,8 @@
// NOTE if the subscriber was previously provisioned,
// then add it back to the queue to be re-provisioned
boolean provisionSubscriber = oltFlowService.
- isSubscriberServiceProvisioned(accessDevicePort);
-
- SubscriberAndDeviceInformation si;
- DiscoveredSubscriber.Status status = DiscoveredSubscriber.Status.ADDED;
- if (type == DeviceEvent.Type.PORT_REMOVED) {
- status = DiscoveredSubscriber.Status.REMOVED;
- si = getProgrammedSubscriber(oltFlowService, accessDevicePort);
- } else {
- si = subsService.get(getPortName(port));
- }
-
+ isSubscriberServiceProvisioned(new AccessDevicePort(port));
+ SubscriberAndDeviceInformation si = subsService.get(getPortName(port));
if (si == null) {
//NOTE this should not happen given that the subscriber was provisioned before
log.error("Subscriber information not found in sadis for port {}",
@@ -943,6 +911,11 @@
return;
}
+ DiscoveredSubscriber.Status status = DiscoveredSubscriber.Status.ADDED;
+ if (type == DeviceEvent.Type.PORT_REMOVED) {
+ status = DiscoveredSubscriber.Status.REMOVED;
+ }
+
DiscoveredSubscriber sub =
new DiscoveredSubscriber(device, port,
status, provisionSubscriber, si);
@@ -975,12 +948,7 @@
addSubscriberToQueue(sub);
} else if (oltFlowService.isSubscriberServiceProvisioned(new AccessDevicePort(port))) {
- //First check if the subscriber is in the programmed subscriber map, if not fallback to sadis
- SubscriberAndDeviceInformation si = getProgrammedSubscriber(oltFlowService, accessDevicePort);
- if (si == null) {
- si = subsService.get(getPortName(port));
- }
- // if it's still null we can't proceed
+ SubscriberAndDeviceInformation si = subsService.get(getPortName(port));
if (si == null) {
//NOTE this should not happen given that the subscriber was provisioned before
log.error("Subscriber information not found in sadis for port {}",