Search in sources :

Example 11 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class ElanPacketInHandler method enqueueJobForDPNSpecificTasks.

private void enqueueJobForDPNSpecificTasks(final String macAddress, final long elanTag, String interfaceName, PhysAddress physAddress, ElanInstance elanInstance, InterfaceInfo interfaceInfo, MacEntry oldMacEntry, MacEntry newMacEntry, boolean isVlanOrFlatProviderIface) {
    jobCoordinator.enqueueJob(ElanUtils.getElanMacDPNKey(elanTag, macAddress, interfaceInfo.getDpId()), () -> {
        macMigrationFlowsCleanup(interfaceName, elanInstance, oldMacEntry, isVlanOrFlatProviderIface);
        BigInteger dpId = interfaceManager.getDpnForInterface(interfaceName);
        elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId, Collections.singletonList(physAddress));
        ElanManagerCounters.unknown_smac_pktin_learned.inc();
        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            elanUtils.setupMacFlows(elanInstance, interfaceInfo, elanInstance.getMacTimeout(), macAddress, !isVlanOrFlatProviderIface, tx);
            InstanceIdentifier<MacEntry> macEntryId = ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
            tx.put(LogicalDatastoreType.OPERATIONAL, macEntryId, newMacEntry, WriteTransaction.CREATE_MISSING_PARENTS);
        }));
    });
}
Also used : NWUtil(org.opendaylight.genius.mdsalutil.NWUtil) PacketProcessingListener(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) MacEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey) NetUtils(org.opendaylight.openflowplugin.libraries.liblldp.NetUtils) PacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason) Inject(javax.inject.Inject) MacEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) Optional(com.google.common.base.Optional) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) NoMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.NoMatch) Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) ElanInstanceCache(org.opendaylight.netvirt.elan.cache.ElanInstanceCache) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) IfIndexInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) EvpnUtils(org.opendaylight.netvirt.elan.evpn.utils.EvpnUtils) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) ElanL2GatewayUtils(org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils) ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Collections(java.util.Collections) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) BigInteger(java.math.BigInteger) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier)

Example 12 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class L2GwValidateCli method readNodes.

private void readNodes() throws ReadFailedException {
    try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
        InstanceIdentifier<Topology> topoId = HwvtepSouthboundUtils.createHwvtepTopologyInstanceIdentifier();
        Optional<Topology> operationalTopoOptional = tx.read(LogicalDatastoreType.OPERATIONAL, topoId).checkedGet();
        Optional<Topology> configTopoOptional = tx.read(LogicalDatastoreType.CONFIGURATION, topoId).checkedGet();
        if (operationalTopoOptional.isPresent()) {
            for (Node node : operationalTopoOptional.get().getNode()) {
                InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
                operationalNodes.put(nodeIid, node);
            }
        }
        if (configTopoOptional.isPresent()) {
            for (Node node : configTopoOptional.get().getNode()) {
                InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
                configNodes.put(nodeIid, node);
            }
        }
        fillNodesData(operationalNodes, operationalNodesData);
        fillNodesData(configNodes, configNodesData);
        Optional<ElanInstances> elanInstancesOptional = tx.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(ElanInstances.class).build()).checkedGet();
        if (elanInstancesOptional.isPresent() && elanInstancesOptional.get().getElanInstance() != null) {
            for (ElanInstance elanInstance : elanInstancesOptional.get().getElanInstance()) {
                elanInstanceMap.put(elanInstance.getElanInstanceName(), elanInstance);
            }
        }
        l2gatewayConnections = L2GatewayConnectionUtils.getAllL2gatewayConnections(dataBroker);
        l2gateways = L2GatewayConnectionUtils.getL2gatewayList(dataBroker);
        for (L2gateway l2gateway : l2gateways) {
            uuidToL2Gateway.put(l2gateway.getUuid(), l2gateway);
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances)

Example 13 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class EvpnMacVrfUtils method removeEvpnDmacFlowOnDetach.

public void removeEvpnDmacFlowOnDetach(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry, ElanInstance elanInstance) {
    // String elanName = getElanNameByMacvrfiid(instanceIdentifier);
    if (elanInstance == null) {
        LOG.error("Error : elanInstance is null for iid {}", instanceIdentifier);
        return;
    }
    List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
    // if (checkEvpnAttachedToNet(elanName)) {
    String nexthopIP = getRoutePathNexthopIp(macVrfEntry);
    if (nexthopIP == null) {
        LOG.debug("nexthopIP is null for iid {}", instanceIdentifier);
        return;
    }
    IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
    Long elanTag = elanInstance.getElanTag();
    String macToRemove = macVrfEntry.getMac();
    jobCoordinator.enqueueJob(macToRemove, () -> {
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        dpnInterfaceLists.forEach(dpnInterfaces -> {
            BigInteger dpId = dpnInterfaces.getDpId();
            ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
            dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setDstMacAddress(macToRemove);
            LOG.info("REMOVE: Deleting DMAC Flows for external MAC. elanTag {}, dpId {}," + "nexthopIP {}, macToRemove {}", elanTag, dpId, nexthopIP, macToRemove);
            elanEvpnFlowUtils.evpnDeleteDmacFlowsToExternalMac(dmacFlowBuilder.build());
        });
        return futures;
    }, ElanConstants.JOB_MAX_RETRIES);
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 14 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class EvpnMacVrfUtils method updateEvpnDmacFlows.

public void updateEvpnDmacFlows(final ElanInstance elanInstance, final boolean install) {
    String rd = evpnUtils.getEvpnRd(elanInstance);
    if (rd == null) {
        return;
    }
    final InstanceIdentifier<VrfTables> iid = InstanceIdentifier.create(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
    evpnUtils.asyncReadAndExecute(LogicalDatastoreType.CONFIGURATION, iid, new StringBuilder(elanInstance.getElanInstanceName()).append(":").append(rd).toString(), (vrfTablesOptional) -> {
        if (!vrfTablesOptional.isPresent()) {
            return null;
        }
        List<MacVrfEntry> macVrfEntries = vrfTablesOptional.get().getMacVrfEntry();
        if (macVrfEntries == null || macVrfEntries.isEmpty()) {
            return null;
        }
        for (MacVrfEntry macVrfEntry : macVrfEntries) {
            InstanceIdentifier<MacVrfEntry> macVrfEntryIid = getMacVrfEntryIid(rd, macVrfEntry);
            if (install) {
                addEvpnDmacFlowOnAttach(macVrfEntryIid, macVrfEntry, elanInstance);
            } else {
                removeEvpnDmacFlowOnDetach(macVrfEntryIid, macVrfEntry, elanInstance);
            }
        }
        return null;
    });
}
Also used : VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) MacVrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)

Example 15 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class EvpnMacVrfUtils method checkEvpnAttachedToNet.

public boolean checkEvpnAttachedToNet(String elanName) {
    ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
    String evpnName = EvpnUtils.getEvpnNameFromElan(elanInfo);
    if (evpnName == null) {
        LOG.error("Error : evpnName is null for elanName {}", elanName);
        return false;
    }
    return true;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Aggregations

ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)75 BigInteger (java.math.BigInteger)36 ArrayList (java.util.ArrayList)33 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)18 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)16 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)14 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)13 ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 EtreeInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance)11 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)11 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)10 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)10 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)10 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)10 ElanInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)10 ElanInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)10 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)9