Search in sources :

Example 11 with L2gateway

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.

the class L2GatewayConnectionUtils method addL2GatewayConnection.

public void addL2GatewayConnection(final L2gatewayConnection input, final String l2GwDeviceName, L2gateway l2Gateway) {
    LOG.info("Adding L2gateway Connection with ID: {}", input.getKey().getUuid());
    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)).orNull();
    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.getValue());
        } 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 12 with L2gateway

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method removed.

@Override
protected void removed(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchDeleted) {
    NodeId nodeId = getNodeId(identifier);
    String psName = phySwitchDeleted.getHwvtepNodeName().getValue();
    LOG.info("Received physical switch {} removed event for node {}", psName, nodeId.getValue());
    L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
    if (l2GwDevice != null) {
        if (!L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
            l2GatewayCache.remove(psName);
            LOG.debug("{} details removed from L2Gateway Cache", psName);
            MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
        } else {
            LOG.debug("{} details are not removed from L2Gateway Cache as it has L2Gateway reference", psName);
        }
        l2GwDevice.setConnected(false);
    // ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(psName);
    } else {
        LOG.error("Unable to find L2 Gateway details for {}", psName);
    }
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 13 with L2gateway

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method handleAdd.

/**
 * Handle add.
 *
 * @param l2GwDevice
 *            the l2 gw device
 */
private void handleAdd(L2GatewayDevice l2GwDevice) {
    final String psName = l2GwDevice.getDeviceName();
    final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
    Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
    for (final IpAddress tunnelIpAddr : tunnelIps) {
        if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
            LOG.debug("L2Gateway {} associated for {} physical switch; creating ITM tunnels for {}", l2GwDevice.getL2GatewayIds(), psName, tunnelIpAddr);
            l2gwServiceProvider.provisionItmAndL2gwConnection(l2GwDevice, psName, hwvtepNodeId, tunnelIpAddr);
        } else {
            LOG.info("l2gw.provision.skip {}:{}", hwvtepNodeId, psName);
        }
    }
    elanClusterUtils.runOnlyInOwnerNode("Stale entry cleanup", () -> {
        InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepNodeId));
        InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
        staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
    });
}
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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 14 with L2gateway

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.

the class L2GatewayListener method removeL2Device.

private void removeL2Device(Devices l2Device, L2gateway input) {
    final String l2DeviceName = l2Device.getDeviceName();
    L2GatewayDevice l2GwDevice = l2GatewayCache.get(l2DeviceName);
    if (l2GwDevice != null) {
        // Also, do not delete device from cache if it's connected
        if (L2GatewayUtils.isLastL2GatewayBeingDeleted(l2GwDevice)) {
            if (l2GwDevice.isConnected()) {
                l2GwDevice.removeL2GatewayId(input.getUuid());
                // Delete ITM tunnels
                final String hwvtepId = l2GwDevice.getHwvtepNodeId();
                final Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
                jobCoordinator.enqueueJob(hwvtepId, () -> {
                    if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
                        LOG.info("Deleting ITM Tunnels for {} connected to cluster node owner", l2DeviceName);
                        for (IpAddress tunnelIp : tunnelIps) {
                            L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, l2DeviceName, tunnelIp);
                        }
                    } else {
                        LOG.info("ITM Tunnels are not deleted on the cluster node as this is not owner for {}", l2DeviceName);
                    }
                    return null;
                });
            } else {
                l2GatewayCache.remove(l2DeviceName);
                // Cleaning up the config DS
                NodeId nodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
                NodeId psNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, l2DeviceName);
                // FIXME: These should be removed
                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(psNodeId));
            }
        } else {
            l2GwDevice.removeL2GatewayId(input.getUuid());
            LOG.trace("ITM tunnels are not deleted for {} as this device has other L2gateway associations", l2DeviceName);
        }
    } else {
        LOG.error("Unable to find L2 Gateway details for {}", l2DeviceName);
    }
}
Also used : 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) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 15 with L2gateway

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.

the class L2GatewayListener method add.

@Override
protected void add(final InstanceIdentifier<L2gateway> identifier, final L2gateway input) {
    LOG.info("Adding L2gateway with ID: {}", input.getUuid());
    List<Devices> l2Devices = input.getDevices();
    for (Devices l2Device : l2Devices) {
        LOG.trace("Adding L2gateway device: {}", l2Device);
        addL2Device(l2Device, input);
    }
}
Also used : Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices)

Aggregations

L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)7 Devices (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices)7 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)7 L2gateway (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway)6 L2gatewayConnection (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)5 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)4 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)4 ArrayList (java.util.ArrayList)3 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)2 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Interfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces)2 L2gatewayConnections (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections)2 VlanBindings (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)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 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 HashMap (java.util.HashMap)1