Search in sources :

Example 6 with L2gatewayConnection

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

the class L2GatewayConnectionUtils method getL2GwConnectionsByElanName.

/**
 * Gets the associated l2 gw connections.
 *
 * @param broker
 *            the broker
 * @param elanName
 *            the elan Name
 * @return the associated l2 gw connection with elan
 */
@Nonnull
public static List<L2gatewayConnection> getL2GwConnectionsByElanName(DataBroker broker, String elanName) {
    List<L2gatewayConnection> allL2GwConns = getAllL2gatewayConnections(broker);
    List<L2gatewayConnection> elanL2GateWayConnections = new ArrayList<>();
    for (L2gatewayConnection l2GwConn : allL2GwConns) {
        if (l2GwConn.getNetworkId().getValue().equalsIgnoreCase(elanName)) {
            elanL2GateWayConnections.add(l2GwConn);
        }
    }
    return elanL2GateWayConnections;
}
Also used : ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection) Nonnull(javax.annotation.Nonnull)

Example 7 with L2gatewayConnection

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

the class L2GatewayConnectionUtils method getAssociatedL2GwConnections.

/**
 * Gets the associated l2 gw connections.
 *
 * @param broker
 *            the broker
 * @param l2GatewayIds
 *            the l2 gateway ids
 * @return the associated l2 gw connections
 */
@Nonnull
public static List<L2gatewayConnection> getAssociatedL2GwConnections(DataBroker broker, Set<Uuid> l2GatewayIds) {
    List<L2gatewayConnection> allL2GwConns = getAllL2gatewayConnections(broker);
    List<L2gatewayConnection> l2GwConnections = new ArrayList<>();
    for (Uuid l2GatewayId : l2GatewayIds) {
        for (L2gatewayConnection l2GwConn : allL2GwConns) {
            if (l2GwConn.getL2gatewayId().equals(l2GatewayId)) {
                l2GwConnections.add(l2GwConn);
            }
        }
    }
    return l2GwConnections;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection) Nonnull(javax.annotation.Nonnull)

Example 8 with L2gatewayConnection

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

the class L2GatewayConnectionUtils method associateHwvtepsToElan.

private void associateHwvtepsToElan(ElanInstance elanInstance, L2gateway l2Gateway, L2gatewayConnection input, String l2GwDeviceName) {
    String elanName = elanInstance.getElanInstanceName();
    Integer defaultVlan = input.getSegmentId();
    Uuid l2GwConnId = input.getKey().getUuid();
    List<Devices> l2Devices = l2Gateway.getDevices();
    LOG.trace("Associating ELAN {} with L2Gw Conn Id {} having below L2Gw devices {}", elanName, l2GwConnId, l2Devices);
    for (Devices l2Device : l2Devices) {
        String l2DeviceName = l2Device.getDeviceName();
        // preprovisioning/re-provisioning
        if (l2GwDeviceName != null && !l2GwDeviceName.equals(l2DeviceName)) {
            LOG.debug("Associating Hwvtep to ELAN is not been processed for {}; as only {} got connected now!", l2DeviceName, l2GwDeviceName);
            continue;
        }
        L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
        if (isL2GwDeviceConnected(l2GatewayDevice)) {
            NodeId hwvtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
            // Delete pending delete logical switch task if scheduled
            elanL2GatewayUtils.cancelDeleteLogicalSwitch(hwvtepNodeId, ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName));
            // Add L2 Gateway device to 'ElanL2GwDevice' cache
            boolean createLogicalSwitch;
            LogicalSwitches logicalSwitch = HwvtepUtils.getLogicalSwitch(broker, LogicalDatastoreType.CONFIGURATION, hwvtepNodeId, elanName);
            if (logicalSwitch == null) {
                HwvtepLogicalSwitchListener hwVTEPLogicalSwitchListener = new HwvtepLogicalSwitchListener(elanInstanceCache, elanL2GatewayUtils, elanClusterUtils, elanL2GatewayMulticastUtils, this, l2GatewayDevice, elanName, l2Device, defaultVlan, l2GwConnId);
                hwVTEPLogicalSwitchListener.registerListener(LogicalDatastoreType.OPERATIONAL, broker);
                closeables.add(hwVTEPLogicalSwitchListener);
                createLogicalSwitch = true;
            } else {
                addL2DeviceToElanL2GwCache(elanName, l2GatewayDevice, l2GwConnId, l2Device);
                createLogicalSwitch = false;
            }
            AssociateHwvtepToElanJob associateHwvtepToElanJob = new AssociateHwvtepToElanJob(broker, elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanInstanceCache, l2GatewayDevice, elanInstance, l2Device, defaultVlan, createLogicalSwitch);
            elanClusterUtils.runOnlyInOwnerNode(associateHwvtepToElanJob.getJobKey(), "create logical switch in hwvtep topo", associateHwvtepToElanJob);
        } else {
            LOG.info("L2GwConn create is not handled for device with id {} as it's not connected", l2DeviceName);
        }
    }
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) AssociateHwvtepToElanJob(org.opendaylight.netvirt.elan.l2gw.jobs.AssociateHwvtepToElanJob) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) HwvtepLogicalSwitchListener(org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLogicalSwitchListener) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 9 with L2gatewayConnection

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

the class L2GatewayConnectionUtils method deleteL2GatewayConnection.

public void deleteL2GatewayConnection(L2gatewayConnection input) {
    LOG.info("Deleting L2gateway Connection with ID: {}", input.getKey().getUuid());
    Uuid networkUuid = input.getNetworkId();
    String elanName = networkUuid.getValue();
    disAssociateHwvtepsFromElan(elanName, input);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 10 with L2gatewayConnection

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

the class L2gwServiceProvider method provisionItmAndL2gwConnection.

@Override
public void provisionItmAndL2gwConnection(L2GatewayDevice l2GwDevice, String psName, String hwvtepNodeId, IpAddress tunnelIpAddr) {
    elanClusterUtils.runOnlyInOwnerNode(hwvtepNodeId, "Handling Physical Switch add create itm tunnels ", () -> {
        ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepNodeId, psName, tunnelIpAddr);
        return Collections.emptyList();
    });
    List<L2gatewayConnection> l2GwConns = L2GatewayConnectionUtils.getAssociatedL2GwConnections(dataBroker, l2GwDevice.getL2GatewayIds());
    LOG.debug("L2GatewayConnections associated for {} physical switch", psName);
    for (L2gatewayConnection l2GwConn : l2GwConns) {
        LOG.trace("L2GatewayConnection {} changes executed on physical switch {}", l2GwConn.getL2gatewayId(), psName);
        l2GatewayConnectionUtils.addL2GatewayConnection(l2GwConn, psName);
    }
}
Also used : L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Aggregations

L2gatewayConnection (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)10 ArrayList (java.util.ArrayList)7 Devices (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices)6 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)5 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)5 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 L2gateway (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway)4 L2gatewayConnections (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections)3 VlanBindings (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)3 BigInteger (java.math.BigInteger)2 Nonnull (javax.annotation.Nonnull)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)2 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)2 Interfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces)2 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 Sets (com.google.common.collect.Sets)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1