Search in sources :

Example 11 with ElanDpnInterfacesList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList in project netvirt by opendaylight.

the class ElanInterfaceManager method handleExternalTunnelStateEvent.

/**
 * Handle external tunnel state event.
 *
 * @param externalTunnel
 *            the external tunnel
 * @param intrf
 *            the interface
 * @throws ElanException in case of issues creating the flow objects
 */
public void handleExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf) throws ElanException {
    if (!validateExternalTunnelStateEvent(externalTunnel, intrf)) {
        return;
    }
    // dpId/externalNodeId will be available either in source or destination
    // based on the tunnel end point
    BigInteger dpId = null;
    NodeId externalNodeId = null;
    if (StringUtils.isNumeric(externalTunnel.getSourceDevice())) {
        dpId = new BigInteger(externalTunnel.getSourceDevice());
        externalNodeId = new NodeId(externalTunnel.getDestinationDevice());
    } else if (StringUtils.isNumeric(externalTunnel.getDestinationDevice())) {
        dpId = new BigInteger(externalTunnel.getDestinationDevice());
        externalNodeId = new NodeId(externalTunnel.getSourceDevice());
    }
    if (dpId == null || externalNodeId == null) {
        LOG.error("Dp ID / externalNodeId not found in external tunnel {}", externalTunnel);
        return;
    }
    ElanDpnInterfaces dpnInterfaceLists = elanUtils.getElanDpnInterfacesList();
    if (dpnInterfaceLists == null) {
        return;
    }
    List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
    for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
        String elanName = elanDpns.getElanInstanceName();
        ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
        DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanName, dpId);
        if (elanInfo == null || dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
            continue;
        }
        LOG.debug("Elan instance:{} is present in Dpn:{} ", elanName, dpId);
        elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, dpId);
        // install L2gwDevices local macs in dpn.
        elanL2GatewayUtils.installL2gwDeviceMacsInDpn(dpId, externalNodeId, elanInfo, intrf.getName());
        // Install dpn macs on external device
        installDpnMacsInL2gwDevice(elanName, new HashSet<>(dpnInterfaces.getInterfaces()), dpId, externalNodeId);
    }
    LOG.info("Handled ExternalTunnelStateEvent for {}", externalTunnel);
}
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) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) 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) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)

Example 12 with ElanDpnInterfacesList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList in project netvirt by opendaylight.

the class ElanInterfaceManager method programRemoteDmacFlow.

void programRemoteDmacFlow(ElanInstance elanInstance, InterfaceInfo interfaceInfo, WriteTransaction writeFlowGroupTx) throws ElanException {
    ElanDpnInterfacesList elanDpnInterfacesList = elanUtils.getElanDpnInterfacesList(elanInstance.getElanInstanceName());
    List<DpnInterfaces> dpnInterfaceLists = null;
    if (elanDpnInterfacesList != null) {
        dpnInterfaceLists = elanDpnInterfacesList.getDpnInterfaces();
    }
    if (dpnInterfaceLists == null) {
        dpnInterfaceLists = new ArrayList<>();
    }
    for (DpnInterfaces dpnInterfaces : dpnInterfaceLists) {
        BigInteger dstDpId = interfaceInfo.getDpId();
        if (dpnInterfaces.getDpId().equals(dstDpId)) {
            continue;
        }
        List<String> remoteElanInterfaces = dpnInterfaces.getInterfaces();
        for (String remoteIf : remoteElanInterfaces) {
            ElanInterfaceMac elanIfMac = elanUtils.getElanInterfaceMacByInterfaceName(remoteIf);
            InterfaceInfo remoteInterface = interfaceManager.getInterfaceInfo(remoteIf);
            if (elanIfMac == null) {
                continue;
            }
            List<MacEntry> remoteMacEntries = elanIfMac.getMacEntry();
            if (remoteMacEntries != null) {
                for (MacEntry macEntry : remoteMacEntries) {
                    String macAddress = macEntry.getMacAddress().getValue();
                    LOG.info("Programming remote dmac {} on the newly added DPN {} for elan {}", macAddress, dstDpId, elanInstance.getElanInstanceName());
                    elanUtils.setupRemoteDmacFlow(dstDpId, remoteInterface.getDpId(), remoteInterface.getInterfaceTag(), elanInstance.getElanTag(), macAddress, elanInstance.getElanInstanceName(), writeFlowGroupTx, remoteIf, elanInstance);
                }
            }
        }
    }
}
Also used : MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) 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) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)

Aggregations

ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)10 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)10 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)9 BigInteger (java.math.BigInteger)6 ArrayList (java.util.ArrayList)6 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)4 Nonnull (javax.annotation.Nonnull)3 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)3 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)3 HashSet (java.util.HashSet)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 ElanException (org.opendaylight.netvirt.elan.ElanException)2 ElanDpnInterfacesListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesListKey)2 Optional (com.google.common.base.Optional)1 Collections (java.util.Collections)1 Collections.emptyList (java.util.Collections.emptyList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1