Search in sources :

Example 6 with NodeId

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId in project netvirt by opendaylight.

the class NetworkL2gwDeviceInfoCli method process.

@SuppressWarnings("checkstyle:HiddenField")
void process(NodeId hwvtepNodeId, String elanName) {
    Node hwvtepConfigNode = configNodes.get(hwvtepNodeId);
    session.getConsole().println("Config Data >>");
    printLocalUcastMacs(hwvtepConfigNode, elanName);
    session.getConsole().println("Operational Data >>");
    Node hwvtepOpNode = opNodes.get(hwvtepNodeId);
    printLocalUcastMacs(hwvtepOpNode, elanName);
    session.getConsole().println("Config Data >>");
    printLocalMcastMacs(hwvtepConfigNode, elanName);
    session.getConsole().println("Operational Data >>");
    printLocalMcastMacs(hwvtepOpNode, elanName);
    session.getConsole().println("Config Data >>");
    printRemoteUcastMacs(hwvtepConfigNode, elanName);
    session.getConsole().println("Operational Data >>");
    printRemoteUcastMacs(hwvtepOpNode, elanName);
    session.getConsole().println("Config Data >>");
    printRemoteMcastMacs(hwvtepConfigNode, elanName);
    session.getConsole().println("Operational Data >>");
    printRemoteMcastMacs(hwvtepOpNode, elanName);
    Node hwvtepConfigPsNode = configPSNodes.get(hwvtepNodeId);
    session.getConsole().println("Config Data >>");
    printVlanBindings(hwvtepConfigPsNode, elanName);
    session.getConsole().println("Operational Data >>");
    Node hwvtepOpPsNode = opPSNodes.get(hwvtepNodeId);
    printVlanBindings(hwvtepOpPsNode, elanName);
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)

Example 7 with NodeId

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method updated.

/**
 * Upon update checks if the tunnels Ip was null earlier and it got newly added.
 * In that case simply call add.
 * If not then check if Tunnel Ip has been updated from an old value to new value.
 * If yes. delete old ITM tunnels of odl Tunnel Ipand add new ITM tunnels with new Tunnel
 * IP then call added ().
 *
 * @param identifier iid
 * @param phySwitchBefore ps Node before update
 * @param phySwitchAfter ps Node after update
 */
@Override
protected void updated(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchBefore, PhysicalSwitchAugmentation phySwitchAfter) {
    NodeId nodeId = getNodeId(identifier);
    LOG.trace("Received PhysicalSwitch Update Event for node {}: PhysicalSwitch Before: {}, " + "PhysicalSwitch After: {}", nodeId.getValue(), phySwitchBefore, phySwitchAfter);
    String psName = getPsName(identifier);
    if (psName == null) {
        LOG.error("Could not find the physical switch name for node {}", nodeId.getValue());
        return;
    }
    L2GatewayDevice existingDevice = l2GatewayCache.get(psName);
    LOG.info("Received physical switch {} update event for node {}", psName, nodeId.getValue());
    InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
    if (DEVICE_NOT_CACHED_OR_PARENT_CONNECTED.test(existingDevice, globalNodeIid)) {
        if (TUNNEL_IP_AVAILABLE.test(phySwitchAfter)) {
            added(identifier, phySwitchAfter);
        }
    } else {
        if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps()) && TUNNEL_IP_CHANGED.test(phySwitchAfter, existingDevice)) {
            final String hwvtepId = existingDevice.getHwvtepNodeId();
            elanClusterUtils.runOnlyInOwnerNode(existingDevice.getDeviceName(), "handling Physical Switch add create itm tunnels ", () -> {
                LOG.info("Deleting itm tunnels for device {}", existingDevice.getDeviceName());
                L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, existingDevice.getDeviceName(), existingDevice.getTunnelIp());
                // TODO remove these sleeps
                Thread.sleep(10000L);
                LOG.info("Creating itm tunnels for device {}", existingDevice.getDeviceName());
                ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepId, psName, phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
                return Collections.emptyList();
            });
            try {
                // TODO remove the sleep by using better itm api to detect finish of prev op
                Thread.sleep(20000L);
            } catch (InterruptedException e) {
                LOG.error("Interrupted ");
            }
            existingDevice.setTunnelIps(new HashSet<>());
            added(identifier, phySwitchAfter);
        }
    }
}
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) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 8 with NodeId

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId 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 9 with NodeId

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId 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 10 with NodeId

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId in project netvirt by opendaylight.

the class LocalUcastMacListener method added.

public void added(final InstanceIdentifier<LocalUcastMacs> identifier, final LocalUcastMacs macAdded) {
    ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, identifier, macAdded);
    String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
    String macAddress = macAdded.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
    String elanName = getElanName(macAdded);
    LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
    ElanInstance elan = elanInstanceCache.get(elanName).orNull();
    if (elan == null) {
        LOG.warn("Could not find ELAN for mac {} being added", macAddress);
        return;
    }
    jobCoordinator.enqueueJob(elanName + HwvtepHAUtil.L2GW_JOB_KEY, () -> {
        L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
        if (elanL2GwDevice == null) {
            LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
            return null;
        }
        elanL2GwDevice.addUcastLocalMac(macAdded);
        elanL2GatewayUtils.installL2GwUcastMacInElan(elan, elanL2GwDevice, macAddress.toLowerCase(), macAdded, null);
        return null;
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Aggregations

NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)105 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)95 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)73 ArrayList (java.util.ArrayList)68 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)68 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)65 Test (org.junit.Test)56 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)42 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)35 BigInteger (java.math.BigInteger)31 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)30 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)29 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)28 ExecutionException (java.util.concurrent.ExecutionException)25 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)25 NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)25 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)24 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)23 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)20 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)19