use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder in project openflowplugin by opendaylight.
the class PacketOutConvertor method convert.
@Override
public PacketOutInput convert(TransmitPacketInput source, PacketOutConvertorData data) {
LOG.trace("toPacketOutInput for datapathId:{}, xid:{}", data.getDatapathId(), data.getXid());
// Build Port ID from TransmitPacketInput.Ingress
PortNumber inPortNr;
Long bufferId = OFConstants.OFP_NO_BUFFER;
Iterable<PathArgument> inArgs = null;
if (source.getIngress() != null) {
inArgs = source.getIngress().getValue().getPathArguments();
}
if (inArgs != null && Iterables.size(inArgs) >= 3) {
inPortNr = getPortNumber(Iterables.get(inArgs, 2), data.getVersion());
} else {
// The packetOut originated from the controller
inPortNr = new PortNumber(0xfffffffdL);
}
// Build Buffer ID to be NO_OFP_NO_BUFFER
if (source.getBufferId() != null) {
bufferId = source.getBufferId();
}
PortNumber outPort = null;
NodeConnectorRef outRef = source.getEgress();
Iterable<PathArgument> outArgs = outRef.getValue().getPathArguments();
if (Iterables.size(outArgs) >= 3) {
outPort = getPortNumber(Iterables.get(outArgs, 2), data.getVersion());
} else {
// TODO : P4 search for some normal exception
// new Exception("PORT NR not exist in Egress");
LOG.error("PORT NR not exist in Egress");
}
List<Action> actions = new ArrayList<>();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> inputActions = source.getAction();
if (inputActions != null) {
final ActionConvertorData actionConvertorData = new ActionConvertorData(data.getVersion());
actionConvertorData.setDatapathId(data.getDatapathId());
final Optional<List<Action>> convertedActions = getConvertorExecutor().convert(inputActions, actionConvertorData);
actions = convertedActions.orElse(Collections.emptyList());
} else {
// TODO VD P! wait for way to move Actions (e.g. augmentation)
OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
outputActionBuilder.setPort(outPort);
outputActionBuilder.setMaxLength(OFConstants.OFPCML_NO_BUFFER);
outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
ActionBuilder actionBuild = new ActionBuilder();
actionBuild.setActionChoice(outputActionCaseBuilder.build());
actions.add(actionBuild.build());
}
PacketOutInputBuilder builder = new PacketOutInputBuilder();
builder.setAction(actions);
builder.setData(source.getPayload());
builder.setVersion(data.getVersion());
builder.setXid(data.getXid());
builder.setInPort(inPortNr);
builder.setBufferId(bufferId);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder in project openflowplugin by opendaylight.
the class TableFeaturesConvertor method setActionTableFeatureProperty.
private static void setActionTableFeatureProperty(final TableFeaturePropertiesBuilder builder, final TableFeaturesPropType type, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> salActions) {
List<Action> actionList = new ArrayList<>();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action currAction : salActions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionType = currAction.getAction();
ActionBuilder actionBuilder = new ActionBuilder();
if (actionType instanceof OutputActionCase) {
OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
actionBuilder.setActionChoice(outputActionCaseBuilder.build());
} else if (actionType instanceof GroupActionCase) {
GroupCaseBuilder groupActionBuilder = new GroupCaseBuilder();
actionBuilder.setActionChoice(groupActionBuilder.build());
} else if (actionType instanceof CopyTtlOutCase) {
CopyTtlOutCaseBuilder copyTtlOutCaseBuilder = new CopyTtlOutCaseBuilder();
actionBuilder.setActionChoice(copyTtlOutCaseBuilder.build());
} else if (actionType instanceof CopyTtlInCase) {
CopyTtlInCaseBuilder copyTtlInCaseBuilder = new CopyTtlInCaseBuilder();
actionBuilder.setActionChoice(copyTtlInCaseBuilder.build());
} else if (actionType instanceof SetMplsTtlActionCase) {
SetMplsTtlCaseBuilder setMplsTtlActionBuilder = new SetMplsTtlCaseBuilder();
actionBuilder.setActionChoice(setMplsTtlActionBuilder.build());
} else if (actionType instanceof DecMplsTtlCase) {
DecMplsTtlCaseBuilder decMplsTtlCaseBuilder = new DecMplsTtlCaseBuilder();
actionBuilder.setActionChoice(decMplsTtlCaseBuilder.build());
} else if (actionType instanceof PushVlanActionCase) {
PushVlanCaseBuilder pushVlanActionBuilder = new PushVlanCaseBuilder();
actionBuilder.setActionChoice(pushVlanActionBuilder.build());
} else if (actionType instanceof PopVlanActionCase) {
PopVlanCaseBuilder popVlanCaseBuilder = new PopVlanCaseBuilder();
actionBuilder.setActionChoice(popVlanCaseBuilder.build());
} else if (actionType instanceof PushMplsActionCase) {
PushMplsCaseBuilder pushMplsActionBuilder = new PushMplsCaseBuilder();
actionBuilder.setActionChoice(pushMplsActionBuilder.build());
} else if (actionType instanceof PopMplsActionCase) {
PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
actionBuilder.setActionChoice(popMplsCaseBuilder.build());
} else if (actionType instanceof SetQueueActionCase) {
SetQueueCaseBuilder setQueueActionBuilder = new SetQueueCaseBuilder();
actionBuilder.setActionChoice(setQueueActionBuilder.build());
} else if (actionType instanceof SetNwTtlActionCase) {
SetNwTtlCaseBuilder setNwTtlActionBuilder = new SetNwTtlCaseBuilder();
actionBuilder.setActionChoice(setNwTtlActionBuilder.build());
} else if (actionType instanceof DecNwTtlCase) {
DecNwTtlCaseBuilder decNwTtlCaseBuilder = new DecNwTtlCaseBuilder();
actionBuilder.setActionChoice(decNwTtlCaseBuilder.build());
} else if (actionType instanceof SetFieldCase) {
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
actionBuilder.setActionChoice(setFieldCaseBuilder.build());
} else if (actionType instanceof PushPbbActionCase) {
PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
actionBuilder.setActionChoice(pushPbbCaseBuilder.build());
} else if (actionType instanceof PopPbbActionCase) {
PopPbbCaseBuilder popPbbCaseBuilder = new PopPbbCaseBuilder();
actionBuilder.setActionChoice(popPbbCaseBuilder.build());
}
// Experimenter action is unhandled
actionList.add(actionBuilder.build());
}
ActionRelatedTableFeaturePropertyBuilder propBuilder = new ActionRelatedTableFeaturePropertyBuilder();
propBuilder.setAction(actionList);
builder.setType(type);
builder.addAugmentation(ActionRelatedTableFeatureProperty.class, propBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createDecNwTtlInstructions.
private static InstructionsBuilder createDecNwTtlInstructions() {
DecNwTtlBuilder ta = new DecNwTtlBuilder();
DecNwTtl decNwTtl = ta.build();
ActionBuilder ab = new ActionBuilder();
ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
// Add our drop action to a list
List<Action> actionList = new ArrayList<>();
actionList.add(ab.build());
// Create an Apply Action
ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
ib.setKey(new InstructionKey(0));
ib.setOrder(0);
// Put our Instruction in a list of Instructions
InstructionsBuilder isb = new InstructionsBuilder();
List<Instruction> instructions = new ArrayList<>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createGroupAction.
private List<Action> createGroupAction() {
GroupActionBuilder groupActionB = new GroupActionBuilder();
groupActionB.setGroupId(1L);
groupActionB.setGroup("0");
ActionBuilder action = new ActionBuilder();
action.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
action.setKey(new ActionKey(0));
List<Action> actions = new ArrayList<>();
actions.add(action.build());
return actions;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createNonAppyPushVlanAction.
private static List<Action> createNonAppyPushVlanAction() {
ActionBuilder ab = new ActionBuilder();
GroupActionBuilder groupActionB = new GroupActionBuilder();
groupActionB.setGroupId(1L);
groupActionB.setGroup("0");
ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
List<Action> actionList = new ArrayList<>();
actionList.add(ab.build());
return actionList;
}
Aggregations