Search in sources :

Example 61 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 OpenFlow13Provider method createIngressClassifierFilterEthNshFlow.

/*
     * Ingress Classifier Filter Eth NSH flow:
     *     Only allows Non-NSH packets to proceed in the classifier
     *     Match on ethertype and null tunnel IP and resubmit to
     *     Ingress Dispatcher on match
     */
public Flow createIngressClassifierFilterEthNshFlow(NodeId nodeId) {
    MatchBuilder match = new MatchBuilder();
    OpenFlow13Utils.addMatchEthNsh(match);
    OpenFlow13Utils.addMatchTunDstIp(match, NULL_IP);
    List<Action> actionList = new ArrayList<>();
    actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.LPORT_DISPATCHER_TABLE, actionList.size()));
    InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
    String flowIdStr = INGRESS_CLASSIFIER_FILTER_ETHNSH_FLOW_NAME + nodeId.getValue();
    return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE, INGRESS_CLASSIFIER_FILTER_ETH_NSH_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE, INGRESS_CLASSIFIER_FILTER_ETHNSH_FLOW_NAME, flowIdStr, match, isb).build();
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ArrayList(java.util.ArrayList) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)

Example 62 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 ConfigurationClassifierImpl method buildEntries.

private Set<ClassifierRenderableEntry> buildEntries(String ruleName, @NonNull List<String> interfaces, @NonNull Matches matches, @NonNull RenderedServicePath rsp) {
    String rspName = rsp.getName().getValue();
    Long nsp = rsp.getPathId();
    Short nsi = rsp.getStartingIndex();
    Short nsl = rsp.getRenderedServicePathHop() == null ? null : (short) rsp.getRenderedServicePathHop().size();
    if (nsp == null || nsi == null || nsl == null) {
        LOG.warn("Ace {} RSP {} ignored: no valid NSI or NSP or length", ruleName, rspName);
        return Collections.emptySet();
    }
    DpnIdType firstHopDpn = sfcProvider.getFirstHopIngressInterfaceFromRsp(rsp).flatMap(geniusProvider::getDpnIdFromInterfaceName).orElse(null);
    if (firstHopDpn == null) {
        LOG.warn("Ace {} RSP {} ignored: no valid first hop DPN", ruleName, rspName);
        return Collections.emptySet();
    }
    String lastHopInterface = sfcProvider.getLastHopEgressInterfaceFromRsp(rsp).orElse(null);
    if (lastHopInterface == null) {
        LOG.warn("Ace {} RSP {} ignored: has no valid last hop interface", ruleName, rspName);
        return Collections.emptySet();
    }
    DpnIdType lastHopDpn = geniusProvider.getDpnIdFromInterfaceName(lastHopInterface).orElse(null);
    if (lastHopDpn == null) {
        LOG.warn("Ace {} RSP {} ignored: has no valid last hop DPN", ruleName, rspName);
        return Collections.emptySet();
    }
    Map<NodeId, List<InterfaceKey>> nodeToInterfaces = new HashMap<>();
    for (String iface : interfaces) {
        geniusProvider.getNodeIdFromLogicalInterface(iface).ifPresent(nodeId -> nodeToInterfaces.computeIfAbsent(nodeId, key -> new ArrayList<>()).add(new InterfaceKey(iface)));
    }
    LOG.trace("Ace {} RSP {}: got classifier nodes and interfaces: {}", ruleName, rspName, nodeToInterfaces);
    String firstHopIp = geniusProvider.getIpFromDpnId(firstHopDpn).orElse(null);
    Set<ClassifierRenderableEntry> entries = new HashSet<>();
    nodeToInterfaces.forEach((nodeId, ifaces) -> {
        // Get node info
        DpnIdType nodeDpn = new DpnIdType(OpenFlow13Provider.getDpnIdFromNodeId(nodeId));
        String nodeIp = geniusProvider.getIpFromDpnId(nodeDpn).orElse(LOCAL_HOST_IP);
        if (firstHopIp == null && !nodeDpn.equals(firstHopDpn)) {
            LOG.warn("Ace {} RSP {} classifier {} ignored: no IP to reach first hop DPN {}", ruleName, rspName, nodeId, firstHopDpn);
            return;
        }
        // Add entries that are not based on ingress or egress interface
        entries.add(ClassifierEntry.buildNodeEntry(nodeId));
        entries.add(ClassifierEntry.buildPathEntry(nodeId, nsp, nsi, nsl, nodeDpn.equals(firstHopDpn) ? null : firstHopIp));
        // Add entries based on ingress interface
        ifaces.forEach(interfaceKey -> {
            entries.add(ClassifierEntry.buildIngressEntry(interfaceKey));
            entries.add(ClassifierEntry.buildMatchEntry(nodeId, geniusProvider.getNodeConnectorIdFromInterfaceName(interfaceKey.getName()).get(), matches, nsp, nsi));
        });
        // hand-off can happen through the dispatcher table
        if (nodeDpn.equals(lastHopDpn)) {
            entries.add(ClassifierEntry.buildIngressEntry(new InterfaceKey(lastHopInterface)));
        }
        // Egress services must bind to egress ports. Since we dont know before-hand what
        // the egress ports will be, we will bind on all switch ports. If the packet
        // doesnt have NSH, it will be returned to the the egress dispatcher table.
        List<Interfaces> interfaceUuidStrList = geniusProvider.getInterfacesFromNode(nodeId);
        interfaceUuidStrList.forEach(interfaceUuidStr -> {
            InterfaceKey interfaceKey = new InterfaceKey(interfaceUuidStr.getInterfaceName());
            Optional<String> remoteIp = geniusProvider.getRemoteIpAddress(interfaceUuidStr.getInterfaceName());
            entries.add(ClassifierEntry.buildEgressEntry(interfaceKey, remoteIp.orElse(nodeIp)));
        });
    });
    return entries;
}
Also used : HashMap(java.util.HashMap) DpnIdType(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ClassifierRenderableEntry(org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierRenderableEntry) ArrayList(java.util.ArrayList) List(java.util.List) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) HashSet(java.util.HashSet)

