Search in sources :

Example 1 with OfTep

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.

the class ItmOfTunnelDeleteWorker method removeTunnelConfiguration.

private void removeTunnelConfiguration(OfDpnTep dpnTep, TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException, OperationFailedException {
    LOG.info("removing ofTep configuration for {}", dpnTep.getOfPortName());
    Optional<OvsBridgeRefEntry> ovsBridgeRefEntry = ovsBridgeRefEntryCache.get(dpnTep.getSourceDpnId());
    Optional<OvsBridgeEntry> ovsBridgeEntryOptional;
    OvsdbBridgeRef ovsdbBridgeRef = null;
    if (ovsBridgeRefEntry.isPresent()) {
        ovsdbBridgeRef = ovsBridgeRefEntry.get().getOvsBridgeReference();
    } else {
        ovsBridgeEntryOptional = ovsBridgeEntryCache.get(dpnTep.getSourceDpnId());
        if (ovsBridgeEntryOptional.isPresent()) {
            ovsdbBridgeRef = ovsBridgeEntryOptional.get().getOvsBridgeReference();
        }
    }
    if (ovsdbBridgeRef != null) {
        removeTerminationEndPoint(ovsdbBridgeRef.getValue(), dpnTep.getOfPortName());
    }
    // delete tunnel ingress flow
    removeOfPortIngressFlow(tx, dpnTep.getOfPortName(), dpnTep.getSourceDpnId());
    // delete bridge to tunnel interface mappings
    OvsBridgeEntryKey bridgeEntryKey = new OvsBridgeEntryKey(dpnTep.getSourceDpnId());
    InstanceIdentifier<OvsBridgeEntry> bridgeEntryIid = DirectTunnelUtils.getOvsBridgeEntryIdentifier(bridgeEntryKey);
    ovsBridgeEntryOptional = ovsBridgeEntryCache.get(dpnTep.getSourceDpnId());
    if (ovsBridgeEntryOptional.isPresent()) {
        Map<OvsBridgeTunnelEntryKey, OvsBridgeTunnelEntry> bridgeTunnelEntries = ovsBridgeEntryOptional.get().getOvsBridgeTunnelEntry();
        deleteBridgeInterfaceEntry(bridgeEntryKey, bridgeTunnelEntries.values().stream().collect(Collectors.toList()), bridgeEntryIid, dpnTep.getOfPortName());
        // IfIndex needs to be removed only during State Clean up not Config
        cleanUpOfTepWithUnknownState(dpnTep.getOfPortName(), tx);
        directTunnelUtils.removeLportTagInterfaceMap(dpnTep.getOfPortName());
    }
}
Also used : OvsBridgeTunnelEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.bridge.tunnel.info.ovs.bridge.entry.OvsBridgeTunnelEntry) OvsBridgeRefEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.ovs.bridge.ref.info.OvsBridgeRefEntry) OvsBridgeTunnelEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.bridge.tunnel.info.ovs.bridge.entry.OvsBridgeTunnelEntryKey) OvsBridgeEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.bridge.tunnel.info.OvsBridgeEntry) OvsdbBridgeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef) OvsBridgeEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.meta.rev171210.bridge.tunnel.info.OvsBridgeEntryKey)

Example 2 with OfTep

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.

the class TunnelInventoryStateListener method handleOfTepStateUpdates.

private void handleOfTepStateUpdates(Optional<OfDpnTep> dpnTepInfo, TypedReadWriteTransaction<Operational> tx, boolean opStateModified, String ofTepName, Interface.OperStatus opState) {
    LOG.debug("updating oftep state entry for {}", ofTepName);
    InstanceIdentifier<OfTep> ofTepStateId = ItmUtils.buildStateOfTepListId(new OfTepKey(ofTepName));
    OfTepBuilder ofTepBuilder = new OfTepBuilder();
    ofTepBuilder.withKey(new OfTepKey(ofTepName));
    if (opStateModified) {
        LOG.debug("updating oftep oper status as {} for {}", opState.getName(), ofTepName);
        ofTepBuilder.setOfTepState(DirectTunnelUtils.convertInterfaceToTunnelOperState(opState));
        LOG.trace("updated to {} for {}", opState.getName(), ofTepName);
    }
    tx.merge(ofTepStateId, ofTepBuilder.build());
}
Also used : OfTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep) OfTepKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepKey) OfTepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepBuilder)

Example 3 with OfTep

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.

the class TunnelInventoryStateListener method removeOfTepStateConfiguration.

