use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase in project openflowplugin by opendaylight.
the class TableFeaturesConvertor method setInstructionTableFeatureProperty.
private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder, final TableFeaturesPropType type, final List<Instruction> instructionList) {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> instructionTypeList = new ArrayList<>();
for (Instruction currInstruction : instructionList) {
InstructionBuilder instructionType = new InstructionBuilder();
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction = currInstruction.getInstruction();
if (instruction instanceof GoToTableCase) {
GotoTableCaseBuilder goToTableCaseBuilder = new GotoTableCaseBuilder();
instructionType.setInstructionChoice(goToTableCaseBuilder.build());
} else if (instruction instanceof WriteMetadataCase) {
WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
instructionType.setInstructionChoice(writeMetadataCaseBuilder.build());
} else if (instruction instanceof WriteActionsCase) {
WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
instructionType.setInstructionChoice(writeActionsCaseBuilder.build());
} else if (instruction instanceof ApplyActionsCase) {
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
instructionType.setInstructionChoice(applyActionsCaseBuilder.build());
} else if (instruction instanceof ClearActionsCase) {
ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
instructionType.setInstructionChoice(clearActionsCaseBuilder.build());
} else if (instruction instanceof MeterCase) {
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
instructionType.setInstructionChoice(meterCaseBuilder.build());
}
// TODO: Experimenter instructions are unhandled
instructionTypeList.add(instructionType.build());
}
InstructionRelatedTableFeaturePropertyBuilder propBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
propBuilder.setInstruction(instructionTypeList);
builder.setType(type);
builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, propBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase in project openflowplugin by opendaylight.
the class AbstractInstructionDeserializerTest method test.
/**
* Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different
* instruction types.
*/
@Test
public void test() {
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04");
Instruction instruction = new GoToTableInstructionDeserializer().deserializeHeader(buffer);
Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof GotoTableCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04");
instruction = new WriteMetadataInstructionDeserializer().deserializeHeader(buffer);
Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteMetadataCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04");
instruction = new WriteActionsInstructionDeserializer().deserializeHeader(buffer);
Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteActionsCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04");
instruction = new ApplyActionsInstructionDeserializer().deserializeHeader(buffer);
Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ApplyActionsCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04");
instruction = new ClearActionsInstructionDeserializer().deserializeHeader(buffer);
Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ClearActionsCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04");
instruction = new MeterInstructionDeserializer().deserializeHeader(buffer);
Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof MeterCase);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase in project openflowplugin by opendaylight.
the class InstructionsDeserializerTest method test.
/**
* Testing instructions translation.
*/
@Test
public void test() {
ByteBuf message = BufferHelper.buildBuffer("00 01 00 08 0A 00 00 00 00 02 00 18 00 00 00 00 " + "00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 30 00 05 00 08 00 00 00 00 00 06 00 08 " + "00 01 02 03 00 03 00 20 00 00 00 00 00 00 00 10 00 00 00 25 00 35 00 00 00 00 00 00 " + "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00");
// skip XID
message.skipBytes(4);
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Instruction> instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, message.readableBytes(), message, keyMaker, registry);
Instruction i1 = instructions.get(0);
Assert.assertTrue("Wrong type - i1", i1.getInstructionChoice() instanceof GotoTableCase);
Assert.assertEquals("Wrong table-id - i1", 10, ((GotoTableCase) i1.getInstructionChoice()).getGotoTable().getTableId().intValue());
Instruction i2 = instructions.get(1);
Assert.assertTrue("Wrong type - i2", i2.getInstructionChoice() instanceof WriteMetadataCase);
Assert.assertArrayEquals("Wrong metadata - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 20"), ((WriteMetadataCase) i2.getInstructionChoice()).getWriteMetadata().getMetadata());
Assert.assertArrayEquals("Wrong metadata-mask - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 30"), ((WriteMetadataCase) i2.getInstructionChoice()).getWriteMetadata().getMetadataMask());
Instruction i3 = instructions.get(2);
Assert.assertTrue("Wrong type - i3", i3.getInstructionChoice() instanceof ClearActionsCase);
Instruction i4 = instructions.get(3);
Assert.assertTrue("Wrong type - i4", i4.getInstructionChoice() instanceof MeterCase);
Assert.assertEquals("Wrong meterId - i4", 66051, ((MeterCase) i4.getInstructionChoice()).getMeter().getMeterId().intValue());
Instruction i5 = instructions.get(4);
Assert.assertTrue("Wrong type - i5", i5.getInstructionChoice() instanceof WriteActionsCase);
Assert.assertEquals("Wrong instructions - i5", 2, ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().size());
Action action1 = ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().get(0);
Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof OutputActionCase);
Assert.assertEquals("Wrong action", 37, ((OutputActionCase) action1.getActionChoice()).getOutputAction().getPort().getValue().intValue());
Assert.assertEquals("Wrong action", 53, ((OutputActionCase) action1.getActionChoice()).getOutputAction().getMaxLength().intValue());
Action action2 = ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().get(1);
Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof GroupCase);
Assert.assertEquals("Wrong action", 80, ((GroupCase) action2.getActionChoice()).getGroupAction().getGroupId().intValue());
Instruction i6 = instructions.get(5);
Assert.assertTrue("Wrong type - i6", i6.getInstructionChoice() instanceof ApplyActionsCase);
Assert.assertEquals("Wrong instructions - i6", 2, ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().size());
action1 = ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().get(0);
Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof SetQueueCase);
Assert.assertEquals("Wrong action", 37, ((SetQueueCase) action1.getActionChoice()).getSetQueueAction().getQueueId().intValue());
action2 = ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().get(1);
Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof SetMplsTtlCase);
Assert.assertEquals("Wrong action", 5, ((SetMplsTtlCase) action2.getActionChoice()).getSetMplsTtlAction().getMplsTtl().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase in project openflowplugin by opendaylight.
the class TableFeaturesResponseConvertor method setInstructionTableFeatureProperty.
private static List<Instruction> setInstructionTableFeatureProperty(final TableFeatureProperties properties) {
List<Instruction> instructionList = new ArrayList<>();
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder();
int index = 0;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction currInstruction : properties.getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstruction()) {
InstructionChoice currInstructionType = currInstruction.getInstructionChoice();
if (currInstructionType instanceof GotoTableCase) {
builder.setInstruction(new GoToTableCaseBuilder().setGoToTable(new GoToTableBuilder().build()).build());
} else if (currInstructionType instanceof WriteMetadataCase) {
builder.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(new WriteMetadataBuilder().build()).build());
} else if (currInstructionType instanceof WriteActionsCase) {
builder.setInstruction(new WriteActionsCaseBuilder().setWriteActions(new WriteActionsBuilder().build()).build());
} else if (currInstructionType instanceof ApplyActionsCase) {
builder.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().build()).build());
} else if (currInstructionType instanceof ClearActionsCase) {
builder.setInstruction(new ClearActionsCaseBuilder().setClearActions(new ClearActionsBuilder().build()).build());
} else if (currInstructionType instanceof MeterCase) {
builder.setInstruction(new MeterCaseBuilder().setMeter(new MeterBuilder().build()).build());
}
// TODO: Experimenter instructions are unhandled
builder.setOrder(index);
index += 1;
instructionList.add(builder.build());
}
return instructionList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase in project genius by opendaylight.
the class InstructionClearActionsTest method verifyInstructionInfo.
private void verifyInstructionInfo(InstructionInfo instructionInfo) {
Instruction instruction = instructionInfo.buildInstruction(2);
assertEquals(2, instruction.getKey().getOrder().intValue());
assertTrue(instruction.getInstruction() instanceof ClearActionsCase);
}
Aggregations