Search in sources :

Example 1 with NodeConnectorInfo

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);
    }
}
Also used : NodeConnectorInfoBuilder(org.opendaylight.genius.itm.utils.NodeConnectorInfoBuilder) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) Acquired(org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.Acquired) OfPortStateAddWorker(org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorker) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) OfPortStateAddWorkerForNodeConnector(org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorkerForNodeConnector) OfDpnTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep) NodeConnectorInfo(org.opendaylight.genius.itm.utils.NodeConnectorInfo) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 2 with NodeConnectorInfo

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();
}
Also used : OfTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep) NodeConnectorInfo(org.opendaylight.genius.itm.utils.NodeConnectorInfo) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) OfTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep) OfTepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepBuilder) ITMBatchingUtils(org.opendaylight.genius.itm.impl.ITMBatchingUtils) IfIndexTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210._if.indexes.tunnel.map.IfIndexTunnelBuilder) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) LoggerFactory(org.slf4j.LoggerFactory) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) IfIndexTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210._if.indexes.tunnel.map.IfIndexTunnelKey) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Datastore(org.opendaylight.mdsal.binding.util.Datastore) IfIndexesTunnelMap(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.IfIndexesTunnelMap) DirectTunnelUtils(org.opendaylight.genius.itm.itmdirecttunnels.renderer.ovs.utilities.DirectTunnelUtils) OfTepKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepKey) OfDpnTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep) Logger(org.slf4j.Logger) IfIndexTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210._if.indexes.tunnel.map.IfIndexTunnel) Uint16(org.opendaylight.yangtools.yang.common.Uint16) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) OperationFailedException(org.opendaylight.yangtools.yang.common.OperationFailedException) IfmConstants(org.opendaylight.genius.interfacemanager.globals.IfmConstants) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) ITMConstants(org.opendaylight.genius.itm.globals.ITMConstants) Collections(java.util.Collections) ItmUtils(org.opendaylight.genius.itm.impl.ItmUtils) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 3 with NodeConnectorInfo

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);
    }
}
Also used : Acquired(org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.Acquired) OfPortStateAddWorker(org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorker) OfPortStateAddWorkerForNodeConnector(org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorkerForNodeConnector) NodeConnectorInfo(org.opendaylight.genius.itm.utils.NodeConnectorInfo)

Aggregations

NodeConnectorInfo (org.opendaylight.genius.itm.utils.NodeConnectorInfo)3 OfPortStateAddWorker (org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorker)2 OfPortStateAddWorkerForNodeConnector (org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorkerForNodeConnector)2 Acquired (org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.Acquired)2 OfDpnTep (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Collections (java.util.Collections)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 IfmConstants (org.opendaylight.genius.interfacemanager.globals.IfmConstants)1 ITMConstants (org.opendaylight.genius.itm.globals.ITMConstants)1 ITMBatchingUtils (org.opendaylight.genius.itm.impl.ITMBatchingUtils)1 ItmUtils (org.opendaylight.genius.itm.impl.ItmUtils)1 DirectTunnelUtils (org.opendaylight.genius.itm.itmdirecttunnels.renderer.ovs.utilities.DirectTunnelUtils)1 NodeConnectorInfoBuilder (org.opendaylight.genius.itm.utils.NodeConnectorInfoBuilder)1 Datastore (org.opendaylight.mdsal.binding.util.Datastore)1 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)1 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)1