Search in sources :

Example 1 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project netvirt by opendaylight.

the class ElanInterfaceManager method setupLeavesLocalBroadcastGroups.

private void setupLeavesLocalBroadcastGroups(ElanInstance elanInfo, DpnInterfaces newDpnInterface, InterfaceInfo interfaceInfo) {
    EtreeInstance etreeInstance = elanInfo.getAugmentation(EtreeInstance.class);
    if (etreeInstance != null) {
        List<Bucket> listBucket = new ArrayList<>();
        int bucketId = 0;
        List<String> interfaces = new ArrayList<>();
        if (newDpnInterface != null) {
            interfaces = newDpnInterface.getInterfaces();
        }
        for (String ifName : interfaces) {
            // In case if there is a InterfacePort in the cache which is not
            // in
            // operational state, skip processing it
            InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
            if (!isOperational(ifInfo)) {
                continue;
            }
            if (!interfaceManager.isExternalInterface(ifName)) {
                // only add root interfaces
                bucketId = addInterfaceIfRootInterface(bucketId, ifName, listBucket, ifInfo);
            }
        }
        if (listBucket.isEmpty()) {
            // No Buckets
            createDropBucket(listBucket);
        }
        long etreeLeafTag = etreeInstance.getEtreeLeafTagVal().getValue();
        long groupId = ElanUtils.getEtreeLeafLocalBCGId(etreeLeafTag);
        Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
        LOG.trace("installing the localBroadCast Group:{}", group);
        mdsalManager.syncInstallGroup(interfaceInfo.getDpId(), group);
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ArrayList(java.util.ArrayList) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 2 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project netvirt by opendaylight.

the class ElanInterfaceManager method validateExternalTunnelStateEvent.

/**
 * Validate external tunnel state event.
 *
 * @param externalTunnel
 *            the external tunnel
 * @param intrf
 *            the intrf
 * @return true, if successful
 */
private boolean validateExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf) {
    if (intrf.getOperStatus() == Interface.OperStatus.Up) {
        String srcDevice = externalTunnel.getDestinationDevice();
        String destDevice = externalTunnel.getSourceDevice();
        ExternalTunnel otherEndPointExtTunnel = elanUtils.getExternalTunnel(srcDevice, destDevice, LogicalDatastoreType.CONFIGURATION);
        LOG.trace("Validating external tunnel state: src tunnel {}, dest tunnel {}", externalTunnel, otherEndPointExtTunnel);
        if (otherEndPointExtTunnel != null) {
            boolean otherEndPointInterfaceOperational = ElanUtils.isInterfaceOperational(otherEndPointExtTunnel.getTunnelInterfaceName(), broker);
            if (otherEndPointInterfaceOperational) {
                return true;
            } else {
                LOG.debug("Other end [{}] of the external tunnel is not yet UP for {}", otherEndPointExtTunnel.getTunnelInterfaceName(), externalTunnel);
            }
        }
    }
    return false;
}
Also used : ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)

Example 3 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project netvirt by opendaylight.

the class ElanInterfaceManager method handleInternalTunnelStateEvent.

