Search in sources :

Example 1 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.

the class ElanInterfaceManager method installDpnMacsInL2gwDevice.

/**
 * Installs dpn macs in external device. first it checks if the physical
 * locator towards this dpn tep is present or not if the physical locator is
 * present go ahead and add the ucast macs otherwise update the mcast mac
 * entry to include this dpn tep ip and schedule the job to put ucast macs
 * once the physical locator is programmed in device
 *
 * @param elanName
 *            the elan name
 * @param lstElanInterfaceNames
 *            the lst Elan interface names
 * @param dpnId
 *            the dpn id
 * @param externalNodeId
 *            the external node id
 */
private void installDpnMacsInL2gwDevice(String elanName, Set<String> lstElanInterfaceNames, BigInteger dpnId, NodeId externalNodeId) {
    L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, externalNodeId.getValue());
    if (elanL2GwDevice == null) {
        LOG.debug("L2 gw device not found in elan cache for device name {}", externalNodeId);
        return;
    }
    IpAddress dpnTepIp = elanItmUtils.getSourceDpnTepIp(dpnId, externalNodeId);
    if (dpnTepIp == null) {
        LOG.warn("Could not install dpn macs in l2gw device , dpnTepIp not found dpn : {} , nodeid : {}", dpnId, externalNodeId);
        return;
    }
    String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
    RemoteMcastMacs remoteMcastMac = elanL2GatewayUtils.readRemoteMcastMac(externalNodeId, logicalSwitchName, LogicalDatastoreType.OPERATIONAL);
    boolean phyLocAlreadyExists = ElanL2GatewayUtils.checkIfPhyLocatorAlreadyExistsInRemoteMcastEntry(externalNodeId, remoteMcastMac, dpnTepIp);
    LOG.debug("phyLocAlreadyExists = {} for locator [{}] in remote mcast entry for elan [{}], nodeId [{}]", phyLocAlreadyExists, String.valueOf(dpnTepIp.getValue()), elanName, externalNodeId.getValue());
    List<PhysAddress> staticMacs = elanL2GatewayUtils.getElanDpnMacsFromInterfaces(lstElanInterfaceNames);
    if (phyLocAlreadyExists) {
        elanL2GatewayUtils.scheduleAddDpnMacsInExtDevice(elanName, dpnId, staticMacs, elanL2GwDevice);
        return;
    }
    elanL2GatewayMulticastUtils.scheduleMcastMacUpdateJob(elanName, elanL2GwDevice);
    elanL2GatewayUtils.scheduleAddDpnMacsInExtDevice(elanName, dpnId, staticMacs, elanL2GwDevice);
}
Also used : RemoteMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs) 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) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 2 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.

the class L2GatewayConnectionListener method loadL2GwDeviceCache.

private void loadL2GwDeviceCache(List<Node> nodes) {
    if (nodes == null) {
        LOG.debug("No config topology nodes are present");
        return;
    }
    Map<InstanceIdentifier<Node>, Node> allNodes = nodes.stream().collect(toMap(TO_NODE_PATH, Function.identity()));
    LOG.trace("Loading all config nodes");
    Set<InstanceIdentifier<Node>> allIids = allNodes.keySet();
    Map<String, List<InstanceIdentifier<Node>>> psNodesByDeviceName = allIids.stream().filter(IS_PS_NODE).collect(groupingBy(GET_DEVICE_NAME, toList()));
    // Process HA nodes
    allNodes.values().stream().filter(IS_HA_PARENT_NODE).forEach(parentNode -> {
        allIids.stream().filter(IS_PS_NODE).filter(psIid -> PS_NODE_OF_PARENT_NODE.test(psIid, parentNode)).forEach(psIid -> {
            addL2DeviceToCache(psIid, parentNode, allNodes.get(psIid));
        });
    });
    // Process non HA nodes there will be only one ps node iid for each device for non ha nodes
    psNodesByDeviceName.values().stream().filter(psIids -> psIids.size() == 1).map(psIids -> psIids.get(0)).forEach(psIid -> {
        Node psNode = allNodes.get(psIid);
        Node globalNode = allNodes.get(TO_GLOBAL_PATH.apply(psNode));
        if (globalNode != null) {
            addL2DeviceToCache(psIid, globalNode, psNode);
        }
    });
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) LoggerFactory(org.slf4j.LoggerFactory) CONFIGURATION(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION) Singleton(javax.inject.Singleton) Function(java.util.function.Function) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) Inject(javax.inject.Inject) AsyncClusteredDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase) BiPredicate(java.util.function.BiPredicate) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) HwvtepHAUtil(org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil) Collectors.toMap(java.util.stream.Collectors.toMap) Optional(com.google.common.base.Optional) Map(java.util.Map) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) HwvtepSouthboundUtils(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils) Logger(org.slf4j.Logger) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Predicate(java.util.function.Predicate) Scheduler(org.opendaylight.netvirt.elan.utils.Scheduler) Set(java.util.Set) FutureCallback(com.google.common.util.concurrent.FutureCallback) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) TimeUnit(java.util.concurrent.TimeUnit) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Collectors.toList(java.util.stream.Collectors.toList) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) L2GatewayConnectionUtils(org.opendaylight.netvirt.elan.l2gw.utils.L2GatewayConnectionUtils) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2gatewayConnections(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections) TunnelIps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps) L2GatewayCache(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayCache) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List)

