Search in sources :

Example 1 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.

the class EvpnMacVrfUtils method addEvpnDmacFlow.

public void addEvpnDmacFlow(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
    String elanName = getElanNameByMacvrfiid(instanceIdentifier);
    if (elanName == null) {
        LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
        return;
    }
    List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
    if (checkEvpnAttachedToNet(elanName)) {
        // TODO(Riyaz) : Check if accessing first nexthop address is right solution
        String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
        IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
        Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
        if (elanTag == null) {
            return;
        }
        String dstMacAddress = macVrfEntry.getMac();
        long vni = macVrfEntry.getL2vni();
        jobCoordinator.enqueueJob(dstMacAddress, () -> {
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            dpnInterfaceLists.forEach(dpnInterfaces -> {
                BigInteger dpId = dpnInterfaces.getDpId();
                LOG.info("ADD: Build DMAC flow with dpId {}, nexthopIP {}, elanTag {}," + "vni {}, dstMacAddress {}, elanName {} ", dpId, nexthopIP, elanTag, vni, dstMacAddress, elanName);
                ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
                dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag).setVni(vni).setDstMacAddress(dstMacAddress).setElanName(elanName);
                Flow flow = elanEvpnFlowUtils.evpnBuildDmacFlowForExternalRemoteMac(dmacFlowBuilder.build());
                futures.add(mdsalManager.installFlow(dpId, flow));
            });
            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) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) 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 2 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry 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 3 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry 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 4 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.

the class EvpnMacVrfUtils method removeEvpnDmacFlow.

public void removeEvpnDmacFlow(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
    String elanName = getElanNameByMacvrfiid(instanceIdentifier);
    if (elanName == null) {
        LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
        return;
    }
    List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
    // if (checkEvpnAttachedToNet(elanName)) {
    // TODO(Riyaz) : Check if accessing first nexthop address is right
    String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
    IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
    Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
    if (elanTag == null) {
        return;
    }
    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);
            futures.addAll(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 5 with MacVrfEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry in project netvirt by opendaylight.

the class EvpnMacVrfUtils method getElanNameByMacvrfiid.

public String getElanNameByMacvrfiid(InstanceIdentifier<MacVrfEntry> instanceIdentifier) {
    try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
        String rd = instanceIdentifier.firstKeyOf(VrfTables.class).getRouteDistinguisher();
        String elanName = null;
        InstanceIdentifier<EvpnRdToNetwork> iidEvpnRdToNet = InstanceIdentifier.builder(EvpnRdToNetworks.class).child(EvpnRdToNetwork.class, new EvpnRdToNetworkKey(rd)).build();
        try {
            Optional<EvpnRdToNetwork> evpnRdToNetwork = tx.read(LogicalDatastoreType.CONFIGURATION, iidEvpnRdToNet).checkedGet();
            if (evpnRdToNetwork.isPresent()) {
                elanName = evpnRdToNetwork.get().getNetworkId();
            }
        } catch (ReadFailedException e) {
            LOG.error("getElanName: unable to read elanName, exception ", e);
        }
        return elanName;
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) EvpnRdToNetworkKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey) EvpnRdToNetwork(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork)

Aggregations

MacVrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntry)6 FibEntries (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries)5 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 BigInteger (java.math.BigInteger)4 ArrayList (java.util.ArrayList)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)4 VrfTables (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)4 MacVrfEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryKey)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)2 MacVrfEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.macvrfentries.MacVrfEntryBuilder)2 Nullable (javax.annotation.Nullable)1 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)1 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)1 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)1 EvpnRdToNetwork (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork)1 EvpnRdToNetworkKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey)1