use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase in project genius by opendaylight.
the class FlowBasedServicesUtils method installLPortDispatcherFlow.
public static void installLPortDispatcherFlow(BigInteger dpId, BoundServices boundService, String interfaceName, WriteTransaction writeTransaction, int interfaceTag, short currentServiceIndex, short nextServiceIndex) {
String serviceRef = boundService.getServiceName();
List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForDispatcherTable(interfaceTag, currentServiceIndex);
// Get the metadata and mask from the service's write metadata
// instruction
StypeOpenflow stypeOpenFlow = boundService.getAugmentation(StypeOpenflow.class);
List<Instruction> serviceInstructions = stypeOpenFlow.getInstruction();
int instructionSize = serviceInstructions != null ? serviceInstructions.size() : 0;
BigInteger[] metadataValues = IfmUtil.mergeOpenflowMetadataWriteInstructions(serviceInstructions);
BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(interfaceTag, nextServiceIndex, metadataValues[0]);
BigInteger metadataMask = MetaDataUtil.getWriteMetaDataMaskForDispatcherTable();
// build the final instruction for LPort Dispatcher table flow entry
List<Instruction> instructions = new ArrayList<>();
instructions.add(MDSALUtil.buildAndGetWriteMetadaInstruction(metadata, metadataMask, ++instructionSize));
if (serviceInstructions != null && !serviceInstructions.isEmpty()) {
for (Instruction info : serviceInstructions) {
// Skip meta data write as that is handled already
if (info.getInstruction() instanceof WriteMetadataCase) {
continue;
} else if (info.getInstruction() instanceof WriteActionsCase) {
info = MDSALUtil.buildWriteActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((WriteActionsCase) info.getInstruction()).getWriteActions().getAction()));
} else if (info.getInstruction() instanceof ApplyActionsCase) {
info = MDSALUtil.buildApplyActionsInstruction(ActionConverterUtil.convertServiceActionToFlowAction(((ApplyActionsCase) info.getInstruction()).getApplyActions().getAction()));
}
instructions.add(info);
}
}
// build the flow and install it
String flowRef = getFlowRef(dpId, NwConstants.LPORT_DISPATCHER_TABLE, interfaceName, currentServiceIndex);
Flow ingressFlow = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, DEFAULT_DISPATCHER_PRIORITY, serviceRef, 0, 0, stypeOpenFlow.getFlowCookie(), matches, instructions);
LOG.debug("Installing LPort Dispatcher Flow on DPN {}, for interface {}, with flowRef {}", dpId, interfaceName, flowRef);
installFlow(dpId, ingressFlow, writeTransaction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase in project genius by opendaylight.
the class InstructionApplyActionsTest method verifyInstructionInfo.
private void verifyInstructionInfo(InstructionInfo instructionInfo) {
Instruction instruction = instructionInfo.buildInstruction(2);
assertEquals(2, instruction.getKey().getOrder().intValue());
assertTrue(instruction.getInstruction() instanceof ApplyActionsCase);
ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstruction();
List<Action> actions = applyActionsCase.getApplyActions().getAction();
assertEquals(1, actions.size());
Action action = actions.get(0);
assertTrue(action.getAction() instanceof GroupActionCase);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase in project netvirt by opendaylight.
the class OpenFlow13ProviderTest method checkApplyActionSize.
private List<Action> checkApplyActionSize(Instruction curInstruction, int numActions) {
assertTrue(curInstruction instanceof ApplyActionsCase);
ApplyActionsCase action = (ApplyActionsCase) curInstruction;
assertEquals(numActions, action.getApplyActions().getAction().size());
return action.getApplyActions().getAction();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase in project openflowplugin by opendaylight.
the class FlowConvertor method getActions.
private List<Action> getActions(short version, BigInteger datapathid, Flow flow) {
Instructions instructions = flow.getInstructions();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> sortedInstructions = INSTRUCTION_ORDERING.sortedCopy(instructions.getInstruction());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : sortedInstructions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction();
if (curInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curInstruction;
ApplyActions applyActions = applyActionscase.getApplyActions();
final ActionConvertorData data = new ActionConvertorData(version);
data.setDatapathId(datapathid);
data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
Optional<List<Action>> result = getConvertorExecutor().convert(applyActions.getAction(), data);
return result.orElse(Collections.emptyList());
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase in project openflowplugin by opendaylight.
the class FlowConvertor method injectPushActionToInstruction.
private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> injectPushActionToInstruction(final Flow sourceFlow) {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> srcInstructionList = sourceFlow.getInstructions().getInstruction();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> targetInstructionList = new ArrayList<>(srcInstructionList.size());
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> targetActionList = new ArrayList<>();
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder instructionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction srcInstruction : srcInstructionList) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curSrcInstruction = srcInstruction.getInstruction();
if (curSrcInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curSrcInstruction;
ApplyActions applyActions = applyActionscase.getApplyActions();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> srcActionList = applyActions.getAction();
int offset = 0;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action actionItem : srcActionList) {
if (actionItem.getAction() instanceof SetVlanIdActionCase) {
SetVlanIdActionCase setVlanIdActionCase = (SetVlanIdActionCase) actionItem.getAction();
PushVlanActionCaseBuilder pushVlanActionCaseBuilder = new PushVlanActionCaseBuilder();
PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
pushVlanActionBuilder.setCfi(new VlanCfi(1)).setVlanId(setVlanIdActionCase.getSetVlanIdAction().getVlanId()).setEthernetType(PUSH_VLAN).setTag(PUSH_VLAN);
pushVlanActionCaseBuilder.setPushVlanAction(pushVlanActionBuilder.build());
PushVlanActionCase injectedAction = pushVlanActionCaseBuilder.build();
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setAction(injectedAction).setKey(actionItem.getKey()).setOrder(actionItem.getOrder() + offset);
targetActionList.add(actionBuilder.build());
offset++;
}
if (offset > 0) {
// we need to increment the order for all the actions added after injection
ActionBuilder actionBuilder = new ActionBuilder(actionItem);
actionBuilder.setOrder(actionItem.getOrder() + offset);
actionItem = actionBuilder.build();
}
targetActionList.add(actionItem);
}
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
applyActionsBuilder.setAction(targetActionList);
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
instructionBuilder.setInstruction(applyActionsCaseBuilder.build());
} else {
instructionBuilder.setInstruction(curSrcInstruction);
}
instructionBuilder.setKey(srcInstruction.getKey()).setOrder(srcInstruction.getOrder());
targetInstructionList.add(instructionBuilder.build());
}
return targetInstructionList;
}
Aggregations