Search in sources :

Example 96 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 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 FluentFuture<? extends CommitInfo> 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);
    FluentFuture<? extends CommitInfo> 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 97 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 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).orElse(null);
    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 98 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 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.key().getUuid())) {
            l2gwDevicesToBeDeleted.addAll(elanL2gwDevice.getDevicesForL2gwConnectionId(input.key().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 if (l2Gateway.nonnullDevices() != null) {
            l2gwDevicesToBeDeleted.addAll(l2Gateway.nonnullDevices().values());
        }
    }
    for (Devices l2Device : l2gwDevicesToBeDeleted) {
        String l2DeviceName = l2Device.getDeviceName();
        L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
        String hwvtepNodeId = l2GatewayDevice.getHwvtepNodeId();
        if (hwvtepNodeId == null) {
            LOG.error("Could not disassociate failed to get node id {}", l2DeviceName);
            continue;
        }
        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.key().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, elanL2GatewayBcGroupUtils, elanClusterUtils, scheduler, jobCoordinator, elanL2GwDevice, elanName, 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) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) 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)

Example 99 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 L2GatewayConnectionUtils method addL2GatewayConnection.

public void addL2GatewayConnection(final L2gatewayConnection input, @Nullable final String l2GwDeviceName, @Nullable L2gateway l2Gateway) {
    LOG.info("Adding L2gateway Connection:{} vlan: {} device name {}", input.key().getUuid(), input.getSegmentId(), l2GwDeviceName);
    Uuid networkUuid = input.getNetworkId();
    // Taking cluster reboot scenario , if Elan instance is not available when l2GatewayConnection add events
    // comes we need to wait for elaninstance to resolve. Hence updating the map with the runnable .
    // When elanInstance add comes , it look in to the map and run the associated runnable associated with it.
    ElanInstance elanInstance = elanInstanceCache.get(networkUuid.getValue(), () -> addL2GatewayConnection(input, l2GwDeviceName)).orElse(null);
    if (elanInstance == null) {
        return;
    }
    if (!isVxlanNetworkOrVxlanSegment(elanInstance)) {
        LOG.error("Neutron network with id {} is not VxlanNetwork", networkUuid.getValue());
    } else {
        Uuid l2GatewayId = input.getL2gatewayId();
        if (l2Gateway == null) {
            l2Gateway = getNeutronL2gateway(broker, l2GatewayId);
        }
        if (l2Gateway == null) {
            LOG.error("L2Gateway with id {} is not present", l2GatewayId);
        } else {
            associateHwvtepsToElan(elanInstance, l2Gateway, input, l2GwDeviceName);
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 100 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 ListenableFuture<Void> preapareRemoteMcastMacEntry(String elanName, L2GatewayDevice device, List<IpAddress> dpnsTepIps, List<IpAddress> l2GwDevicesTepIps, boolean addCase) {
    ArrayList<IpAddress> remoteTepIps = new ArrayList<>(l2GwDevicesTepIps);
    remoteTepIps.remove(device.getTunnelIp());
    remoteTepIps.addAll(dpnsTepIps);
    IpAddress dhcpDesignatedSwitchTepIp = getTepIpOfDesignatedSwitchForExternalTunnel(device, elanName);
    if (dhcpDesignatedSwitchTepIp != null && !remoteTepIps.contains(dhcpDesignatedSwitchTepIp)) {
        remoteTepIps.add(dhcpDesignatedSwitchTepIp);
    }
    return putRemoteMcastMac(new NodeId(device.getHwvtepNodeId()), elanName, remoteTepIps, addCase);
}
Also used : ArrayList(java.util.ArrayList) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

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