Search in sources :

Example 1 with SalFlowService

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

the class FlowForwarderTest method removeTest.

@Test
public void removeTest() throws Exception {
    Mockito.when(salFlowService.removeFlow(removeFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
    final Flow removeFlow = new FlowBuilder(flow).build();
    final Future<RpcResult<RemoveFlowOutput>> removeResult = flowForwarder.remove(flowPath, removeFlow, flowCapableNodePath);
    Mockito.verify(salFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
    final RemoveFlowInput flowInput = removeFlowInputCpt.getValue();
    Assert.assertEquals(2, flowInput.getTableId().shortValue());
    Assert.assertEquals(emptyMatch, flowInput.getMatch());
    Assert.assertEquals(null, flowInput.getInstructions());
    Assert.assertEquals(true, flowInput.isStrict());
    final RpcResult<RemoveFlowOutput> removeFlowOutputRpcResult = removeResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(removeFlowOutputRpcResult.isSuccessful());
    final RemoveFlowOutput resultValue = removeFlowOutputRpcResult.getResult();
    Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) RemoveFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TransactionId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) OriginalFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow) Test(org.junit.Test)

Example 2 with SalFlowService

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

the class DropTestRpcSender method processPacket.

@Override
protected void processPacket(final InstanceIdentifier<Node> node, final Match match, final Instructions instructions) {
    final AddFlowInputBuilder fb = BUILDER.get();
    // Finally build our flow
    fb.setMatch(match);
    fb.setInstructions(instructions);
    // Construct the flow instance id
    fb.setNode(new NodeRef(node));
    // Add flow
    final AddFlowInput flow = fb.build();
    if (LOG.isDebugEnabled()) {
        LOG.debug("onPacketReceived - About to write flow (via SalFlowService) {}", flow);
    }
    ListenableFuture<RpcResult<AddFlowOutput>> result = JdkFutureAdapters.listenInPoolThread(flowService.addFlow(flow));
    Futures.addCallback(result, new FutureCallback<RpcResult<AddFlowOutput>>() {

        @Override
        public void onSuccess(final RpcResult<AddFlowOutput> result) {
            countFutureSuccess();
        }

        @Override
        public void onFailure(final Throwable throwable) {
            countFutureError();
        }
    }, MoreExecutors.directExecutor());
}
Also used : AddFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder)

Example 3 with SalFlowService

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

the class SalFlowServiceImplTest method removeFlow.

private void removeFlow(short version) throws Exception {
    RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder().setMatch(match).setTableId((short) 1).build();
    SalFlowServiceImpl salFlowService = mockSalFlowService(version);
    verifyOutput(salFlowService.removeFlow(mockedRemoveFlowInput));
}
Also used : RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) RemoveFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder)

Example 4 with SalFlowService

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

the class SalFlowServiceImplTest method updateFlow.

private void updateFlow(short version) throws Exception {
    UpdateFlowInput mockedUpdateFlowInput = mock(UpdateFlowInput.class);
    UpdateFlowInput mockedUpdateFlowInput1 = mock(UpdateFlowInput.class);
    UpdatedFlow mockedUpdateFlow = new UpdatedFlowBuilder().setMatch(match).setTableId((short) 1).build();
    UpdatedFlow mockedUpdateFlow1 = new UpdatedFlowBuilder().setMatch(match).setTableId((short) 1).setPriority(1).build();
    when(mockedUpdateFlowInput.getUpdatedFlow()).thenReturn(mockedUpdateFlow);
    when(mockedUpdateFlowInput1.getUpdatedFlow()).thenReturn(mockedUpdateFlow1);
    FlowRef mockedFlowRef = mock(FlowRef.class);
    Mockito.doReturn(TABLE_II.child(Flow.class, new FlowKey(new FlowId(DUMMY_FLOW_ID)))).when(mockedFlowRef).getValue();
    when(mockedUpdateFlowInput.getFlowRef()).thenReturn(mockedFlowRef);
    when(mockedUpdateFlowInput1.getFlowRef()).thenReturn(mockedFlowRef);
    OriginalFlow mockedOriginalFlow = new OriginalFlowBuilder().setMatch(match).setTableId((short) 1).build();
    OriginalFlow mockedOriginalFlow1 = new OriginalFlowBuilder().setMatch(match).setTableId((short) 1).setPriority(2).build();
    when(mockedUpdateFlowInput.getOriginalFlow()).thenReturn(mockedOriginalFlow);
    when(mockedUpdateFlowInput1.getOriginalFlow()).thenReturn(mockedOriginalFlow1);
    SalFlowServiceImpl salFlowService = mockSalFlowService(version);
    verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput));
    verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput1));
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) FlowRef(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef) OriginalFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow) UpdateFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput) OriginalFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder) UpdatedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) OriginalFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow)

Example 5 with SalFlowService

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

the class Activator method onSessionInitialized.

@Override
public void onSessionInitialized(ConsumerContext session) {
    SalFlowService flowService = session.getRpcService(SalFlowService.class);
    new SimpleDropFirewall(flowService).start();
}
Also used : SalFlowService(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService)

Aggregations

Test (org.junit.Test)13 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)10 AddFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)9 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)7 InOrder (org.mockito.InOrder)6 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)6 UpdateFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)6 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)5 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)5 RemoveFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)5 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)5 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)4 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)4 TableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)4 StaleFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow)4 StaleFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowBuilder)4 StaleFlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey)4 FRMTest (test.mock.util.FRMTest)4