use of org.projectfloodlight.openflow.protocol.action.OFAction in project open-kilda by telstra.
the class FlowsResource method buildFlowInstructions.
private Map<String, Object> buildFlowInstructions(final List<OFInstruction> instructions) {
Map<String, Object> data = new HashMap<>();
for (OFInstruction instruction : instructions) {
Map<String, Object> iData = new HashMap<>();
OFInstructionType instructionType = instruction.getType();
switch(instructionType) {
case APPLY_ACTIONS:
for (OFAction action : ((OFInstructionApplyActions) instruction).getActions()) {
OFActionType actionType = action.getType();
switch(actionType) {
case // ver1.5
METER:
iData.put(actionType.toString(), ((OFActionMeter) action).getMeterId());
break;
case OUTPUT:
Optional.ofNullable(((OFActionOutput) action).getPort()).ifPresent(port -> iData.put(actionType.toString(), port.toString()));
break;
case POP_VLAN:
iData.put(actionType.toString(), null);
break;
case PUSH_VLAN:
Optional.ofNullable(((OFActionPushVlan) action).getEthertype()).ifPresent(ethType -> iData.put(actionType.toString(), ethType.toString()));
break;
case SET_FIELD:
OFOxm<?> setFieldAction = ((OFActionSetField) action).getField();
iData.put(actionType.toString(), String.format("%s->%s", setFieldAction.getValue(), setFieldAction.getMatchField().getName()));
break;
default:
iData.put(actionType.toString(), "could not parse");
break;
}
}
break;
case METER:
OFInstructionMeter action = ((OFInstructionMeter) instruction);
iData.put(instructionType.toString(), action.getMeterId());
break;
default:
iData.put(instructionType.toString(), "could not parse");
break;
}
data.put(instruction.getType().name(), iData);
}
return data;
}
Aggregations