Search in sources :

Example 1 with TunnelOperStatus

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus in project netvirt by opendaylight.

the class ElanTunnelInterfaceStateListener method add.

@Override
protected void add(InstanceIdentifier<StateTunnelList> key, StateTunnelList add) {
    LOG.info("processing add state for StateTunnelList {}", add);
    if (!isInternalTunnel(add)) {
        LOG.trace("tunnel {} is not a internal vxlan tunnel", add);
        return;
    }
    if (elanUtils.isTunnelInLogicalGroup(add.getTunnelInterfaceName())) {
        LOG.trace("MULTIPLE_VxLAN_TUNNELS: ignoring the tunnel event for {}", add.getTunnelInterfaceName());
        return;
    }
    TunnelOperStatus tunOpStatus = add.getOperState();
    if (tunOpStatus != TunnelOperStatus.Down && tunOpStatus != TunnelOperStatus.Up) {
        LOG.trace("Returning because unsupported tunnelOperStatus {}", tunOpStatus);
        return;
    }
    jobCoordinator.enqueueJob(add.getTunnelInterfaceName(), () -> {
        BigInteger srcDpId = new BigInteger(add.getSrcInfo().getTepDeviceId());
        BigInteger dstDpId = new BigInteger(add.getDstInfo().getTepDeviceId());
        LOG.info("Handling tunnel state event for srcDpId {} and dstDpId {} ", srcDpId, dstDpId);
        elanInterfaceManager.handleInternalTunnelStateEvent(srcDpId, dstDpId);
        return Collections.emptyList();
    }, ElanConstants.JOB_MAX_RETRIES);
}
Also used : TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) BigInteger(java.math.BigInteger)

Example 2 with TunnelOperStatus

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus in project netvirt by opendaylight.

the class TunnelInterfaceStateListener method add.

@Override
protected void add(InstanceIdentifier<StateTunnelList> identifier, StateTunnelList add) {
    LOG.trace("add: Tunnel addition---- {}", add);
    TunnelOperStatus tunOpStatus = add.getOperState();
    if (tunOpStatus != TunnelOperStatus.Down && tunOpStatus != TunnelOperStatus.Up) {
        LOG.info("add: Returning from unsupported tunnelOperStatus {} for tunnel interface {}", tunOpStatus, add.getTunnelInterfaceName());
        return;
    }
    if (tunOpStatus != TunnelOperStatus.Up) {
        LOG.error("add: Tunnel {} is not yet UP.", add.getTunnelInterfaceName());
    }
    if (isGreTunnel(add)) {
        programDcGwLoadBalancingGroup(add, NwConstants.ADD_FLOW);
    }
    LOG.info("add: ITM Tunnel ,type {} ,added between src: {} and dest: {}", fibManager.getTransportTypeStr(add.getTransportType().toString()), add.getSrcInfo().getTepDeviceId(), add.getDstInfo().getTepDeviceId());
    handleTunnelEventForDPN(add, TunnelAction.TUNNEL_EP_ADD);
}
Also used : TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus)

Example 3 with TunnelOperStatus

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus in project netvirt by opendaylight.

the class TunnelInterfaceStateListener method update.

@Override
protected void update(InstanceIdentifier<StateTunnelList> identifier, StateTunnelList original, StateTunnelList update) {
    LOG.trace("update: Tunnel updation---- {}", update);
    LOG.info("update: ITM Tunnel {} of type {} state event changed from :{} to :{}", update.getTunnelInterfaceName(), fibManager.getTransportTypeStr(update.getTransportType().toString()), original.getOperState(), update.getOperState());
    TunnelOperStatus tunOpStatus = update.getOperState();
    if (tunOpStatus != TunnelOperStatus.Down && tunOpStatus != TunnelOperStatus.Up) {
        LOG.info("update: Returning from unsupported tunnelOperStatus {} for tunnel interface {}", tunOpStatus, update.getTunnelInterfaceName());
        return;
    }
    if (isGreTunnel(update)) {
        programDcGwLoadBalancingGroup(update, NwConstants.MOD_FLOW);
    }
    // Remove the corresponding nexthop from the routepath under extraroute in fibentries.
    BigInteger srcDpnId = new BigInteger(update.getSrcInfo().getTepDeviceId());
    String srcTepIp = String.valueOf(update.getSrcInfo().getTepIp().getValue());
    List<VpnInstanceOpDataEntry> vpnInstanceOpData = VpnUtil.getAllVpnInstanceOpData(dataBroker);
    if (vpnInstanceOpData == null) {
        LOG.trace("update: No vpnInstanceOpdata present");
        return;
    }
    WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
    if (tunOpStatus == TunnelOperStatus.Up) {
        handleTunnelEventForDPN(update, TunnelAction.TUNNEL_EP_ADD);
    } else {
        vpnInstanceOpData.stream().filter(opData -> {
            if (opData.getVpnToDpnList() == null) {
                return false;
            }
            return opData.getVpnToDpnList().stream().anyMatch(vpnToDpn -> vpnToDpn.getDpnId().equals(srcDpnId));
        }).forEach(opData -> {
            List<DestPrefixes> prefixes = VpnExtraRouteHelper.getExtraRouteDestPrefixes(dataBroker, opData.getVpnId());
            prefixes.forEach(destPrefix -> {
                VrfEntry vrfEntry = VpnUtil.getVrfEntry(dataBroker, opData.getVrfId(), destPrefix.getDestPrefix());
                if (vrfEntry == null || vrfEntry.getRoutePaths() == null) {
                    return;
                }
                List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
                routePaths.forEach(routePath -> {
                    if (routePath.getNexthopAddress().equals(srcTepIp)) {
                        fibManager.updateRoutePathForFibEntry(opData.getVrfId(), destPrefix.getDestPrefix(), srcTepIp, routePath.getLabel(), false, writeConfigTxn);
                    }
                });
            });
        });
    }
    writeConfigTxn.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) LoggerFactory(org.slf4j.LoggerFactory) TepTypeInternal(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeInternal) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) GetDpnInterfaceListInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Future(java.util.concurrent.Future) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) Optional(com.google.common.base.Optional) Map(java.util.Map) BigInteger(java.math.BigInteger) DcGatewayIpList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre) TunnelsState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelsState) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Set(java.util.Set) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) List(java.util.List) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) PostConstruct(javax.annotation.PostConstruct) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) PortOpData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.PortOpData) PortOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.port.op.data.PortOpDataEntry) PortOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.port.op.data.PortOpDataEntryKey) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) Strings(com.google.common.base.Strings) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) TepTypeHwvtep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeHwvtep) DestPrefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.extraroute.rds.map.extraroute.rds.DestPrefixes) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) TepTypeExternal(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TepTypeExternal) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) AsyncDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) Collectors.toList(java.util.stream.Collectors.toList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) GetDpnInterfaceListOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Collections(java.util.Collections) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) DestPrefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.extraroute.rds.map.extraroute.rds.DestPrefixes) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) BigInteger(java.math.BigInteger)