Example 63 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 OpenflowRenderer method renderPath.

@Override
// FindBugs reports "Useless object stored in variable flows" however it doesn't recognize the usage of forEach.
@SuppressFBWarnings("UC_USELESS_OBJECT")
public void renderPath(NodeId nodeId, Long nsp, short nsi, short nsl, String firstHopIp) {
    List<Flow> flows = new ArrayList<>();
    if (firstHopIp != null) {
        Long port = geniusProvider.getEgressVxlanPortForNode(OpenFlow13Provider.getDpnIdFromNodeId(nodeId)).orElse(null);
        if (port == null) {
            LOG.error("OpenflowRenderer: cant get egressPort for nodeId [{}]", nodeId.getValue());
            return;
        }
        Flow flow;
        flow = openFlow13Provider.createEgressClassifierTransportEgressRemoteFlow(nodeId, nsp, port, firstHopIp);
        flows.add(flow);
    } else {
        Flow flow;
        flow = openFlow13Provider.createEgressClassifierTransportEgressLocalFlow(nodeId, nsp);
        flows.add(flow);
    }
    short egressNsi = (short) (nsi - nsl);
    flows.add(openFlow13Provider.createIngressClassifierFilterChainEgressFlow(nodeId, nsp, egressNsi));
    ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> flows.forEach(flow -> this.openFlow13Provider.appendFlowForCreate(nodeId, flow, tx))), LOG, "Error rendering a path");
}
Also used : Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LoggerFactory(org.slf4j.LoggerFactory) ClassifierEntryRenderer(org.opendaylight.netvirt.sfc.classifier.service.domain.api.ClassifierEntryRenderer) Matches(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) OpenFlow13Provider(org.opendaylight.netvirt.sfc.classifier.providers.OpenFlow13Provider) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ArrayList(java.util.ArrayList) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) List(java.util.List) GeniusProvider(org.opendaylight.netvirt.sfc.classifier.providers.GeniusProvider) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ArrayList(java.util.ArrayList) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 64 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 L2GatewayListener method update.