@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private List<? extends ListenableFuture<?>> removeOfTepStateConfiguration(NodeConnectorId nodeConnectorIdNew, NodeConnectorId nodeConnectorIdOld, String ofTepName, FlowCapableNodeConnector fcNodeConnectorOld) {
    List<ListenableFuture<?>> futures = new ArrayList<>();
    NodeConnectorId nodeConnectorId = (nodeConnectorIdOld != null && !nodeConnectorIdNew.equals(nodeConnectorIdOld)) ? nodeConnectorIdOld : nodeConnectorIdNew;
    Uint64 dpId = DirectTunnelUtils.getDpnFromNodeConnectorId(nodeConnectorId);
    // scenario, and should be treated as port removal.
    if (fcNodeConnectorOld.getReason() != PortReason.Delete) {
        // Remove event is because of connection lost between controller and switch, or switch shutdown.
        // Hence, dont remove the interface but set the status as "unknown"
        futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
            updateOfTepStateOnNodeRemove(dpId, ofTepName, fcNodeConnectorOld, tx);
        }));
    } else {
        LOG.debug("removing oftep state for oftep: {}", ofTepName);
        futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
            directTunnelUtils.deleteOfTepStateEntry(ofTepName);
            directTunnelUtils.removeLportTagInterfaceMap(ofTepName);
            directTunnelUtils.removeTunnelIngressFlow(tx, dpId, ofTepName);
        }));
        EVENT_LOGGER.debug("ITM-OfTepInventoryState,REMOVE Table 0 flow for {} completed", ofTepName);
    }
    return futures;
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) NodeConnectorInfo(org.opendaylight.genius.itm.utils.NodeConnectorInfo) OfTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep) Acquired(org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.Acquired) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) LoggerFactory(org.slf4j.LoggerFactory) OfDpnTepConfigCache(org.opendaylight.genius.itm.cache.OfDpnTepConfigCache) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) DirectTunnelUtils(org.opendaylight.genius.itm.itmdirecttunnels.renderer.ovs.utilities.DirectTunnelUtils) StateTunnelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey) TunnelEndPointInfo(org.opendaylight.genius.itm.utils.TunnelEndPointInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PortReason(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortReason) DpnTepStateCache(org.opendaylight.genius.itm.cache.DpnTepStateCache) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) Objects(java.util.Objects) List(java.util.List) TunnelStateInfoBuilder(org.opendaylight.genius.itm.utils.TunnelStateInfoBuilder) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) Optional(java.util.Optional) TypedReadWriteTransaction(org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction) NonNull(org.eclipse.jdt.annotation.NonNull) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) TunnelStateCache(org.opendaylight.genius.itm.cache.TunnelStateCache) TunnelStateAddWorkerForNodeConnector(org.opendaylight.genius.itm.itmdirecttunnels.workers.TunnelStateAddWorkerForNodeConnector) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) OfTepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepBuilder) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Callable(java.util.concurrent.Callable) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) DpnTepInterfaceInfo(org.opendaylight.genius.itm.utils.DpnTepInterfaceInfo) NodeConnectorInfoBuilder(org.opendaylight.genius.itm.utils.NodeConnectorInfoBuilder) OfPortStateAddWorker(org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorker) TunnelStateAddWorker(org.opendaylight.genius.itm.itmdirecttunnels.workers.TunnelStateAddWorker) DPNTEPsInfoCache(org.opendaylight.genius.itm.cache.DPNTEPsInfoCache) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) TunnelStateInfo(org.opendaylight.genius.itm.utils.TunnelStateInfo) 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) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Operational(org.opendaylight.mdsal.binding.util.Datastore.Operational) OfPortStateAddWorkerForNodeConnector(org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorkerForNodeConnector) StateTunnelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListBuilder) AbstractClusteredSyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractClusteredSyncDataTreeChangeListener) UnprocessedNodeConnectorEndPointCache(org.opendaylight.genius.itm.cache.UnprocessedNodeConnectorEndPointCache) UnprocessedNodeConnectorCache(org.opendaylight.genius.itm.cache.UnprocessedNodeConnectorCache) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) ITMConstants(org.opendaylight.genius.itm.globals.ITMConstants) UnprocessedOFNodeConnectorCache(org.opendaylight.genius.itm.cache.UnprocessedOFNodeConnectorCache) Collections(java.util.Collections) ItmUtils(org.opendaylight.genius.itm.impl.ItmUtils) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Uint64(org.opendaylight.yangtools.yang.common.Uint64) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 4 with OfTep

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.

the class OfPortStateAddWorker method addStateEntry.

private OfTep addStateEntry(String ofPortName, long portNo) throws ExecutionException, InterruptedException, OperationFailedException {
    final int ifIndex = directTunnelUtils.allocateId(IfmConstants.IFM_IDPOOL_NAME, ofPortName);
    if (ifIndex == ITMConstants.INVALID_ID) {
        LOG.trace("aborting addStateEntry for {}, due to invalid Id", ofPortName);
        return null;
    }
    createLportTagInterfaceMap(ofPortName, ifIndex);
    final OfTepBuilder ofTepBuilder = new OfTepBuilder();
    Interface.OperStatus operStatus = Interface.OperStatus.Up;
    TunnelOperStatus tunnelOperStatus = DirectTunnelUtils.convertInterfaceToTunnelOperState(operStatus);
    OfTepKey ofTepKey = new OfTepKey(ofPortName);
    ofTepBuilder.withKey(ofTepKey).setTunnelType(dpnTep.getTunnelType()).setOfPortName(ofPortName).setTepIp(dpnTep.getTepIp()).setPortNumber(String.valueOf(portNo)).setIfIndex(Uint16.valueOf(ifIndex)).setOfTepState(tunnelOperStatus).setSourceDpnId(dpnTep.getSourceDpnId());
    InstanceIdentifier<OfTep> ofTepsListId = ItmUtils.buildStateOfTepListId(ofTepKey);
    LOG.trace("Batching the Creation of tunnel_state: {} for Id: {}", ofTepBuilder.build(), ofTepsListId);
    ITMBatchingUtils.write(ofTepsListId, ofTepBuilder.build(), ITMBatchingUtils.EntityType.DEFAULT_OPERATIONAL);
    return ofTepBuilder.build();
}
Also used : OfTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) OfTepKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepKey) OfTepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 5 with OfTep

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep in project genius by opendaylight.

