Search in sources :

Example 1 with InstructionsBuilder

use of org.openkilda.rulemanager.Instructions.InstructionsBuilder 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();
}
Also used : OFInstructionMeter(org.projectfloodlight.openflow.protocol.instruction.OFInstructionMeter) MeterAction(org.openkilda.rulemanager.action.MeterAction) SwapFieldAction(org.openkilda.rulemanager.action.SwapFieldAction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) Set(java.util.Set) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) OFInstructionWriteMetadata(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata) InstructionsBuilder(org.openkilda.rulemanager.Instructions.InstructionsBuilder) MeterId(org.openkilda.model.MeterId) OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OfMetadata(org.openkilda.rulemanager.OfMetadata) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) List(java.util.List) ArrayList(java.util.ArrayList) OFInstructionWriteActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteActions)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 MeterId (org.openkilda.model.MeterId)1 InstructionsBuilder (org.openkilda.rulemanager.Instructions.InstructionsBuilder)1 OfMetadata (org.openkilda.rulemanager.OfMetadata)1 Action (org.openkilda.rulemanager.action.Action)1 GroupAction (org.openkilda.rulemanager.action.GroupAction)1 MeterAction (org.openkilda.rulemanager.action.MeterAction)1 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)1 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)1 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)1 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)1 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)1 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)1 SwapFieldAction (org.openkilda.rulemanager.action.SwapFieldAction)1 CopyFieldAction (org.openkilda.rulemanager.action.noviflow.CopyFieldAction)1 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)1 OFInstruction (org.projectfloodlight.openflow.protocol.instruction.OFInstruction)1 OFInstructionApplyActions (org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions)1