Search in sources :

Example 6 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class HwvtepTerminationPointListener method handlePortAdded.

private List<ListenableFuture<Void>> handlePortAdded(TerminationPoint portAdded, NodeId psNodeId) {
    Node psNode = HwvtepUtils.getHwVtepNode(broker, LogicalDatastoreType.OPERATIONAL, psNodeId);
    if (psNode != null) {
        String psName = psNode.getAugmentation(PhysicalSwitchAugmentation.class).getHwvtepNodeName().getValue();
        L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
        if (l2GwDevice != null) {
            if (isL2GatewayConfigured(l2GwDevice)) {
                List<L2gatewayConnection> l2GwConns = L2GatewayConnectionUtils.getAssociatedL2GwConnections(broker, l2GwDevice.getL2GatewayIds());
                String newPortId = portAdded.getTpId().getValue();
                NodeId hwvtepNodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
                List<VlanBindings> vlanBindings = getVlanBindings(l2GwConns, hwvtepNodeId, psName, newPortId);
                return Collections.singletonList(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(hwvtepNodeId, psName, newPortId, vlanBindings));
            }
        } else {
            LOG.error("{} details are not present in L2Gateway Cache", psName);
        }
    } else {
        LOG.error("{} entry not in config datastore", psNodeId);
    }
    return Collections.emptyList();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 7 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class LocalUcastMacListener method added.

public void added(final InstanceIdentifier<LocalUcastMacs> identifier, final LocalUcastMacs macAdded) {
    ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, identifier, macAdded);
    String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
    String macAddress = macAdded.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
    String elanName = getElanName(macAdded);
    LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
    ElanInstance elan = elanInstanceCache.get(elanName).orNull();
    if (elan == null) {
        LOG.warn("Could not find ELAN for mac {} being added", macAddress);
        return;
    }
    jobCoordinator.enqueueJob(elanName + HwvtepHAUtil.L2GW_JOB_KEY, () -> {
        L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
        if (elanL2GwDevice == null) {
            LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
            return null;
        }
        elanL2GwDevice.addUcastLocalMac(macAdded);
        elanL2GatewayUtils.installL2GwUcastMacInElan(elan, elanL2GwDevice, macAddress.toLowerCase(), macAdded, null);
        return null;
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 8 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method getRemoteBCGroupBucketsOfElanL2GwDevices.

public List<Bucket> getRemoteBCGroupBucketsOfElanL2GwDevices(ElanInstance elanInfo, BigInteger dpnId, int bucketId) {
    List<Bucket> listBucketInfo = new ArrayList<>();
    ConcurrentMap<String, L2GatewayDevice> map = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInfo.getElanInstanceName());
    for (L2GatewayDevice device : map.values()) {
        String interfaceName = elanItmUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId), device.getHwvtepNodeId());
        if (interfaceName == null) {
            continue;
        }
        List<Action> listActionInfo = elanItmUtils.buildTunnelItmEgressActions(interfaceName, ElanUtils.getVxlanSegmentationId(elanInfo));
        listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
        bucketId++;
    }
    return listBucketInfo;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ArrayList(java.util.ArrayList) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 9 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method updateMcastMacsForAllElanDevices.

/**
 * Update mcast macs for this elan.
 * for all dpns in this elan  recompute and update broadcast group
 * for all l2gw devices in this elan recompute and update remote mcast mac entry
 *
 * @param elanName
 *            the elan name
 * @param device
 *            the device
 * @param updateThisDevice
 *            the update this device
 * @return the listenable future
 */
private ListenableFuture<Void> updateMcastMacsForAllElanDevices(String elanName, L2GatewayDevice device, boolean updateThisDevice) {
    SettableFuture<Void> ft = SettableFuture.create();
    ft.set(null);
    List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanName);
    ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
    List<IpAddress> dpnsTepIps = getAllTepIpsOfDpns(device, dpns);
    List<IpAddress> l2GwDevicesTepIps = getAllTepIpsOfL2GwDevices(devices);
    return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        if (updateThisDevice) {
            preapareRemoteMcastMacEntry(elanName, device, dpnsTepIps, l2GwDevicesTepIps);
        }
        // present to configure RemoteMcastMac entry
        for (L2GatewayDevice otherDevice : devices.values()) {
            if (!otherDevice.getDeviceName().equals(device.getDeviceName())) {
                preapareRemoteMcastMacEntry(elanName, otherDevice, dpnsTepIps, l2GwDevicesTepIps);
            }
        }
    });
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 10 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class ElanL2GatewayUtils method getL2GwDeviceLocalMacs.

/**
 * Gets the l2 gw device local macs.
 * @param elanName
 *            name of the elan
 * @param l2gwDevice
 *            the l2gw device
 * @return the l2 gw device local macs
 */