the class ItmManagerRpcService method getEgressActionsForInternalTunnels.

private ListenableFuture<GetEgressActionsForTunnelOutput> getEgressActionsForInternalTunnels(String interfaceName, Long tunnelKey, Integer actionKey) throws ExecutionException, InterruptedException, OperationFailedException {
    if (interfaceName.startsWith("of")) {
        Optional<OfTep> oftep = ofTepStateCache.get(interfaceName);
        if (!oftep.isPresent()) {
            throw new IllegalStateException("Interface information not present in oper DS for" + interfaceName);
        }
        List<ActionInfo> actions = getEgressActionInfosForOpenFlowTunnel(oftep.get().getIfIndex(), oftep.get().getTepIp(), tunnelKey, actionKey);
        return Futures.immediateFuture(new GetEgressActionsForTunnelOutputBuilder().setAction(actions.stream().map(ActionInfo::buildAction).collect(Collectors.toList())).build());
    } else {
        DpnTepInterfaceInfo interfaceInfo = dpnTepStateCache.getTunnelFromCache(interfaceName);
        if (interfaceInfo == null) {
            throw new IllegalStateException("Interface information not present in config DS for" + interfaceName);
        }
        String tunnelType = ItmUtils.convertTunnelTypetoString(interfaceInfo.getTunnelType());
        if (!tunnelType.equalsIgnoreCase(ITMConstants.TUNNEL_TYPE_VXLAN)) {
            throw new IllegalArgumentException(tunnelType + " tunnel not handled by ITM");
        }
        Optional<DPNTEPsInfo> dpntePsInfoOptional = dpnTEPsInfoCache.get(InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(// FIXME: the cache should be caching this value, not just as a String
        dpnTepStateCache.getTunnelEndPointInfoFromCache(interfaceInfo.getTunnelName()).getDstEndPointInfo())).build());
        Integer dstId;
        if (dpntePsInfoOptional.isPresent()) {
            dstId = dpntePsInfoOptional.get().getDstId();
        } else {
            dstId = directTunnelUtils.allocateId(ITMConstants.ITM_IDPOOL_NAME, interfaceInfo.getRemoteDPN().toString());
        }
        List<ActionInfo> result = new ArrayList<>();
        long regValue = MetaDataUtil.getRemoteDpnMetadatForEgressTunnelTable(dstId);
        int actionKeyStart = actionKey == null ? 0 : actionKey;
        result.add(new ActionSetFieldTunnelId(actionKeyStart++, Uint64.valueOf(tunnelKey != null ? tunnelKey : 0L)));
        result.add(new ActionRegLoad(actionKeyStart++, NxmNxReg6.class, MetaDataUtil.REG6_START_INDEX, MetaDataUtil.REG6_END_INDEX, regValue));
        result.add(new ActionNxResubmit(actionKeyStart, NwConstants.EGRESS_TUNNEL_TABLE));
        return Futures.immediateFuture(new GetEgressActionsForTunnelOutputBuilder().setAction(result.stream().map(ActionInfo::buildAction).collect(Collectors.toList())).build());
    }
}
Also used : OfTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep) NxmNxReg6(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6) GetEgressActionsForTunnelOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelOutputBuilder) DpnEndpoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpoints) ArrayList(java.util.ArrayList) ActionRegLoad(org.opendaylight.genius.mdsalutil.actions.ActionRegLoad) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) DpnTepInterfaceInfo(org.opendaylight.genius.itm.utils.DpnTepInterfaceInfo) BigInteger(java.math.BigInteger) DPNTEPsInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Aggregations

OfTep (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep)7 OfTepKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepKey)5 ArrayList (java.util.ArrayList)4 OfTepBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTepBuilder)4 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Collections (java.util.Collections)2 List (java.util.List)2 ITMConstants (org.opendaylight.genius.itm.globals.ITMConstants)2 ItmUtils (org.opendaylight.genius.itm.impl.ItmUtils)2 DirectTunnelUtils (org.opendaylight.genius.itm.itmdirecttunnels.renderer.ovs.utilities.DirectTunnelUtils)2 DpnTepInterfaceInfo (org.opendaylight.genius.itm.utils.DpnTepInterfaceInfo)2 NodeConnectorInfo (org.opendaylight.genius.itm.utils.NodeConnectorInfo)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 BigInteger (java.math.BigInteger)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Callable (java.util.concurrent.Callable)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1