use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions in project genius by opendaylight.
the class MDSALUtil method buildWriteActionsInstruction.
/**
* Build write actions instruction with the given actions and key.
*
* @param actions the actions.
* @param instructionKey the instruction key.
* @return the instruction.
*/
public static Instruction buildWriteActionsInstruction(List<Action> actions, int instructionKey) {
WriteActions writeActions = new WriteActionsBuilder().setAction(actions).build();
WriteActionsCase writeActionsCase = new WriteActionsCaseBuilder().setWriteActions(writeActions).build();
InstructionBuilder instructionBuilder = new InstructionBuilder();
instructionBuilder.setInstruction(writeActionsCase);
instructionBuilder.setKey(new InstructionKey(instructionKey));
return instructionBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions in project openflowplugin by opendaylight.
the class ApplyActionsInstructionSerializer method serialize.
@Override
public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
int startIndex = outBuffer.writerIndex();
outBuffer.writeShort(getType());
ApplyActionsCase actionsCase = (ApplyActionsCase) instruction.getInstructionChoice();
if (actionsCase != null) {
List<Action> actions = actionsCase.getApplyActions().getAction();
writeActions(actions, outBuffer, startIndex);
} else {
outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions in project openflowplugin by opendaylight.
the class WriteActionsInstructionSerializer method serialize.
@Override
public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
int startIndex = outBuffer.writerIndex();
outBuffer.writeShort(getType());
WriteActionsCase actionsCase = (WriteActionsCase) instruction.getInstructionChoice();
if (actionsCase != null) {
List<Action> actions = actionsCase.getWriteActions().getAction();
writeActions(actions, outBuffer, startIndex);
} else {
outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions in project openflowplugin by opendaylight.
the class WriteActionsTablePropertySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final WriteActions property = new WriteActionsBuilder().setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder().setAction(Collections.singletonList(new ActionBuilder().setOrder(0).setAction(new SetNwSrcActionCaseBuilder().build()).build())).build()).build();
assertProperty(property, out -> {
assertEquals(out.readUnsignedShort(), ActionConstants.SET_FIELD_CODE);
// Skip length of set field action
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions in project openflowplugin by opendaylight.
the class TableFeaturesConvertor method toTableProperties.
private static List<TableFeatureProperties> toTableProperties(final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties tableProperties) {
if (tableProperties == null) {
return Collections.emptyList();
}
List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(tableProperties.getTableFeatureProperties());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties property : sortedTableProperties) {
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType propType = property.getTableFeaturePropType();
setTableFeatureProperty(propType);
if (propType instanceof Instructions) {
setTableFeatureProperty((Instructions) propType, propBuilder);
} else if (propType instanceof InstructionsMiss) {
setTableFeatureProperty((InstructionsMiss) propType, propBuilder);
} else if (propType instanceof NextTable) {
setTableFeatureProperty((NextTable) propType, propBuilder);
} else if (propType instanceof NextTableMiss) {
setTableFeatureProperty((NextTableMiss) propType, propBuilder);
} else if (propType instanceof WriteActions) {
setTableFeatureProperty((WriteActions) propType, propBuilder);
} else if (propType instanceof WriteActionsMiss) {
setTableFeatureProperty((WriteActionsMiss) propType, propBuilder);
} else if (propType instanceof ApplyActions) {
setTableFeatureProperty((ApplyActions) propType, propBuilder);
} else if (propType instanceof ApplyActionsMiss) {
setTableFeatureProperty((ApplyActionsMiss) propType, propBuilder);
} else if (propType instanceof Match) {
setTableFeatureProperty((Match) propType, propBuilder);
} else if (propType instanceof Wildcards) {
setTableFeatureProperty((Wildcards) propType, propBuilder);
} else if (propType instanceof WriteSetfield) {
setTableFeatureProperty((WriteSetfield) propType, propBuilder);
} else if (propType instanceof WriteSetfieldMiss) {
setTableFeatureProperty((WriteSetfieldMiss) propType, propBuilder);
} else if (propType instanceof ApplySetfield) {
setTableFeatureProperty((ApplySetfield) propType, propBuilder);
} else if (propType instanceof ApplySetfieldMiss) {
setTableFeatureProperty((ApplySetfieldMiss) propType, propBuilder);
}
// Experimenter and Experimenter miss Table features are unhandled
ofTablePropertiesList.add(propBuilder.build());
}
return ofTablePropertiesList;
}
Aggregations