@Override
protected void update(InstanceIdentifier<L2gateway> identifier, L2gateway original, L2gateway update) {
    LOG.trace("Updating L2gateway : key: {}, original value={}, update value={}", identifier, original, update);
    List<L2gatewayConnection> connections = l2gwService.getAssociatedL2GwConnections(Sets.newHashSet(update.getUuid()));
    if (connections == null) {
        LOG.warn("There are no connections associated with l2 gateway uuid {} name {}", update.getUuid(), update.getName());
        return;
    }
    if (original.getDevices() == null) {
        connections.forEach((connection) -> l2gwService.addL2GatewayConnection(connection));
        return;
    }
    jobCoordinator.enqueueJob("l2gw.update", () -> {
        ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
        DeviceInterfaces updatedDeviceInterfaces = new DeviceInterfaces(update);
        List<ListenableFuture<Void>> fts = new ArrayList<>();
        original.getDevices().stream().filter((originalDevice) -> originalDevice.getInterfaces() != null).forEach((originalDevice) -> {
            String deviceName = originalDevice.getDeviceName();
            L2GatewayDevice l2GwDevice = l2GatewayCache.get(deviceName);
            NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(new NodeId(l2GwDevice.getHwvtepNodeId()), deviceName);
            originalDevice.getInterfaces().stream().filter((intf) -> !updatedDeviceInterfaces.containsInterface(deviceName, intf.getInterfaceName())).forEach((intf) -> {
                connections.forEach((connection) -> {
                    Integer vlanId = connection.getSegmentId();
                    if (intf.getSegmentationIds() != null && !intf.getSegmentationIds().isEmpty()) {
                        for (Integer vlan : intf.getSegmentationIds()) {
                            HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId, intf.getInterfaceName(), vlan);
                        }
                    } else {
                        LOG.debug("Deleting vlan binding {} {} {}", physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
                        HwvtepUtils.deleteVlanBinding(transaction, physicalSwitchNodeId, intf.getInterfaceName(), vlanId);
                    }
                });
            });
        });
        fts.add(transaction.submit());
        Futures.addCallback(fts.get(0), new FutureCallback<Void>() {

            @Override
            public void onSuccess(Void success) {
                LOG.debug("Successfully deleted vlan bindings for l2gw update {}", update);
                connections.forEach((l2GwConnection) -> l2gwService.addL2GatewayConnection(l2GwConnection, null, update));
            }

            @Override
            public void onFailure(Throwable throwable) {
                LOG.error("Failed to delete vlan bindings as part of l2gw udpate {}", update);
            }
        }, MoreExecutors.directExecutor());
        return fts;
    }, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
Also used : HwvtepSouthboundConstants(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) IL2gwService(org.opendaylight.netvirt.elanmanager.api.IL2gwService) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) L2gateways(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.L2gateways) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) EntityOwnershipService(org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) HwvtepUtils(org.opendaylight.genius.utils.hwvtep.HwvtepUtils) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) AsyncClusteredDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) Map(java.util.Map) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) HwvtepSouthboundUtils(org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) Logger(org.slf4j.Logger) EntityOwnershipUtils(org.opendaylight.genius.utils.clustering.EntityOwnershipUtils) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Set(java.util.Set) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) SystemPropertyReader(org.opendaylight.genius.utils.SystemPropertyReader) Sets(com.google.common.collect.Sets) FutureCallback(com.google.common.util.concurrent.FutureCallback) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2gatewayConnections(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections) L2GatewayCache(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayCache) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) ItmRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService) ArrayList(java.util.ArrayList) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 65 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 L2GatewayUtils method createItmTunnels.

protected static void createItmTunnels(ItmRpcService itmRpcService, String hwvtepId, String psName, IpAddress tunnelIp) {
    AddL2GwDeviceInputBuilder builder = new AddL2GwDeviceInputBuilder();
    builder.setTopologyId(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue());
    builder.setNodeId(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepId), psName).getValue());
    builder.setIpAddress(tunnelIp);
    try {
        Future<RpcResult<Void>> result = itmRpcService.addL2GwDevice(builder.build());
        RpcResult<Void> rpcResult = result.get();
        if (rpcResult.isSuccessful()) {
            LOG.info("Created ITM tunnels for {}", hwvtepId);
        } else {
            LOG.error("Failed to create ITM Tunnels: {}", rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("RPC to create ITM tunnels failed", e);
    }
}
Also used : AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException)

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