use of org.opendaylight.genius.itm.utils.NodeConnectorInfoBuilder in project genius by opendaylight.
the class TunnelInventoryStateListener method add.
@Override
public void add(@NonNull InstanceIdentifier<FlowCapableNodeConnector> key, @NonNull FlowCapableNodeConnector fcNodeConnectorNew) {
LOG.info("Received NodeConnector Add Event: {}, {}", key, fcNodeConnectorNew);
EVENT_LOGGER.debug("ITM-TunnelInventoryState,ADD DTCN received for {}", fcNodeConnectorNew.getName());
String portName = fcNodeConnectorNew.getName();
// Return if its not tunnel port and if its not Internal
if (!DirectTunnelUtils.TUNNEL_PORT_PREDICATE.test(portName) && !portName.startsWith("of")) {
LOG.debug("Node Connector Add {} Interface is not a tunnel I/f, so no-op", portName);
return;
}
if (!directTunnelUtils.isEntityOwner()) {
LOG.debug("Not an entity owner.");
return;
}
// Optional<OfDpnTep> dpnTepOptional = Optional.ofNullable(null);
NodeConnectorInfo nodeConnectorInfo = new NodeConnectorInfoBuilder().setNodeConnectorId(key).setNodeConnector(fcNodeConnectorNew).build();
if (portName.startsWith("of") && interfaceManager.isItmOfTunnelsEnabled()) {
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
Uint64 srcDpn = DirectTunnelUtils.getDpnFromNodeConnectorId(nodeConnectorId);
OfDpnTep dpntep = null;
try (Acquired lock = directTunnelUtils.lockTunnel(portName)) {
try {
Optional<OfDpnTep> dpnTepOptional = ofDpnTepConfigCache.get(srcDpn.toJava());
if (!dpnTepOptional.isPresent()) {
// Park the notification
LOG.debug("Unable to process the NodeConnector ADD event for {} as Config not available." + "Hence parking it", portName);
unprocessedOFNCCache.add(portName, nodeConnectorInfo);
return;
} else {
dpntep = dpnTepOptional.get();
}
} catch (ReadFailedException e) {
LOG.error("unable to get ofDpnTepConfigCache");
}
}
if (dpntep != null) {
OfPortStateAddWorkerForNodeConnector ifOfStateAddWorker = new OfPortStateAddWorkerForNodeConnector(new OfPortStateAddWorker(directTunnelUtils, dpntep, txRunner), nodeConnectorInfo);
EVENT_LOGGER.debug("ITM-Of-tepInventoryState Entity Owner,ADD {} {}", nodeConnectorId.getValue(), portName);
coordinator.enqueueJob(portName, ifOfStateAddWorker, ITMConstants.JOB_MAX_RETRIES);
}
} else {
addTunnelState(nodeConnectorInfo, portName);
}
}
Aggregations