Search in sources :

Example 6 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class FlowConvertor method toInstructions.

private List<Instruction> toInstructions(Flow flow, short version, BigInteger datapathid) {
    final List<Instruction> instructionsList = new ArrayList<>();
    final ActionConvertorData data = new ActionConvertorData(version);
    data.setDatapathId(datapathid);
    data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
    Instructions instructions = flow.getInstructions();
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : instructions.getInstruction()) {
        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction();
        Optional<Instruction> result = PROCESSOR.process(curInstruction, data, getConvertorExecutor());
        if (result.isPresent()) {
            instructionsList.add(result.get());
        }
    }
    return instructionsList;
}
Also used : ArrayList(java.util.ArrayList) ActionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData) Instructions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction)

Example 7 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class PacketReceivedTranslator method getPacketInMatch.

@VisibleForTesting
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(input.getVersion());
    datapathIdConvertorData.setDatapathId(datapathId);
    final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder> matchOptional = convertorExecutor.convert(input.getMatch(), datapathIdConvertorData);
    final MatchBuilder matchBuilder = matchOptional.map(matchBuilder1 -> new MatchBuilder(matchBuilder1.build())).orElseGet(MatchBuilder::new);
    final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()), MatchPath.PACKET_RECEIVED_MATCH);
    if (matchExtensionWrap != null) {
        matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
    }
    return matchBuilder.build();
}
Also used : PacketInUtil(org.opendaylight.openflowplugin.impl.util.PacketInUtil) ConvertorExecutor(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor) MatchPath(org.opendaylight.openflowplugin.extension.api.path.MatchPath) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MatchExtensionHelper(org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) AugmentTuple(org.opendaylight.openflowplugin.extension.api.AugmentTuple) Optional(java.util.Optional) BigInteger(java.math.BigInteger) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) NodeConnectorRefToPortTranslator(org.opendaylight.openflowplugin.impl.util.NodeConnectorRefToPortTranslator) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 8 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method _testAllFlows.

/*
     * usage testAllFlows <dp>
     * ex: _perfFlowTest 1
     */
@SuppressWarnings("checkstyle:IllegalCatch")
public void _testAllFlows(final CommandInterpreter ci) {
    String dataPathID = ci.nextArgument();
    final int numberOfFlows = 82;
    if (dataPathID == null || dataPathID.trim().equals("")) {
        dataPathID = "1";
    }
    ci.println("*     Test All Flows    *");
    ci.println("*     dataPathID:::" + dataPathID + "");
    final String dataPath = "openflow:" + dataPathID;
    final String tableId = "0";
    final NodeBuilder tn = createTestNode(dataPath);
    FlowBuilder tf;
    for (int flow = 1; flow < numberOfFlows; flow++) {
        final String flowID = "f" + flow;
        try {
            tf = createTestFlow(tn, flowID, tableId);
            writeFlow(ci, tf, tn);
        } catch (RuntimeException e) {
            ci.println("--Test Failed--Issue found while adding flow" + flow);
            break;
        }
    }
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)

Example 9 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class PacketOutConvertor method convert.

@Override
public PacketOutInput convert(TransmitPacketInput source, PacketOutConvertorData data) {
    LOG.trace("toPacketOutInput for datapathId:{}, xid:{}", data.getDatapathId(), data.getXid());
    // Build Port ID from TransmitPacketInput.Ingress
    PortNumber inPortNr;
    Long bufferId = OFConstants.OFP_NO_BUFFER;
    Iterable<PathArgument> inArgs = null;
    if (source.getIngress() != null) {
        inArgs = source.getIngress().getValue().getPathArguments();
    }
    if (inArgs != null && Iterables.size(inArgs) >= 3) {
        inPortNr = getPortNumber(Iterables.get(inArgs, 2), data.getVersion());
    } else {
        // The packetOut originated from the controller
        inPortNr = new PortNumber(0xfffffffdL);
    }
    // Build Buffer ID to be NO_OFP_NO_BUFFER
    if (source.getBufferId() != null) {
        bufferId = source.getBufferId();
    }
    PortNumber outPort = null;
    NodeConnectorRef outRef = source.getEgress();
    Iterable<PathArgument> outArgs = outRef.getValue().getPathArguments();
    if (Iterables.size(outArgs) >= 3) {
        outPort = getPortNumber(Iterables.get(outArgs, 2), data.getVersion());
    } else {
        // TODO : P4 search for some normal exception
        // new Exception("PORT NR not exist in Egress");
        LOG.error("PORT NR not exist in Egress");
    }
    List<Action> actions = new ArrayList<>();
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> inputActions = source.getAction();
    if (inputActions != null) {
        final ActionConvertorData actionConvertorData = new ActionConvertorData(data.getVersion());
        actionConvertorData.setDatapathId(data.getDatapathId());
        final Optional<List<Action>> convertedActions = getConvertorExecutor().convert(inputActions, actionConvertorData);
        actions = convertedActions.orElse(Collections.emptyList());
    } else {
        // TODO VD P! wait for way to move Actions (e.g. augmentation)
        OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
        OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
        outputActionBuilder.setPort(outPort);
        outputActionBuilder.setMaxLength(OFConstants.OFPCML_NO_BUFFER);
        outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
        ActionBuilder actionBuild = new ActionBuilder();
        actionBuild.setActionChoice(outputActionCaseBuilder.build());
        actions.add(actionBuild.build());
    }
    PacketOutInputBuilder builder = new PacketOutInputBuilder();
    builder.setAction(actions);
    builder.setData(source.getPayload());
    builder.setVersion(data.getVersion());
    builder.setXid(data.getXid());
    builder.setInPort(inPortNr);
    builder.setBufferId(bufferId);
    return builder.build();
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ArrayList(java.util.ArrayList) ActionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData) PacketOutInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ArrayList(java.util.ArrayList) List(java.util.List) PathArgument(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Example 10 with DatapathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId in project openflowplugin by opendaylight.

the class PortTranslatorUtilTest method testTranslatePort.

/**
 * Test  method for
 * {@link PortTranslatorUtil#translatePort(Short, java.math.BigInteger,
 * Long, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping)} ()}.
 */
@Test
public void testTranslatePort() {
    Short version = OpenflowVersion.OF10.getVersion();
    BigInteger dataPathId = BigInteger.ONE;
    Long portNumber = Long.MAX_VALUE;
    PortGrouping portGrouping = mockPortGrouping();
    NodeConnectorUpdated nodeConnectorUpdated = PortTranslatorUtil.translatePort(version, dataPathId, portNumber, portGrouping);
    assertNotNull(nodeConnectorUpdated);
    version = OpenflowVersion.OF13.getVersion();
    nodeConnectorUpdated = PortTranslatorUtil.translatePort(version, dataPathId, portNumber, portGrouping);
    assertNotNull(nodeConnectorUpdated);
    version = OpenflowVersion.UNSUPPORTED.getVersion();
    nodeConnectorUpdated = PortTranslatorUtil.translatePort(version, dataPathId, portNumber, portGrouping);
    assertNotNull(nodeConnectorUpdated);
}
Also used : PortGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping) BigInteger(java.math.BigInteger) NodeConnectorUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated) Test(org.junit.Test)

Aggregations

BigInteger (java.math.BigInteger)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 OpenflowVersion (org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)7 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)6 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)6 ActionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)5 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)5 OvsdbBridgeAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation)5 List (java.util.List)4 DatapathId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId)4 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)4 ByteBuf (io.netty.buffer.ByteBuf)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)3 NodeConnectorUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder)3 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)3 OvsdbBridgeAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentationBuilder)3 OvsdbBridgeName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName)3 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)3