use of org.opendaylight.genius.itm.utils.NodeConnectorInfo 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);
}
}
use of org.opendaylight.genius.itm.utils.NodeConnectorInfo in project genius by opendaylight.
the class OfPortStateAddWorker method addState.
public List<? extends ListenableFuture<?>> addState(NodeConnectorInfo nodeConnectorInfo) throws ExecutionException, InterruptedException, OperationFailedException {
// When this method is invoked, all parameters necessary should be available
// Retrieve Port No from nodeConnectorId
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(nodeConnectorInfo.getNodeConnectorId().firstIdentifierOf(NodeConnector.class)).getId();
String ofPortName = nodeConnectorInfo.getNodeConnector().getName();
long portNo = DirectTunnelUtils.getPortNumberFromNodeConnectorId(nodeConnectorId);
EVENT_LOGGER.debug("ITM-Of Port State, ADD to oper DS {}", ofPortName);
if (portNo == ITMConstants.INVALID_PORT_NO) {
LOG.error("Cannot derive port number, not proceeding with of-port State " + "addition for of-port: {}", ofPortName);
return null;
}
LOG.info("adding of-port state to Oper DS for interface: {}", ofPortName);
OfTep ofTep = addStateEntry(ofPortName, portNo);
// If this interface is a of-port interface, create the of-port ingress flow
if (ofTep != null) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> {
Uint64 dpId = DirectTunnelUtils.getDpnFromNodeConnectorId(nodeConnectorId);
directTunnelUtils.addTunnelIngressFlow(tx, dpId, portNo, ofPortName, ofTep.getIfIndex().toJava(), ofTep.getTepIp().getIpv4Address());
}));
}
EVENT_LOGGER.debug("ITM-of-port,ADD Table 0 flow for {} completed", ofPortName);
return Collections.emptyList();
}
use of org.opendaylight.genius.itm.utils.NodeConnectorInfo in project genius by opendaylight.
the class OfDpnTepConfigCache method added.
@Override
protected void added(InstanceIdentifier<OfDpnTep> path, OfDpnTep ofDpnTep) {
NodeConnectorInfo nodeConnectorInfo = null;
try (Acquired lock = directTunnelUtils.lockTunnel(ofDpnTep.getOfPortName())) {
if (unprocessedOFNCCache.get(ofDpnTep.getOfPortName()) != null) {
nodeConnectorInfo = unprocessedOFNCCache.remove(ofDpnTep.getOfPortName());
}
}
if (nodeConnectorInfo != null && directTunnelUtils.isEntityOwner()) {
OfPortStateAddWorkerForNodeConnector ifOfStateAddWorker = new OfPortStateAddWorkerForNodeConnector(new OfPortStateAddWorker(directTunnelUtils, ofDpnTep, txRunner), nodeConnectorInfo);
LOG.debug("ITM-Of-tepInventoryState Entity Owner,ADD {} {}", ofDpnTep.getSourceDpnId(), ofDpnTep.getOfPortName());
EVENT_LOGGER.debug("ITM-Of-tepInventoryState Entity Owner,ADD {} {}", ofDpnTep.getSourceDpnId(), ofDpnTep.getOfPortName());
coordinator.enqueueJob(ofDpnTep.getOfPortName(), ifOfStateAddWorker, ITMConstants.JOB_MAX_RETRIES);
}
}
Aggregations