Search in sources :

Example 11 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class EvpnUtils method programEvpnL2vniDemuxTable.

public void programEvpnL2vniDemuxTable(String elanName, final BiConsumer<String, String> serviceHandler, BiConsumer<BigInteger, FlowEntity> flowHandler) {
    ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
    List<String> tunnelInterfaceNameList = getDcGatewayTunnelInterfaceNameList();
    if (tunnelInterfaceNameList.isEmpty()) {
        LOG.info("No DC gateways tunnels while programming l2vni table for elan {}.", elanName);
        return;
    }
    tunnelInterfaceNameList.forEach(tunnelInterfaceName -> {
        serviceHandler.accept(elanName, tunnelInterfaceName);
    });
    programEvpnL2vniFlow(elanInfo, flowHandler);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 12 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class EvpnUtils method advertiseEvpnRT2Routes.

@SuppressWarnings("checkstyle:IllegalCatch")
public void advertiseEvpnRT2Routes(EvpnAugmentation evpnAugmentation, String elanName) {
    if (evpnAugmentation == null || evpnAugmentation.getEvpnName() == null) {
        return;
    }
    String evpnName = evpnAugmentation.getEvpnName();
    List<MacEntry> macEntries = elanUtils.getElanMacEntries(elanName);
    if (macEntries == null || macEntries.isEmpty()) {
        LOG.trace("advertiseEvpnRT2Routes no elan mac entries found for {}", elanName);
        return;
    }
    String rd = vpnManager.getVpnRd(broker, evpnName);
    ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
    macEntries.stream().filter(isIpv4PrefixAvailable).forEach(macEntry -> {
        InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(macEntry.getInterface());
        if (interfaceInfo == null) {
            LOG.debug("advertiseEvpnRT2Routes, interfaceInfo is null for interface {}", macEntry.getInterface());
            return;
        }
        advertisePrefix(elanInfo, rd, macEntry.getMacAddress().getValue(), macEntry.getIpPrefix().getIpv4Address().getValue(), interfaceInfo.getInterfaceName(), interfaceInfo.getDpId());
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 13 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class EvpnUtils method withdrawEvpnRT2Routes.

public void withdrawEvpnRT2Routes(EvpnAugmentation evpnAugmentation, String elanName) {
    if (evpnAugmentation == null || evpnAugmentation.getEvpnName() == null) {
        LOG.trace("withdrawEvpnRT2Routes, evpnAugmentation is null");
        return;
    }
    String evpnName = evpnAugmentation.getEvpnName();
    String rd = vpnManager.getVpnRd(broker, evpnName);
    if (rd == null) {
        LOG.debug("withdrawEvpnRT2Routes : rd is null for {}", elanName);
        return;
    }
    List<MacEntry> macEntries = elanUtils.getElanMacEntries(elanName);
    if (macEntries == null || macEntries.isEmpty()) {
        LOG.debug("withdrawEvpnRT2Routes : macEntries  is empty for elan {} ", elanName);
        return;
    }
    for (MacEntry macEntry : macEntries) {
        if (!isIpv4PrefixAvailable.test(macEntry)) {
            LOG.debug("withdrawEvpnRT2Routes macEntry does not have IPv4 prefix {}", macEntry);
            continue;
        }
        String prefix = macEntry.getIpPrefix().getIpv4Address().getValue();
        LOG.info("Withdrawing routes with rd {}, prefix {}", rd, prefix);
        bgpManager.withdrawPrefix(rd, prefix);
    }
}
Also used : MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)

Example 14 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanGroupListener method update.

@Override
protected void update(InstanceIdentifier<Group> identifier, Group original, Group update) {
    LOG.trace("received group updated {}", update.getKey().getGroupId());
    final BigInteger dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
    if (dpnId == null) {
        return;
    }
    List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
    if (allDevices == null || allDevices.isEmpty()) {
        LOG.trace("no elan devices present in cache {}", update.getKey().getGroupId());
        return;
    }
    int expectedElanFootprint = 0;
    final ElanInstance elanInstance = getElanInstanceFromGroupId(update);
    if (elanInstance == null) {
        LOG.trace("no elan instance is null {}", update.getKey().getGroupId());
        return;
    }
    ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstance.getElanInstanceName());
    if (devices == null || devices.isEmpty()) {
        LOG.trace("no elan devices in elan cache {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
        return;
    }
    boolean updateGroup = false;
    List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
    if (dpns.size() > 0) {
        expectedElanFootprint += dpns.size();
    } else {
        updateGroup = true;
    }
    expectedElanFootprint += devices.size();
    if (update.getBuckets() != null && update.getBuckets().getBucket() != null) {
        if (update.getBuckets().getBucket().size() != expectedElanFootprint) {
            updateGroup = true;
        } else {
            LOG.trace("no of buckets matched perfectly {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
        }
    }
    if (updateGroup) {
        List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0, elanInstance.getElanTag());
        // remove local bcgroup bucket
        expectedElanFootprint--;
        if (bucketList.size() != expectedElanFootprint) {
            // no point in retrying if not able to meet expected foot print
            return;
        }
        LOG.trace("no of buckets mismatched {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
        elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
            elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId);
            return null;
        });
    } else {
        LOG.trace("no buckets in the update {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) BigInteger(java.math.BigInteger)

Example 15 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanInstanceListener method remove.

@Override
protected void remove(final InstanceIdentifier<ElanInstance> identifier, final ElanInstance del) {
    elanClusterUtils.runOnlyInOwnerNode(del.getElanInstanceName(), "delete Elan instance", () -> {
        LOG.info("Elan instance {} deleted from Configuration tree ", del);
        List<L2gatewayConnection> connections = L2GatewayConnectionUtils.getL2GwConnectionsByElanName(this.broker, del.getElanInstanceName());
        if (connections.isEmpty()) {
            return Collections.emptyList();
        }
        ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
            for (L2gatewayConnection connection : connections) {
                InstanceIdentifier<L2gatewayConnection> iid = InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class).child(L2gatewayConnection.class, connection.getKey());
                tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
            }
        });
        ListenableFutures.addErrorLogging(future, LOG, "Failed to delete associate L2 gateway connection while deleting network");
        return Collections.singletonList(future);
    });
}
Also used : L2gatewayConnections(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Aggregations

ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)52 BigInteger (java.math.BigInteger)36 ArrayList (java.util.ArrayList)31 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)18 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)18 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)14 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)13 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)13 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)12 ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)9 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)9 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)9 Elan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan)9 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8