use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder in project openflowplugin by opendaylight.
the class FlowForwarderTest method updateTest.
@Test
public void updateTest() throws Exception {
Mockito.when(salFlowService.updateFlow(updateFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
final Instructions originalInstructions = new InstructionsBuilder().setInstruction(Collections.singletonList(new InstructionBuilder().setInstruction(new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(Collections.singletonList(new ActionBuilder().setAction(new DropActionCaseBuilder().build()).build())).build()).build()).build())).build();
final Flow flowUpdated = new FlowBuilder(flow).setInstructions(originalInstructions).setMatch(new MatchBuilder().build()).build();
final Future<RpcResult<UpdateFlowOutput>> updateResult = flowForwarder.update(flowPath, flow, flowUpdated, flowCapableNodePath);
Mockito.verify(salFlowService).updateFlow(Matchers.<UpdateFlowInput>any());
final UpdateFlowInput updateFlowInput = updateFlowInputCpt.getValue();
final OriginalFlow flowOrigInput = updateFlowInput.getOriginalFlow();
final UpdatedFlow flowInput = updateFlowInput.getUpdatedFlow();
Assert.assertEquals(nodePath, updateFlowInput.getNode().getValue());
Assert.assertEquals(flowPath, updateFlowInput.getFlowRef().getValue());
Assert.assertEquals(2, flowInput.getTableId().shortValue());
Assert.assertEquals(emptyMatch, flowInput.getMatch());
Assert.assertEquals(originalInstructions, flowInput.getInstructions());
Assert.assertEquals(true, flowInput.isStrict());
Assert.assertEquals(2, flowOrigInput.getTableId().shortValue());
Assert.assertEquals(emptyMatch, flowOrigInput.getMatch());
Assert.assertEquals(null, flowOrigInput.getInstructions());
Assert.assertEquals(true, flowOrigInput.isStrict());
final RpcResult<UpdateFlowOutput> updateFlowOutputRpcResult = updateResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(updateFlowOutputRpcResult.isSuccessful());
final UpdateFlowOutput resultValue = updateFlowOutputRpcResult.getResult();
Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder in project openflowplugin by opendaylight.
the class Test method createDecNwTtlInstructionsBld.
private static InstructionsBuilder createDecNwTtlInstructionsBld() {
// Add our drop action to a list
List<Action> actionList = new ArrayList<>();
actionList.add(createOFAction(0).build());
actionList.add(createNxActionBld(1).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());
ib.setKey(new InstructionKey(0));
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder in project openflowplugin by opendaylight.
the class InstructionsTablePropertySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Instructions property = new InstructionsBuilder().setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder().setInstruction(Collections.singletonList(new InstructionBuilder().setOrder(0).setInstruction(new ApplyActionsCaseBuilder().build()).build())).build()).build();
assertProperty(property, out -> {
assertEquals(out.readUnsignedShort(), InstructionConstants.APPLY_ACTIONS_TYPE);
// Skip length of set field action
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder in project openflowplugin by opendaylight.
the class SimpleDropFirewallCli method createTcpFlow.
/**
* Form of input is: node name node-connector number source ip-address destinatinon ip-address.
*
* @param cliInput
* Parsed input from CLI
*/
public AddFlowInput createTcpFlow(final List<String> cliInput) {
AddFlowInputBuilder ret = new AddFlowInputBuilder();
ret.setNode(nodeFromString(cliInput.get(0)));
// We construct a match
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
ipv4Match.setIpv4Source(new Ipv4Prefix(cliInput.get(3)));
ipv4Match.setIpv4Destination(new Ipv4Prefix(cliInput.get(4)));
match.setLayer3Match(ipv4Match.build());
match.setLayer4Match(new TcpMatchBuilder().build());
ret.setMatch(match.build());
DropActionCase dropAction = new DropActionCaseBuilder().build();
ActionBuilder action = new ActionBuilder();
action.setAction(dropAction);
List<Action> actions = Collections.singletonList(action.build());
//
ApplyActionsCaseBuilder aaBldr = new ApplyActionsCaseBuilder();
aaBldr.setApplyActions(new ApplyActionsBuilder().setAction(actions).build());
InstructionBuilder instructionBldr = new InstructionBuilder();
instructionBldr.setInstruction(aaBldr.build());
List<Instruction> isntructions = Collections.singletonList(instructionBldr.build());
InstructionsBuilder instructionsBldr = new InstructionsBuilder();
instructionsBldr.setInstruction(isntructions);
ret.setInstructions(instructionsBldr.build());
return ret.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder in project openflowplugin by opendaylight.
the class AbstractDropTest method makeStaticDropActionInstructions.
private static Instructions makeStaticDropActionInstructions() {
// Create an DropAction
final DropActionCase dropAction = new DropActionCaseBuilder().setDropAction(new DropActionBuilder().build()).build();
// Create an Action
final Action ab = new ActionBuilder().setOrder(0).setAction(dropAction).build();
// Create an Apply Action
final ApplyActions aab = new ApplyActionsBuilder().setAction(Collections.singletonList(ab)).build();
// Wrap our Apply Action in an Instruction
final Instruction ib = new InstructionBuilder().setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab).build()).setOrder(0).build();
// Put our Instruction in a list of Instructions
return new InstructionsBuilder().setInstruction(Collections.singletonList(ib)).build();
}
Aggregations