Search in sources :

Example 66 with Elan

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

the class ElanL2GatewayUtils method unInstallL2GwUcastMacFromElanDpns.

/**
 * Uninstall l2gw macs from other DPNs in the elan instance provided.
 * @param elan - Elan Instance for which other DPNs will be scanned.
 * @param l2GwDevice - l2gwDevice whose macs are required to be cleared from other devices.
 * @param macAddresses - Mac address to be cleared.
 */
public void unInstallL2GwUcastMacFromElanDpns(final ElanInstance elan, final L2GatewayDevice l2GwDevice, final Collection<MacAddress> macAddresses) {
    if (macAddresses == null || macAddresses.isEmpty()) {
        return;
    }
    if (elan == null || elan.getElanInstanceName() == null) {
        LOG.error("Could not delete l2gw ucast macs, Failed to find the elan for device {}", l2GwDevice.getHwvtepNodeId());
        return;
    }
    final Collection<DpnInterfaces> elanDpns = getElanDpns(elan.getElanInstanceName());
    // Retrieve all participating DPNs in this Elan. Populate this MAC in
    // DMAC table. Looping through all DPNs in order to add/remove mac flows
    // in their DMAC table
    List<ListenableFuture<Void>> result = new ArrayList<>();
    for (final MacAddress mac : macAddresses) {
        elanClusterUtils.runOnlyInOwnerNode(elan.getElanInstanceName() + ":" + mac.getValue(), "delete remote ucast macs in elan DPNs", () -> {
            for (DpnInterfaces elanDpn : elanDpns) {
                BigInteger dpnId = elanDpn.getDpId();
                result.addAll(elanDmacUtils.deleteDmacFlowsToExternalMac(elan.getElanTag(), dpnId, l2GwDevice.getHwvtepNodeId(), mac.getValue().toLowerCase(Locale.getDefault())));
            }
            return result;
        });
    }
}
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) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 67 with Elan

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

the class ElanL2GatewayUtils method deleteElanMacsFromL2GatewayDevice.

/**
 * Delete elan macs from L2 gateway device.<br>
 * This includes deleting ELAN mac table entries plus external device
 * UcastLocalMacs which are part of the same ELAN.
 *
 * @param hwvtepNodeId
 *            the hwvtepNodeId
 * @param elanName
 *            the elan name
 * @return the listenable future
 */
public ListenableFuture<Void> deleteElanMacsFromL2GatewayDevice(String hwvtepNodeId, String elanName) {
    String logicalSwitch = getLogicalSwitchFromElan(elanName);
    List<MacAddress> lstElanMacs = getRemoteUcastMacs(new NodeId(hwvtepNodeId), logicalSwitch, LogicalDatastoreType.CONFIGURATION);
    ListenableFuture<Void> future = HwvtepUtils.deleteRemoteUcastMacs(broker, new NodeId(hwvtepNodeId), logicalSwitch, lstElanMacs);
    Futures.addCallback(future, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void noarg) {
            LOG.trace("Successful in batch deletion of elan [{}] macs from l2gw device [{}]", elanName, hwvtepNodeId);
        }

        @Override
        public void onFailure(Throwable error) {
            LOG.warn("Failed during batch delete of elan {} macs from l2gw device {}. " + "Retrying with sequential deletes.", elanName, hwvtepNodeId, error);
            if (lstElanMacs != null && !lstElanMacs.isEmpty()) {
                for (MacAddress mac : lstElanMacs) {
                    HwvtepUtils.deleteRemoteUcastMac(broker, new NodeId(hwvtepNodeId), logicalSwitch, mac);
                }
            }
        }
    }, MoreExecutors.directExecutor());
    if (LOG.isDebugEnabled()) {
        List<String> elanMacs = lstElanMacs.stream().map(MacAddress::getValue).collect(Collectors.toList());
        LOG.debug("Deleting elan [{}] macs from node [{}]. Deleted macs = {}", elanName, hwvtepNodeId, elanMacs);
    }
    return future;
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 68 with Elan

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

the class ElanL2GatewayUtils method getElanInstanceForUcastLocalMac.

public ElanInstance getElanInstanceForUcastLocalMac(LocalUcastMacs localUcastMac) {
    Optional<LogicalSwitches> lsOpc = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, (InstanceIdentifier<LogicalSwitches>) localUcastMac.getLogicalSwitchRef().getValue());
    if (lsOpc.isPresent()) {
        LogicalSwitches ls = lsOpc.get();
        // Logical switch name is Elan name
        String elanName = getElanFromLogicalSwitch(ls.getHwvtepNodeName().getValue());
        return elanInstanceCache.get(elanName).orNull();
    }
    return null;
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)

