Search in sources :

Example 11 with AddFlowInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder in project openflowplugin by opendaylight.

the class Test method testFlow.

@Override
public Future<RpcResult<Void>> testFlow(TestFlowInput input) {
    AddFlowInputBuilder flow = new AddFlowInputBuilder();
    flow.setPriority(2);
    flow.setMatch(createMatchBld().build());
    flow.setInstructions(createDecNwTtlInstructionsBld().build());
    flow.setBarrier(Boolean.FALSE);
    BigInteger value = BigInteger.valueOf(10L);
    flow.setCookie(new FlowCookie(value));
    flow.setCookieMask(new FlowCookie(value));
    flow.setHardTimeout(0);
    flow.setIdleTimeout(0);
    flow.setInstallHw(false);
    flow.setStrict(false);
    flow.setContainerName(null);
    flow.setFlags(new FlowModFlags(false, false, false, false, true));
    flow.setTableId((short) 0);
    flow.setFlowName("NiciraFLOW");
    // Construct the flow instance id
    final InstanceIdentifier<Node> flowInstanceId = InstanceIdentifier.builder(// File under nodes
    Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
    flow.setNode(new NodeRef(flowInstanceId));
    pushFlowViaRpc(flow.build());
    return Futures.immediateFuture(RpcResultBuilder.<Void>status(true).build());
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder) BigInteger(java.math.BigInteger) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 12 with AddFlowInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder in project openflowplugin by opendaylight.

the class SingleLayerFlowServiceTest method buildRequest.

@Test
public void buildRequest() throws Exception {
    final AddFlowInput input = new AddFlowInputBuilder().setTableId(TABLE_ID).build();
    final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
    assertEquals(FlowMessage.class, ofHeader.getImplementedInterface());
    final FlowMessage result = FlowMessage.class.cast(ofHeader);
    assertEquals(FlowModCommand.OFPFCADD, result.getCommand());
    assertEquals(TABLE_ID, result.getTableId().shortValue());
}
Also used : OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder) FlowMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessage) Test(org.junit.Test)

Example 13 with AddFlowInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder 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();
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) TcpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) DropActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder) TcpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) DropActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder)

Example 14 with AddFlowInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder in project openflowplugin by opendaylight.

the class SalFlowsBatchServiceImpl method addFlowsBatch.

@Override
public Future<RpcResult<AddFlowsBatchOutput>> addFlowsBatch(final AddFlowsBatchInput input) {
    LOG.trace("Adding flows @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddFlows().size());
    final ArrayList<ListenableFuture<RpcResult<AddFlowOutput>>> resultsLot = new ArrayList<>();
    for (BatchFlowInputGrouping batchFlow : input.getBatchAddFlows()) {
        final AddFlowInput addFlowInput = new AddFlowInputBuilder(batchFlow).setFlowRef(createFlowRef(input.getNode(), batchFlow)).setNode(input.getNode()).build();
        resultsLot.add(JdkFutureAdapters.listenInPoolThread(salFlowService.addFlow(addFlowInput)));
    }
    final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult = Futures.transform(Futures.successfulAsList(resultsLot), FlowUtil.<AddFlowOutput>createCumulatingFunction(input.getBatchAddFlows()), MoreExecutors.directExecutor());
    ListenableFuture<RpcResult<AddFlowsBatchOutput>> addFlowsBulkFuture = Futures.transform(commonResult, FlowUtil.FLOW_ADD_TRANSFORM, MoreExecutors.directExecutor());
    if (input.isBarrierAfter()) {
        addFlowsBulkFuture = BarrierUtil.chainBarrier(addFlowsBulkFuture, input.getNode(), transactionService, FlowUtil.FLOW_ADD_COMPOSING_TRANSFORM);
    }
    return addFlowsBulkFuture;
}
Also used : AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) BatchFlowInputGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowInputGrouping) BatchFailedFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput) ArrayList(java.util.ArrayList) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)

Example 15 with AddFlowInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder in project openflowplugin by opendaylight.

the class SalFlowServiceImplTest method addFlow.

private void addFlow(short version) throws ExecutionException, InterruptedException {
    AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder().setMatch(match).setTableId((short) 1).build();
    SalFlowServiceImpl salFlowService = mockSalFlowService(version);
    mockingFlowRegistryLookup();
    verifyOutput(salFlowService.addFlow(mockedAddFlowInput));
}
Also used : AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)

Aggregations

AddFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)15 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 AddFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)7 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)7 ArrayList (java.util.ArrayList)4 AddFlowOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput)4 FlowRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 BigInteger (java.math.BigInteger)2 List (java.util.List)2 Test (org.junit.Test)2 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)2 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)2 FlowTableRef (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef)2 RemoveFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder)2 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)2 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder)2 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)2 FlowModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder)2 ExecutionException (java.util.concurrent.ExecutionException)1