use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteActions in project open-kilda by telstra.
the class OfFlowPresenceVerifier method isInstructionsEquals.
private boolean isInstructionsEquals(List<OFInstruction> expectedSeq, List<OFInstruction> actualSeq) {
if (expectedSeq.size() != actualSeq.size()) {
return false;
}
Map<Class<?>, OFInstruction> expectedMap = sequenceToMapByTypes(expectedSeq);
Map<Class<?>, OFInstruction> actualMap = sequenceToMapByTypes(actualSeq);
boolean result = true;
for (Map.Entry<Class<?>, OFInstruction> entry : expectedMap.entrySet()) {
OFInstruction expected = entry.getValue();
OFInstruction actual = actualMap.get(entry.getKey());
if (actual == null) {
result = false;
} else if (expected instanceof OFInstructionApplyActions) {
result = isApplyActionsInstructionEquals((OFInstructionApplyActions) expected, (OFInstructionApplyActions) actual);
} else if (expected instanceof OFInstructionWriteActions) {
result = isWriteActionsInstructionEquals((OFInstructionWriteActions) expected, (OFInstructionWriteActions) actual);
} else if (!Objects.equals(expected, actual)) {
result = false;
}
if (!result) {
break;
}
}
return result;
}
use of org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteActions in project open-kilda by telstra.
the class OfInstructionsConverter method convertToRuleManagerInstructions.
/**
* Convert instructions.
*/
public Instructions convertToRuleManagerInstructions(List<OFInstruction> ofInstructions) {
InstructionsBuilder builder = Instructions.builder();
for (OFInstruction ofInstruction : ofInstructions) {
if (ofInstruction instanceof OFInstructionApplyActions) {
List<OFAction> ofActions = ((OFInstructionApplyActions) ofInstruction).getActions();
List<Action> actions = ofActions.stream().map(this::convertToRuleManagerAction).collect(Collectors.toList());
builder.applyActions(actions);
} else if (ofInstruction instanceof OFInstructionWriteActions) {
List<OFAction> ofActions = ((OFInstructionWriteActions) ofInstruction).getActions();
Set<Action> actions = ofActions.stream().map(this::convertToRuleManagerAction).collect(Collectors.toSet());
builder.writeActions(actions);
} else if (ofInstruction instanceof OFInstructionMeter) {
final long meterId = ((OFInstructionMeter) ofInstruction).getMeterId();
builder.goToMeter(new MeterId(meterId));
} else if (ofInstruction instanceof OFInstructionGotoTable) {
final short tableId = ((OFInstructionGotoTable) ofInstruction).getTableId().getValue();
builder.goToTable(OfTable.fromInt(tableId));
} else if (ofInstruction instanceof OFInstructionWriteMetadata) {
final long metadata = ((OFInstructionWriteMetadata) ofInstruction).getMetadata().getValue();
final long metadataMask = ((OFInstructionWriteMetadata) ofInstruction).getMetadataMask().getValue();
builder.writeMetadata(new OfMetadata(metadata, metadataMask));
}
}
return builder.build();
}
Aggregations