Search in sources :

Example 11 with LocalUcastMacs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs in project netvirt by opendaylight.

the class DhcpUCastMacListener method add.

@Override
protected void add(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs add) {
    NodeId torNodeId = identifier.firstKeyOf(Node.class).getNodeId();
    InstanceIdentifier<LogicalSwitches> logicalSwitchRef = (InstanceIdentifier<LogicalSwitches>) add.getLogicalSwitchRef().getValue();
    Optional<LogicalSwitches> logicalSwitchOptional = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, logicalSwitchRef);
    if (!logicalSwitchOptional.isPresent()) {
        LOG.error("Logical Switch ref doesn't have data {}", logicalSwitchRef);
        return;
    }
    LogicalSwitches logicalSwitch = logicalSwitchOptional.get();
    String elanInstanceName = logicalSwitch.getHwvtepNodeName().getValue();
    String macAddress = add.getMacEntryKey().getValue();
    BigInteger vni = new BigInteger(logicalSwitch.getTunnelKey());
    Port port = dhcpExternalTunnelManager.readVniMacToPortCache(vni, macAddress);
    if (port == null) {
        LOG.trace("No neutron port created for macAddress {}, tunnelKey {}", macAddress, vni);
        return;
    }
    L2GatewayDevice device = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanInstanceName, torNodeId.getValue());
    if (device == null) {
        LOG.error("Logical Switch Device with name {} is not present in L2GWCONN cache", elanInstanceName);
        return;
    }
    IpAddress tunnelIp = device.getTunnelIp();
    Subnet subnet = dhcpManager.getNeutronSubnet(port);
    if (null != subnet && !subnet.isEnableDhcp()) {
        dhcpExternalTunnelManager.updateExistingVMTunnelIPCache(tunnelIp, elanInstanceName, macAddress);
        LOG.warn("DhcpUCastMacListener add: flag for the subnetId {} is False so Table 18 entries are not added", subnet.getUuid());
        return;
    }
    BigInteger designatedDpnId = dhcpExternalTunnelManager.readDesignatedSwitchesForExternalTunnel(tunnelIp, elanInstanceName);
    if (designatedDpnId == null || designatedDpnId.equals(DhcpMConstants.INVALID_DPID)) {
        LOG.trace("Unable to install flows for macAddress {}. TunnelIp {}, elanInstanceName {}, designatedDpn {} ", macAddress, tunnelIp, elanInstanceName, designatedDpnId);
        dhcpExternalTunnelManager.updateLocalCache(tunnelIp, elanInstanceName, macAddress);
        return;
    }
    dhcpExternalTunnelManager.installDhcpFlowsForVms(tunnelIp, elanInstanceName, DhcpServiceUtils.getListOfDpns(broker), designatedDpnId, macAddress);
}
Also used : 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) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 12 with LocalUcastMacs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs 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 13 with LocalUcastMacs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs 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 14 with LocalUcastMacs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs in project netvirt by opendaylight.

the class L2GatewayConnectionUtils method readAndCopyLocalUcastMacsToCache.