Example 69 with Elan

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

the class ElanL2GatewayUtils method installElanMacsInL2GatewayDevice.

/**
 * Install ELAN macs in L2 Gateway device.<br>
 * This includes installing ELAN mac table entries plus external device
 * UcastLocalMacs which are part of the same ELAN.
 *
 * @param elanName
 *            the elan name
 * @param l2GatewayDevice
 *            the l2 gateway device which has to be configured
 * @return the listenable future
 */
public ListenableFuture<Void> installElanMacsInL2GatewayDevice(String elanName, L2GatewayDevice l2GatewayDevice) {
    String logicalSwitchName = getLogicalSwitchFromElan(elanName);
    NodeId hwVtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
    List<RemoteUcastMacs> lstL2GatewayDevicesMacs = getOtherDevicesMacs(elanName, l2GatewayDevice, hwVtepNodeId, logicalSwitchName);
    List<RemoteUcastMacs> lstElanMacTableEntries = getElanMacTableEntriesMacs(elanName, hwVtepNodeId, logicalSwitchName);
    List<RemoteUcastMacs> lstRemoteUcastMacs = new ArrayList<>(lstL2GatewayDevicesMacs);
    lstRemoteUcastMacs.addAll(lstElanMacTableEntries);
    ListenableFuture<Void> future = HwvtepUtils.addRemoteUcastMacs(broker, hwVtepNodeId, lstRemoteUcastMacs);
    LOG.info("Added RemoteUcastMacs entries [{}] in config DS. NodeID: {}, LogicalSwitch: {}", lstRemoteUcastMacs.size(), hwVtepNodeId.getValue(), logicalSwitchName);
    return future;
}
Also used : RemoteUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ArrayList(java.util.ArrayList)

Example 70 with Elan

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

the class L2GatewayConnectionUtils method disAssociateHwvtepsFromElan.

private void disAssociateHwvtepsFromElan(String elanName, L2gatewayConnection input) {
    Integer defaultVlan = input.getSegmentId();
    List<L2GatewayDevice> l2Devices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
    List<Devices> l2gwDevicesToBeDeleted = new ArrayList<>();
    for (L2GatewayDevice elanL2gwDevice : l2Devices) {
        if (elanL2gwDevice.getL2GatewayIds().contains(input.getKey().getUuid())) {
            l2gwDevicesToBeDeleted.addAll(elanL2gwDevice.getDevicesForL2gwConnectionId(input.getKey().getUuid()));
        }
    }
    if (l2gwDevicesToBeDeleted.isEmpty()) {
        // delete logical switch
        Uuid l2GatewayId = input.getL2gatewayId();
        L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GatewayId);
        if (l2Gateway == null) {
            LOG.error("Failed to find the l2gateway for the connection {}", input.getUuid());
            return;
        } else {
            l2gwDevicesToBeDeleted.addAll(l2Gateway.getDevices());
        }
    }
    for (Devices l2Device : l2gwDevicesToBeDeleted) {
        String l2DeviceName = l2Device.getDeviceName();
        L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
        String hwvtepNodeId = l2GatewayDevice.getHwvtepNodeId();
        boolean isLastL2GwConnDeleted = false;
        L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
        if (elanL2GwDevice != null && isLastL2GwConnBeingDeleted(elanL2GwDevice)) {
            // Delete L2 Gateway device from 'ElanL2GwDevice' cache
            LOG.debug("Elan L2Gw Conn cache removed for id {}", hwvtepNodeId);
            ElanL2GwCacheUtils.removeL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
            isLastL2GwConnDeleted = true;
        } else {
            Uuid l2GwConnId = input.getKey().getUuid();
            LOG.debug("Elan L2Gw Conn cache with id {} is being referred by other L2Gw Conns; so only " + "L2 Gw Conn {} reference is removed", hwvtepNodeId, l2GwConnId);
            if (elanL2GwDevice != null) {
                elanL2GwDevice.removeL2GatewayId(l2GwConnId);
            } else {
                isLastL2GwConnDeleted = true;
            }
        }
        DisAssociateHwvtepFromElanJob disAssociateHwvtepToElanJob = new DisAssociateHwvtepFromElanJob(elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanL2GwDevice, elanName, () -> elanInstanceCache.get(elanName).orNull(), l2Device, defaultVlan, hwvtepNodeId, isLastL2GwConnDeleted);
        elanClusterUtils.runOnlyInOwnerNode(disAssociateHwvtepToElanJob.getJobKey(), "remove l2gw connection job", disAssociateHwvtepToElanJob);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) DisAssociateHwvtepFromElanJob(org.opendaylight.netvirt.elan.l2gw.jobs.DisAssociateHwvtepFromElanJob)

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