@SuppressWarnings("checkstyle:IllegalCatch")
public void handleInternalTunnelStateEvent(BigInteger srcDpId, BigInteger dstDpId) {
    ElanDpnInterfaces dpnInterfaceLists = elanUtils.getElanDpnInterfacesList();
    LOG.trace("processing tunnel state event for srcDpId {} dstDpId {}" + " and dpnInterfaceList {}", srcDpId, dstDpId, dpnInterfaceLists);
    if (dpnInterfaceLists == null) {
        return;
    }
    List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
    for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
        int cnt = 0;
        String elanName = elanDpns.getElanInstanceName();
        ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
        if (elanInfo == null) {
            LOG.warn("ELAN Info is null for elanName {} that does exist in elanDpnInterfaceList, " + "skipping this ELAN for tunnel handling", elanName);
            continue;
        }
        if (ElanUtils.isFlat(elanInfo) || ElanUtils.isVlan(elanInfo)) {
            LOG.debug("Ignoring internal tunnel state event for Flat/Vlan elan {}", elanName);
            continue;
        }
        List<DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
        if (dpnInterfaces == null) {
            continue;
        }
        DpnInterfaces dstDpnIf = null;
        for (DpnInterfaces dpnIf : dpnInterfaces) {
            BigInteger dpnIfDpId = dpnIf.getDpId();
            if (dpnIfDpId.equals(srcDpId)) {
                cnt++;
            } else if (dpnIfDpId.equals(dstDpId)) {
                cnt++;
                dstDpnIf = dpnIf;
            }
        }
        if (cnt == 2) {
            LOG.info("Elan instance:{} is present b/w srcDpn:{} and dstDpn:{}", elanName, srcDpId, dstDpId);
            // var needs to be final so it can be accessed in lambda
            final DpnInterfaces finalDstDpnIf = dstDpnIf;
            jobCoordinator.enqueueJob(elanName, () -> {
                // update Remote BC Group
                LOG.trace("procesing elan remote bc group for tunnel event {}", elanInfo);
                try {
                    elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, srcDpId);
                } catch (RuntimeException e) {
                    LOG.error("Error while adding remote bc group for {} on dpId {} ", elanName, srcDpId);
                }
                Set<String> interfaceLists = new HashSet<>();
                interfaceLists.addAll(finalDstDpnIf.getInterfaces());
                for (String ifName : interfaceLists) {
                    jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(ifName), () -> {
                        LOG.info("Processing tunnel up event for elan {} and interface {}", elanName, ifName);
                        InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(ifName);
                        if (isOperational(interfaceInfo)) {
                            return installDMacAddressTables(elanInfo, interfaceInfo, srcDpId);
                        }
                        return Collections.emptyList();
                    }, ElanConstants.JOB_MAX_RETRIES);
                }
                return Collections.emptyList();
            }, ElanConstants.JOB_MAX_RETRIES);
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) BigInteger(java.math.BigInteger) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) HashSet(java.util.HashSet)

Example 4 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State in project netvirt by opendaylight.

the class ElanInterfaceManager method setupStandardLocalBroadcastGroups.

public void setupStandardLocalBroadcastGroups(ElanInstance elanInfo, DpnInterfaces newDpnInterface, InterfaceInfo interfaceInfo) {
    List<Bucket> listBucket = new ArrayList<>();
    int bucketId = 0;
    long groupId = ElanUtils.getElanLocalBCGId(elanInfo.getElanTag());
    List<String> interfaces = new ArrayList<>();
    if (newDpnInterface != null) {
        interfaces = newDpnInterface.getInterfaces();
    }
    for (String ifName : interfaces) {
        // In case if there is a InterfacePort in the cache which is not in
        // operational state, skip processing it
        InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
        if (!isOperational(ifInfo)) {
            continue;
        }
        if (!interfaceManager.isExternalInterface(ifName)) {
            listBucket.add(MDSALUtil.buildBucket(getInterfacePortActions(ifInfo), MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
            bucketId++;
        }
    }
    Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
    LOG.trace("installing the localBroadCast Group:{}", group);
    mdsalManager.syncInstallGroup(interfaceInfo.getDpId(), group);
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ArrayList(java.util.ArrayList) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 5 with State

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State 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)

Aggregations

ArrayList (java.util.ArrayList)31 Test (org.junit.Test)28 BigInteger (java.math.BigInteger)27 List (java.util.List)15 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)14 Collections (java.util.Collections)13 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Optional (com.google.common.base.Optional)11 Inject (javax.inject.Inject)11 Singleton (javax.inject.Singleton)11 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)10 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)10 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)10 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)10 FutureCallback (com.google.common.util.concurrent.FutureCallback)9 ByteBuf (io.netty.buffer.ByteBuf)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9