Search in sources :

Example 11 with Devices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.

the class ElanL2GatewayUtils method getOtherDevicesMacs.

/**
 * Gets the l2 gateway devices ucast local macs as remote ucast macs.
 *
 * @param elanName
 *            the elan name
 * @param l2GatewayDeviceToBeConfigured
 *            the l2 gateway device to be configured
 * @param hwVtepNodeId
 *            the hw vtep node Id to be configured
 * @param logicalSwitchName
 *            the logical switch name
 * @return the l2 gateway devices macs as remote ucast macs
 */
public static List<RemoteUcastMacs> getOtherDevicesMacs(String elanName, L2GatewayDevice l2GatewayDeviceToBeConfigured, NodeId hwVtepNodeId, String logicalSwitchName) {
    List<RemoteUcastMacs> lstRemoteUcastMacs = new ArrayList<>();
    ConcurrentMap<String, L2GatewayDevice> elanL2GwDevicesFromCache = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
    if (elanL2GwDevicesFromCache != null) {
        for (L2GatewayDevice otherDevice : elanL2GwDevicesFromCache.values()) {
            if (l2GatewayDeviceToBeConfigured.getHwvtepNodeId().equals(otherDevice.getHwvtepNodeId())) {
                continue;
            }
            if (!areMLAGDevices(l2GatewayDeviceToBeConfigured, otherDevice)) {
                for (LocalUcastMacs localUcastMac : otherDevice.getUcastLocalMacs()) {
                    HwvtepPhysicalLocatorAugmentation physLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(otherDevice.getTunnelIp().getValue()));
                    RemoteUcastMacs remoteUcastMac = HwvtepSouthboundUtils.createRemoteUcastMac(hwVtepNodeId, localUcastMac.getMacEntryKey().getValue().toLowerCase(Locale.getDefault()), localUcastMac.getIpaddr(), logicalSwitchName, physLocatorAug);
                    lstRemoteUcastMacs.add(remoteUcastMac);
                }
            }
        }
    }
    return lstRemoteUcastMacs;
}
Also used : LocalUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs) RemoteUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs) HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation) ArrayList(java.util.ArrayList) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 12 with Devices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.

the class ElanL2GatewayUtils method deleteElanL2GwDevicesUcastLocalMacsFromDpn.

/**
 * Delete elan l2 gateway devices ucast local macs from dpn.
 *
 * @param elanName
 *            the elan name
 * @param dpnId
 *            the dpn id
 */
public void deleteElanL2GwDevicesUcastLocalMacsFromDpn(final String elanName, final BigInteger dpnId) {
    ConcurrentMap<String, L2GatewayDevice> elanL2GwDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
    if (elanL2GwDevices == null || elanL2GwDevices.isEmpty()) {
        LOG.trace("No L2 gateway devices in Elan [{}] cache.", elanName);
        return;
    }
    final ElanInstance elan = elanInstanceCache.get(elanName).orNull();
    if (elan == null) {
        LOG.error("Could not find Elan by name: {}", elanName);
        return;
    }
    LOG.info("Deleting Elan [{}] L2GatewayDevices UcastLocalMacs from Dpn [{}]", elanName, dpnId);
    final Long elanTag = elan.getElanTag();
    for (final L2GatewayDevice l2GwDevice : elanL2GwDevices.values()) {
        getL2GwDeviceLocalMacsAndRunCallback(elan.getElanInstanceName(), l2GwDevice, (localMacs) -> {
            for (MacAddress mac : localMacs) {
                String jobKey = elanName + ":" + mac.getValue();
                elanClusterUtils.runOnlyInOwnerNode(jobKey, () -> elanDmacUtils.deleteDmacFlowsToExternalMac(elanTag, dpnId, l2GwDevice.getHwvtepNodeId(), mac.getValue()));
            }
            return null;
        });
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 13 with Devices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.

the class ElanL2GatewayUtils method deleteL2GwDeviceUcastLocalMacsFromElan.

/**
 * Delete l2 gateway device ucast local macs from elan.<br>
 * Deletes macs from internal ELAN nodes and also on rest of external l2
 * gateway devices which are part of the ELAN.
 *
 * @param l2GatewayDevice
 *            the l2 gateway device whose ucast local macs to be deleted
 *            from elan
 * @param elanName
 *            the elan name
 */
public void deleteL2GwDeviceUcastLocalMacsFromElan(L2GatewayDevice l2GatewayDevice, String elanName) {
    LOG.info("Deleting L2GatewayDevice [{}] UcastLocalMacs from elan [{}]", l2GatewayDevice.getHwvtepNodeId(), elanName);
    ElanInstance elan = elanInstanceCache.get(elanName).orNull();
    if (elan == null) {
        LOG.error("Could not find Elan by name: {}", elanName);
        return;
    }
    Collection<MacAddress> localMacs = getL2GwDeviceLocalMacs(elanName, l2GatewayDevice);
    unInstallL2GwUcastMacFromL2gwDevices(elanName, l2GatewayDevice, localMacs);
    unInstallL2GwUcastMacFromElanDpns(elan, l2GatewayDevice, localMacs);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 14 with Devices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices 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 15 with Devices

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.

the class ElanL2GatewayUtils method updateVlanBindingsInL2GatewayDevice.

/**
 * Update vlan bindings in l2 gateway device.
 *
 * @param nodeId
 *            the node id
 * @param logicalSwitchName
 *            the logical switch name
 * @param hwVtepDevice
 *            the hardware device
 * @param defaultVlanId
 *            the default vlan id
 * @return the listenable future
 */
public ListenableFuture<Void> updateVlanBindingsInL2GatewayDevice(NodeId nodeId, String logicalSwitchName, Devices hwVtepDevice, Integer defaultVlanId) {
    if (hwVtepDevice == null || hwVtepDevice.getInterfaces() == null || hwVtepDevice.getInterfaces().isEmpty()) {
        String errMsg = "HwVtepDevice is null or interfaces are empty.";
        LOG.error(errMsg);
        return Futures.immediateFailedFuture(new RuntimeException(errMsg));
    }
    return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) {
            // Removed the check for checking terminationPoint present in OP or not
            // for coniguring vlan bindings
            // As we are not any more dependent on it , plugin takes care of this
            // with port reconcilation.
            List<VlanBindings> vlanBindings = new ArrayList<>();
            if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
                for (Integer vlanId : deviceInterface.getSegmentationIds()) {
                    vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, vlanId, logicalSwitchName));
                }
            } else {
                // Use defaultVlanId (specified in L2GatewayConnection) if Vlan
                // ID not specified at interface level.
                vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, defaultVlanId, logicalSwitchName));
            }
            HwvtepUtils.mergeVlanBindings(tx, nodeId, hwVtepDevice.getDeviceName(), deviceInterface.getInterfaceName(), vlanBindings);
        }
        LOG.info("Updated Hwvtep VlanBindings in config DS. NodeID: {}, LogicalSwitch: {}", nodeId.getValue(), logicalSwitchName);
    });
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)

Aggregations

L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)9 ArrayList (java.util.ArrayList)8 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)7 Devices (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices)6 BigInteger (java.math.BigInteger)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)4 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)3 L2gatewayConnection (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)3 L2gateway (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway)3 VlanBindings (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)3 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 HwvtepPhysicalLocatorAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation)2 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)1