Example 3 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device 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 4 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device 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 5 with Device

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method preapareRemoteMcastMacEntry.

/**
 * Update remote mcast mac.
 *
 * @param elanName
 *            the elan name
 * @param device
 *            the device
 * @param dpnsTepIps
 *            the dpns tep ips
 * @param l2GwDevicesTepIps
 *            the l2 gw devices tep ips
 * @return the write transaction
 */
private void preapareRemoteMcastMacEntry(String elanName, L2GatewayDevice device, List<IpAddress> dpnsTepIps, List<IpAddress> l2GwDevicesTepIps) {
    NodeId nodeId = new NodeId(device.getHwvtepNodeId());
    ArrayList<IpAddress> remoteTepIps = new ArrayList<>(l2GwDevicesTepIps);
    remoteTepIps.remove(device.getTunnelIp());
    remoteTepIps.addAll(dpnsTepIps);
    IpAddress dhcpDesignatedSwitchTepIp = getTepIpOfDesignatedSwitchForExternalTunnel(device, elanName);
    if (dpnsTepIps.isEmpty()) {
        // physical locator in l2 gw device
        if (dhcpDesignatedSwitchTepIp != null) {
            remoteTepIps.add(dhcpDesignatedSwitchTepIp);
            HwvtepPhysicalLocatorAugmentation phyLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(dhcpDesignatedSwitchTepIp.getValue()));
            InstanceIdentifier<TerminationPoint> iid = HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId, phyLocatorAug);
            TerminationPoint terminationPoint = new TerminationPointBuilder().setKey(HwvtepSouthboundUtils.getTerminationPointKey(phyLocatorAug)).addAugmentation(HwvtepPhysicalLocatorAugmentation.class, phyLocatorAug).build();
            ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, iid, terminationPoint);
            LOG.info("Adding PhysicalLocator for node: {} with Dhcp designated switch Tep Ip {} " + "as physical locator, elan {}", device.getHwvtepNodeId(), String.valueOf(dhcpDesignatedSwitchTepIp.getValue()), elanName);
        } else {
            LOG.warn("Dhcp designated switch Tep Ip not found for l2 gw node {} and elan {}", device.getHwvtepNodeId(), elanName);
        }
    }
    if (dhcpDesignatedSwitchTepIp != null && !remoteTepIps.contains(dhcpDesignatedSwitchTepIp)) {
        remoteTepIps.add(dhcpDesignatedSwitchTepIp);
    }
    String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
    putRemoteMcastMac(nodeId, logicalSwitchName, remoteTepIps);
    LOG.info("Adding RemoteMcastMac for node: {} with physical locators: {}", device.getHwvtepNodeId(), remoteTepIps);
}
Also used : HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Aggregations

ArrayList (java.util.ArrayList)50 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)34 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)30 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)25 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)24 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)24 List (java.util.List)21 ExecutionException (java.util.concurrent.ExecutionException)18 Collection (java.util.Collection)16 Map (java.util.Map)16 Collections (java.util.Collections)15 HashMap (java.util.HashMap)15 Test (org.junit.Test)14 BigInteger (java.math.BigInteger)13 Set (java.util.Set)13 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)13 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12