Example 4 with TunnelOperStatus

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

the class ItmTunnelEventListener method update.

@Override
public void update(@Nonnull InstanceIdentifier<StateTunnelList> instanceIdentifier, @Nonnull StateTunnelList originalTunnelList, @Nonnull StateTunnelList updatedTunnelList) {
    LOG.trace("Tunnel Interface updated. Old: {} New: {}", originalTunnelList, updatedTunnelList);
    TunnelOperStatus operStatus = updatedTunnelList.getOperState();
    if (!Objects.equals(originalTunnelList.getOperState(), updatedTunnelList.getOperState())) {
        LOG.debug("Tunnel Interface {} changed state to {}", originalTunnelList.getTunnelInterfaceName(), operStatus);
        ItmTunnelUpdateAlarmWorker itmTunnelUpdateAlarmWorker = new ItmTunnelUpdateAlarmWorker(originalTunnelList, updatedTunnelList);
        jobCoordinator.enqueueJob(ITMConstants.ITM_ALARM, itmTunnelUpdateAlarmWorker);
    }
}
Also used : TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus)

Example 5 with TunnelOperStatus

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

the class ItmUtils method buildStateTunnelList.

public static StateTunnelList buildStateTunnelList(StateTunnelListKey tlKey, String name, boolean state, TunnelOperStatus tunOpStatus, IInterfaceManager ifaceManager, DataBroker broker) {
    StateTunnelListBuilder stlBuilder = new StateTunnelListBuilder();
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = ItmUtils.getInterface(name, ifaceManager);
    IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
    ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
    if (ifTunnel == null || parentRefs == null) {
        return null;
    }
    DstInfoBuilder dstInfoBuilder = new DstInfoBuilder();
    SrcInfoBuilder srcInfoBuilder = new SrcInfoBuilder();
    dstInfoBuilder.setTepIp(ifTunnel.getTunnelDestination());
    srcInfoBuilder.setTepIp(ifTunnel.getTunnelSource());
    // TODO: Add/Improve logic for device type
    InternalTunnel internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
    ExternalTunnel externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
    if (internalTunnel == null && externalTunnel == null) {
        // both not present in cache. let us update and try again.
        ItmUtils.updateTunnelsCache(broker);
        internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
        externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
    }
    if (internalTunnel != null) {
        srcInfoBuilder.setTepDeviceId(internalTunnel.getSourceDPN().toString()).setTepDeviceType(TepTypeInternal.class);
        dstInfoBuilder.setTepDeviceId(internalTunnel.getDestinationDPN().toString()).setTepDeviceType(TepTypeInternal.class);
        stlBuilder.setTransportType(internalTunnel.getTransportType());
    } else if (externalTunnel != null) {
        ExternalTunnel tunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
        srcInfoBuilder.setTepDeviceId(tunnel.getSourceDevice()).setTepDeviceType(getDeviceType(tunnel.getSourceDevice()));
        dstInfoBuilder.setTepDeviceId(tunnel.getDestinationDevice()).setTepDeviceType(getDeviceType(tunnel.getDestinationDevice())).setTepIp(ifTunnel.getTunnelDestination());
        stlBuilder.setTransportType(tunnel.getTransportType());
    }
    stlBuilder.setKey(tlKey).setTunnelInterfaceName(name).setOperState(tunOpStatus).setTunnelState(state).setDstInfo(dstInfoBuilder.build()).setSrcInfo(srcInfoBuilder.build());
    return stlBuilder.build();
}
Also used : StateTunnelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListBuilder) DstInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.state.tunnel.list.DstInfoBuilder) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) SrcInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.state.tunnel.list.SrcInfoBuilder)

Aggregations

TunnelOperStatus (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 BigInteger (java.math.BigInteger)2 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)2 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)2 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)2 StateTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)2 StateTunnelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey)2 Optional (com.google.common.base.Optional)1 Strings (com.google.common.base.Strings)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1