Search in sources :

Example 1 with OutputAction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction in project openflowplugin by opendaylight.

the class OutputActionSerializer method serialize.

@Override
public void serialize(OutputActionCase action, ByteBuf outBuffer) {
    super.serialize(action, outBuffer);
    final OutputAction outputAction = action.getOutputAction();
    Long value = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, outputAction.getOutputNodeConnector().getValue());
    if (value == null) {
        throw new IllegalArgumentException("Not a valid port number: " + outputAction.getOutputNodeConnector().getValue());
    }
    outBuffer.writeInt(value.intValue());
    outBuffer.writeShort(MoreObjects.firstNonNull(outputAction.getMaxLength(), 0));
    outBuffer.writeZero(ActionConstants.OUTPUT_PADDING);
}
Also used : OutputAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction)

Example 2 with OutputAction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction in project openflowplugin by opendaylight.

the class OutputActionDeserializerTest method testDeserialize.

@Test
public void testDeserialize() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final int portNum = 10;
    final short maxLength = 24;
    writeHeader(in);
    in.writeInt(portNum);
    in.writeShort(maxLength);
    in.writeZero(ActionConstants.OUTPUT_PADDING);
    final Action action = deserializeAction(in);
    assertTrue(OutputActionCase.class.isInstance(action));
    final OutputAction outputAction = OutputActionCase.class.cast(action).getOutputAction();
    assertEquals(portNum, InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, outputAction.getOutputNodeConnector().getValue()).intValue());
    assertEquals(maxLength, outputAction.getMaxLength().shortValue());
    assertEquals(0, in.readableBytes());
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action) OutputAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction) OutputAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction) ByteBuf(io.netty.buffer.ByteBuf) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase) Test(org.junit.Test)

Example 3 with OutputAction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction in project openflowplugin by opendaylight.

the class SalToOfOutputActionCase method process.

@Nonnull
@Override
public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
    final OutputAction outputAction = source.getOutputAction();
    final OutputActionBuilder outputBuilder = new OutputActionBuilder();
    if (outputAction.getMaxLength() != null) {
        outputBuilder.setMaxLength(outputAction.getMaxLength());
    } else {
        outputBuilder.setMaxLength(0);
    }
    final OpenflowVersion version = OpenflowVersion.get(data.getVersion());
    final String nodeConnectorId = outputAction.getOutputNodeConnector().getValue();
    final Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(version, nodeConnectorId);
    if (OpenflowPortsUtil.checkPortValidity(version, portNumber)) {
        outputBuilder.setPort(new PortNumber(portNumber));
    } else {
        LOG.error("Invalid Port specified {} for Output Action for OF version: {}", portNumber, version);
    }
    return Optional.of(new ActionBuilder().setActionChoice(new OutputActionCaseBuilder().setOutputAction(outputBuilder.build()).build()).build());
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) 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) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) OutputAction(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) Nonnull(javax.annotation.Nonnull)

Example 4 with OutputAction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction in project openflowplugin by opendaylight.

the class OfToSalOutputActionCase method process.

@Override
public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
    OutputActionBuilder outputAction = new OutputActionBuilder();
    OutputAction outputActionFromOF = source.getOutputAction();
    if (outputActionFromOF.getPort() != null) {
        PortNumberUni protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(ofVersion, outputActionFromOF.getPort().getValue());
        String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
        outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
    } else {
        LOG.error("Provided action is not OF Output action, no associated port found!");
    }
    Integer maxLength = outputActionFromOF.getMaxLength();
    if (maxLength != null) {
        outputAction.setMaxLength(maxLength);
    } else {
        LOG.error("Provided action is not OF Output action, no associated length found!");
    }
    OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
    outputActionCaseBuilder.setOutputAction(outputAction.build());
    return Optional.of(outputActionCaseBuilder.build());
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) OutputAction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputAction) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)

Example 5 with OutputAction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction in project openflowplugin by opendaylight.

the class ActionConvertorV10Test method testToMDSalActions.

/**
 * Test {@link ActionResponseConvertor#convert(List, ActionResponseConvertorData)}}.
 */
@Test
public void testToMDSalActions() {
    OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
    OutputActionBuilder outputBuilder = new OutputActionBuilder();
    outputBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(14L));
    outputBuilder.setMaxLength(555);
    caseBuilder.setOutputAction(outputBuilder.build());
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
    actionBuilder.setActionChoice(caseBuilder.build());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actions = new ArrayList<>();
    actions.add(actionBuilder.build());
    ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_0);
    data.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
    Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> mdSalActionsOptional = convertorManager.convert(actions, data);
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());
    Assert.assertEquals("Wrong number of output actions", 1, mdSalActions.size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);
    Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());
    OutputActionCase outputAction = (OutputActionCase) action;
    Assert.assertEquals("Wrong output port", "14", outputAction.getOutputAction().getOutputNodeConnector().getValue());
    Assert.assertEquals("Wrong max length", 555, outputAction.getOutputAction().getMaxLength().intValue());
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) SetTpDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder) SetVlanIdActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder) SetNwTosActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder) SetTpSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder) SetNwDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder) SetDlDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder) StripVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder) SetVlanPcpActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder) SetDlSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) ArrayList(java.util.ArrayList) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) List(java.util.List) ArrayList(java.util.ArrayList) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase) ActionResponseConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData) Test(org.junit.Test)

Aggregations

OutputAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction)3 Test (org.junit.Test)2 OpenflowVersion (org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion)2 OutputActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase)2 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder)2 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Nonnull (javax.annotation.Nonnull)1 ActionResponseConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData)1 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)1 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action)1 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder)1 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)1 SetDlDstActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder)1 SetDlSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder)1 SetNwDstActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder)1 SetNwSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder)1 SetNwTosActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder)1