import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
public class OFToMDSalFlowConvertor {
+ private OFToMDSalFlowConvertor() {
+ // hiding implicite constructor
+ }
+
/**
* Method convert Openflow 1.3+ specific instructions to MD-SAL format
* flow instruction
List<Instruction> salInstructionList = new ArrayList<Instruction>();
int instructionTreeNodekey = 0;
+ org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction salInstruction;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction switchInst : instructions) {
if (switchInst.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions.class)) {
applyActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(actionsInstruction.getAction(), ofVersion, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION)));
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
-
- InstructionBuilder instBuilder = new InstructionBuilder();
- instBuilder.setInstruction(applyActionsCaseBuilder.build());
- instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
- instBuilder.setOrder(instructionTreeNodekey);
- instructionTreeNodekey++;
- salInstructionList.add(instBuilder.build());
+ salInstruction = applyActionsCaseBuilder.build();
} else if (switchInst.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions.class)) {
- InstructionBuilder instBuilder = new InstructionBuilder();
ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
ClearActionsBuilder clearActionsBuilder = new ClearActionsBuilder();
clearActionsCaseBuilder.setClearActions(clearActionsBuilder.build());
- instBuilder.setInstruction(clearActionsCaseBuilder.build());
- instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
- instBuilder.setOrder(instructionTreeNodekey);
- instructionTreeNodekey++;
-
- salInstructionList.add(instBuilder.build());
+ salInstruction = clearActionsCaseBuilder.build();
} else if (switchInst.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable.class)) {
TableIdInstruction tableIdInstruction = (TableIdInstruction) switchInst.getAugmentation(TableIdInstruction.class);
goToTableBuilder.setTableId(tableIdInstruction.getTableId());
goToTableCaseBuilder.setGoToTable(goToTableBuilder.build());
- InstructionBuilder instBuilder = new InstructionBuilder();
- instBuilder.setInstruction(goToTableCaseBuilder.build());
- instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
- instBuilder.setOrder(instructionTreeNodekey);
- instructionTreeNodekey++;
-
- salInstructionList.add(instBuilder.build());
+ salInstruction = goToTableCaseBuilder.build();
} else if (switchInst.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter.class)) {
MeterIdInstruction meterIdInstruction = (MeterIdInstruction) switchInst.getAugmentation(MeterIdInstruction.class);
- InstructionBuilder instBuilder = new InstructionBuilder();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
meterBuilder.setMeterId(new MeterId(meterIdInstruction.getMeterId()));
meterCaseBuilder.setMeter(meterBuilder.build());
- instBuilder.setInstruction(meterCaseBuilder.build());
- instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
- instBuilder.setOrder(instructionTreeNodekey);
- instructionTreeNodekey++;
-
- salInstructionList.add(instBuilder.build());
+ salInstruction = meterCaseBuilder.build();
} else if (switchInst.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions.class)) {
ActionsInstruction actionsInstruction = (ActionsInstruction) switchInst.getAugmentation(ActionsInstruction.class);
writeActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(actionsInstruction.getAction(), ofVersion, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION)));
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
- InstructionBuilder instBuilder = new InstructionBuilder();
- instBuilder.setInstruction(writeActionsCaseBuilder.build());
- instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
- instBuilder.setOrder(instructionTreeNodekey);
- instructionTreeNodekey++;
-
- salInstructionList.add(instBuilder.build());
-
+ salInstruction = writeActionsCaseBuilder.build();
} else if (switchInst.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata.class)) {
MetadataInstruction metadataInstruction = (MetadataInstruction) switchInst.getAugmentation(MetadataInstruction.class);
writeMetadataBuilder.setMetadataMask(new BigInteger(1, metadataInstruction.getMetadataMask()));
writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
- InstructionBuilder instBuilder = new InstructionBuilder();
- instBuilder.setInstruction(writeMetadataCaseBuilder.build());
- instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
- instBuilder.setOrder(instructionTreeNodekey);
- instructionTreeNodekey++;
-
- salInstructionList.add(instBuilder.build());
+ salInstruction = writeMetadataCaseBuilder.build();
+ } else {
+ continue;
}
+
+ InstructionBuilder instBuilder = new InstructionBuilder();
+ instBuilder.setInstruction(salInstruction);
+ instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
+ instBuilder.setOrder(instructionTreeNodekey);
+ instructionTreeNodekey++;
+ salInstructionList.add(instBuilder.build());
+
}
instructionsBuilder.setInstruction(salInstructionList);
return instructionsBuilder.build();