public Collection<MacAddress> getL2GwDeviceLocalMacs(String elanName, L2GatewayDevice l2gwDevice) {
    if (l2gwDevice == null) {
        return Collections.emptyList();
    }
    Collection<LocalUcastMacs> lstUcastLocalMacs = l2gwDevice.getUcastLocalMacs();
    Set<MacAddress> macs = new HashSet<>();
    if (!lstUcastLocalMacs.isEmpty()) {
        macs.addAll(lstUcastLocalMacs.stream().filter(Objects::nonNull).map(mac -> new MacAddress(mac.getMacEntryKey().getValue().toLowerCase())).collect(Collectors.toList()));
    }
    Optional<Node> configNode = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(l2gwDevice.getHwvtepNodeId())));
    if (configNode.isPresent()) {
        HwvtepGlobalAugmentation augmentation = configNode.get().getAugmentation(HwvtepGlobalAugmentation.class);
        if (augmentation != null && augmentation.getLocalUcastMacs() != null) {
            macs.addAll(augmentation.getLocalUcastMacs().stream().filter(mac -> getLogicalSwitchName(mac).equals(elanName)).map(mac -> mac.getMacEntryKey()).collect(Collectors.toSet()));
        }
    }
    return macs;
}
Also used : HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation) RemoteMcastMacsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacsKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Future(java.util.concurrent.Future) ElanClusterUtils(org.opendaylight.netvirt.elan.utils.ElanClusterUtils) HwvtepHAUtil(org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) Pair(org.apache.commons.lang3.tuple.Pair) Optional(com.google.common.base.Optional) BigInteger(java.math.BigInteger) LocalUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) DeleteLogicalSwitchJob(org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) MacTable(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTable) Set(java.util.Set) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Interfaces(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces) DeleteL2GwDeviceMacsFromElanJob(org.opendaylight.netvirt.elan.l2gw.jobs.DeleteL2GwDeviceMacsFromElanJob) RemoteMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs) ElanConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig) HwvtepSouthboundConstants(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) ExternalTeps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ExternalTeps) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) GetDpidFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder) JdkFutures(org.opendaylight.infrautils.utils.concurrent.JdkFutures) LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) GetDpidFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) ElanInstanceDpnsCache(org.opendaylight.netvirt.elan.cache.ElanInstanceDpnsCache) FutureCallback(com.google.common.util.concurrent.FutureCallback) RemoteUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) ScheduledFuture(java.util.concurrent.ScheduledFuture) ElanItmUtils(org.opendaylight.netvirt.elan.utils.ElanItmUtils) ElanL2GwCacheUtils(org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils) ElanConstants(org.opendaylight.netvirt.elan.utils.ElanConstants) LoggerFactory(org.slf4j.LoggerFactory) HwvtepUtils(org.opendaylight.genius.utils.hwvtep.HwvtepUtils) HwvtepMacTableGenericAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepMacTableGenericAttributes) PreDestroy(javax.annotation.PreDestroy) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) Locale(java.util.Locale) AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) ElanDmacUtils(org.opendaylight.netvirt.elan.utils.ElanDmacUtils) Collectors(java.util.stream.Collectors) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Objects(java.util.Objects) List(java.util.List) ElanException(org.opendaylight.netvirt.elan.ElanException) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) LocatorSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HwvtepPhysicalLocatorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef) Singleton(javax.inject.Singleton) Function(java.util.function.Function) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) Inject(javax.inject.Inject) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) Nonnull(javax.annotation.Nonnull) HwvtepLogicalSwitchRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef) HwvtepSouthboundUtils(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils) Logger(org.slf4j.Logger) ElanInstanceCache(org.opendaylight.netvirt.elan.cache.ElanInstanceCache) Scheduler(org.opendaylight.netvirt.elan.utils.Scheduler) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) SystemPropertyReader(org.opendaylight.genius.utils.SystemPropertyReader) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TimeUnit(java.util.concurrent.TimeUnit) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Collections(java.util.Collections) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) LocalUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) HashSet(java.util.HashSet)

Aggregations

L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)41 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)16 ArrayList (java.util.ArrayList)12 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)12 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)11 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)10 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 BigInteger (java.math.BigInteger)7 Devices (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices)7 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)7 List (java.util.List)5 Set (java.util.Set)5 Inject (javax.inject.Inject)5 Singleton (javax.inject.Singleton)5 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)5 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)5 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)5 HwvtepSouthboundUtils (org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils)5 HwvtepUtils (org.opendaylight.genius.utils.hwvtep.HwvtepUtils)5