Search in sources :

Example 1 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 L2GwValidateCli method verifyL2GatewayConnections.

private void verifyL2GatewayConnections() {
    boolean isValid = true;
    for (L2gatewayConnection l2gatewayConnection : l2gatewayConnections) {
        L2gateway l2gateway = uuidToL2Gateway.get(l2gatewayConnection.getL2gatewayId());
        String logicalSwitchName = l2gatewayConnection.getNetworkId().getValue();
        List<Devices> devices = l2gateway.getDevices();
        for (Devices device : devices) {
            L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(device.getDeviceName());
            isValid = verifyL2GatewayDevice(l2gateway, device, l2GatewayDevice);
            if (!isValid) {
                continue;
            }
            NodeId nodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
            InstanceIdentifier<Node> nodeIid = topoIid.child(Node.class, new NodeKey(nodeId));
            isValid = verfiyLogicalSwitch(logicalSwitchName, nodeIid);
            if (isValid) {
                isValid = verifyMcastMac(logicalSwitchName, nodeIid);
                verifyVlanBindings(nodeIid, logicalSwitchName, device, l2gatewayConnection.getSegmentId());
                L2GatewayDevice elanL2gatewayDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(logicalSwitchName, nodeId.getValue());
                if (elanL2gatewayDevice == null) {
                    pw.println("Failed elan l2gateway device not found for network " + logicalSwitchName + " and device " + device.getDeviceName() + " " + l2GatewayDevice.getHwvtepNodeId() + " l2gw connection id " + l2gatewayConnection.getUuid());
                }
            }
        }
    }
}
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) 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) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 2 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 L2GwValidateCli method readNodes.

private void readNodes() throws ReadFailedException {
    try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
        InstanceIdentifier<Topology> topoId = HwvtepSouthboundUtils.createHwvtepTopologyInstanceIdentifier();
        Optional<Topology> operationalTopoOptional = tx.read(LogicalDatastoreType.OPERATIONAL, topoId).checkedGet();
        Optional<Topology> configTopoOptional = tx.read(LogicalDatastoreType.CONFIGURATION, topoId).checkedGet();
        if (operationalTopoOptional.isPresent()) {
            for (Node node : operationalTopoOptional.get().getNode()) {
                InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
                operationalNodes.put(nodeIid, node);
            }
        }
        if (configTopoOptional.isPresent()) {
            for (Node node : configTopoOptional.get().getNode()) {
                InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
                configNodes.put(nodeIid, node);
            }
        }
        fillNodesData(operationalNodes, operationalNodesData);
        fillNodesData(configNodes, configNodesData);
        Optional<ElanInstances> elanInstancesOptional = tx.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(ElanInstances.class).build()).checkedGet();
        if (elanInstancesOptional.isPresent() && elanInstancesOptional.get().getElanInstance() != null) {
            for (ElanInstance elanInstance : elanInstancesOptional.get().getElanInstance()) {
                elanInstanceMap.put(elanInstance.getElanInstanceName(), elanInstance);
            }
        }
        l2gatewayConnections = L2GatewayConnectionUtils.getAllL2gatewayConnections(dataBroker);
        l2gateways = L2GatewayConnectionUtils.getL2gatewayList(dataBroker);
        for (L2gateway l2gateway : l2gateways) {
            uuidToL2Gateway.put(l2gateway.getUuid(), l2gateway);
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances)

Example 3 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 HwvtepTerminationPointListener method handlePortAdded.

private List<ListenableFuture<Void>> handlePortAdded(TerminationPoint portAdded, NodeId psNodeId) {
    Node psNode = HwvtepUtils.getHwVtepNode(broker, LogicalDatastoreType.OPERATIONAL, psNodeId);
    if (psNode != null) {
        String psName = psNode.getAugmentation(PhysicalSwitchAugmentation.class).getHwvtepNodeName().getValue();
        L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
        if (l2GwDevice != null) {
            if (isL2GatewayConfigured(l2GwDevice)) {
                List<L2gatewayConnection> l2GwConns = L2GatewayConnectionUtils.getAssociatedL2GwConnections(broker, l2GwDevice.getL2GatewayIds());
                String newPortId = portAdded.getTpId().getValue();
                NodeId hwvtepNodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
                List<VlanBindings> vlanBindings = getVlanBindings(l2GwConns, hwvtepNodeId, psName, newPortId);
                return Collections.singletonList(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(hwvtepNodeId, psName, newPortId, vlanBindings));
            }
        } else {
            LOG.error("{} details are not present in L2Gateway Cache", psName);
        }
    } else {
        LOG.error("{} entry not in config datastore", psNodeId);
    }
    return Collections.emptyList();
}
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) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 4 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 HwvtepTerminationPointListener method getVlanBindings.

private List<VlanBindings> getVlanBindings(List<L2gatewayConnection> l2GwConns, NodeId hwvtepNodeId, String psName, String newPortId) {
    List<VlanBindings> vlanBindings = new ArrayList<>();
    for (L2gatewayConnection l2GwConn : l2GwConns) {
        L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GwConn.getL2gatewayId());
        if (l2Gateway == null) {
            LOG.error("L2Gateway with id {} is not present", l2GwConn.getL2gatewayId().getValue());
        } else {
            String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(l2GwConn.getNetworkId().getValue());
            List<Devices> l2Devices = l2Gateway.getDevices();
            for (Devices l2Device : l2Devices) {
                String l2DeviceName = l2Device.getDeviceName();
                if (l2DeviceName != null && l2DeviceName.equals(psName)) {
                    for (Interfaces deviceInterface : l2Device.getInterfaces()) {
                        if (deviceInterface.getInterfaceName().equals(newPortId)) {
                            if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
                                for (Integer vlanId : deviceInterface.getSegmentationIds()) {
                                    vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, vlanId, logicalSwitchName));
                                }
                            } else {
                                // Use defaultVlanId (specified in L2GatewayConnection) if Vlan
                                // ID not specified at interface level.
                                Integer segmentationId = l2GwConn.getSegmentId();
                                int defaultVlanId = segmentationId != null ? segmentationId : 0;
                                vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, defaultVlanId, logicalSwitchName));
                            }
                        }
                    }
                }
            }
        }
    }
    return vlanBindings;
}
Also used : Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces) ArrayList(java.util.ArrayList) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) 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) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 5 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 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)

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