private void readAndCopyLocalUcastMacsToCache(final String elanName, final L2GatewayDevice l2GatewayDevice) {
    final InstanceIdentifier<Node> nodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(l2GatewayDevice.getHwvtepNodeId()));
    jobCoordinator.enqueueJob(elanName + ":" + l2GatewayDevice.getDeviceName(), () -> {
        final SettableFuture settableFuture = SettableFuture.create();
        Futures.addCallback(broker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, nodeIid), new SettableFutureCallback<Optional<Node>>(settableFuture) {

            @Override
            public void onSuccess(@Nonnull Optional<Node> resultNode) {
                LocalUcastMacListener localUcastMacListener = new LocalUcastMacListener(broker, haOpClusteredListener, elanL2GatewayUtils, jobCoordinator, elanInstanceCache);
                settableFuture.set(resultNode);
                Optional<Node> nodeOptional = resultNode;
                if (nodeOptional.isPresent()) {
                    Node node = nodeOptional.get();
                    if (node.getAugmentation(HwvtepGlobalAugmentation.class) != null) {
                        List<LocalUcastMacs> localUcastMacs = node.getAugmentation(HwvtepGlobalAugmentation.class).getLocalUcastMacs();
                        if (localUcastMacs == null) {
                            return;
                        }
                        localUcastMacs.stream().filter((mac) -> {
                            return macBelongsToLogicalSwitch(mac, elanName);
                        }).forEach((mac) -> {
                            InstanceIdentifier<LocalUcastMacs> macIid = getMacIid(nodeIid, mac);
                            localUcastMacListener.added(macIid, mac);
                        });
                    }
                }
            }
        }, MoreExecutors.directExecutor());
        return Lists.newArrayList(settableFuture);
    }, 5);
}
Also used : SettableFuture(com.google.common.util.concurrent.SettableFuture) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection) ElanL2GwCacheUtils(org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils) L2gateways(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.L2gateways) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) LoggerFactory(org.slf4j.LoggerFactory) AssociateHwvtepToElanJob(org.opendaylight.netvirt.elan.l2gw.jobs.AssociateHwvtepToElanJob) SettableFuture(com.google.common.util.concurrent.SettableFuture) Singleton(javax.inject.Singleton) HwvtepLogicalSwitchListener(org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLogicalSwitchListener) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) HwvtepUtils(org.opendaylight.genius.utils.hwvtep.HwvtepUtils) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) PreDestroy(javax.annotation.PreDestroy) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HAOpClusteredListener(org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpClusteredListener) ElanClusterUtils(org.opendaylight.netvirt.elan.utils.ElanClusterUtils) Lists(com.google.common.collect.Lists) Optional(com.google.common.base.Optional) LocalUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) LocalUcastMacListener(org.opendaylight.netvirt.elan.l2gw.listeners.LocalUcastMacListener) Nonnull(javax.annotation.Nonnull) HwvtepSouthboundUtils(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Logger(org.slf4j.Logger) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ElanInstanceCache(org.opendaylight.netvirt.elan.cache.ElanInstanceCache) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Set(java.util.Set) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) L2gatewayConnections(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections) L2gatewayKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gatewayKey) DisAssociateHwvtepFromElanJob(org.opendaylight.netvirt.elan.l2gw.jobs.DisAssociateHwvtepFromElanJob) ElanUtils.isVxlanNetworkOrVxlanSegment(org.opendaylight.netvirt.elan.utils.ElanUtils.isVxlanNetworkOrVxlanSegment) Collections(java.util.Collections) L2GatewayCache(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayCache) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Optional(com.google.common.base.Optional) 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) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ArrayList(java.util.ArrayList) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LocalUcastMacListener(org.opendaylight.netvirt.elan.l2gw.listeners.LocalUcastMacListener)

Example 15 with LocalUcastMacs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs in project netvirt by opendaylight.

the class TestBuilders method buildLocalUcastMacs.

public static LocalUcastMacs buildLocalUcastMacs(InstanceIdentifier<Node> nodeIid, String vmMac, String vmip, String tepIp, String logicalSwitchName) {
    LocalUcastMacsBuilder ucmlBuilder = new LocalUcastMacsBuilder();
    ucmlBuilder.setIpaddr(new IpAddress(vmip.toCharArray()));
    ucmlBuilder.setMacEntryKey(new MacAddress(vmMac));
    ucmlBuilder.setMacEntryUuid(getUUid(vmMac));
    ucmlBuilder.setLocatorRef(buildLocatorRef(nodeIid, tepIp));
    ucmlBuilder.setLogicalSwitchRef(buildLogicalSwitchesRef(nodeIid, logicalSwitchName));
    return ucmlBuilder.build();
}
Also used : LocalUcastMacsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacsBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Aggregations

L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)12 LocalUcastMacs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs)8 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)8 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)7 HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)7 ArrayList (java.util.ArrayList)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)5 Collections (java.util.Collections)4 Set (java.util.Set)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)4 HwvtepSouthboundUtils (org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils)4 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)4 ElanInstanceCache (org.opendaylight.netvirt.elan.cache.ElanInstanceCache)4 ElanL2GwCacheUtils (org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils)4 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)4