Search in sources :

Example 1 with AddFlowsDsInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImpl method addFlowsDs.

@Override
public Future<RpcResult<Void>> addFlowsDs(AddFlowsDsInput input) {
    WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    boolean createParentsNextTime = MoreObjects.firstNonNull(input.isAlwaysCreateParents(), Boolean.FALSE);
    boolean createParents = true;
    for (BulkFlowDsItem bulkFlow : input.getBulkFlowDsItem()) {
        FlowBuilder flowBuilder = new FlowBuilder(bulkFlow);
        flowBuilder.setTableId(bulkFlow.getTableId());
        flowBuilder.setId(new FlowId(bulkFlow.getFlowId()));
        writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getFlowInstanceIdentifier(bulkFlow), flowBuilder.build(), createParents);
        createParents = createParentsNextTime;
    }
    ListenableFuture<Void> submitFuture = writeTransaction.submit();
    return handleResultFuture(Futures.allAsList(submitFuture));
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) BulkFlowDsItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem)

Example 2 with AddFlowsDsInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImplTest method testAddRemoveFlowsDs.

@Test
public void testAddRemoveFlowsDs() throws Exception {
    Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
    final BulkFlowDsItemBuilder bulkFlowDsItemBuilder = new BulkFlowDsItemBuilder().setFlowId(new FlowId("1")).setTableId((short) 2);
    final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
    bulkFlowDsItemBuilder.setNode(new NodeRef(nodeId));
    final BulkFlowDsItem bulkFlowDsItem = bulkFlowDsItemBuilder.build();
    final List<BulkFlowDsItem> bulkFlowDsItems = new ArrayList<>();
    bulkFlowDsItems.add(bulkFlowDsItem);
    final AddFlowsDsInputBuilder addFlowsDsInputBuilder = new AddFlowsDsInputBuilder();
    addFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
    final AddFlowsDsInput addFlowsDsInput = addFlowsDsInputBuilder.build();
    salBulkFlowService.addFlowsDs(addFlowsDsInput);
    verify(writeTransaction).submit();
    verify(writeTransaction).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any(), flowArgumentCaptor.capture(), Mockito.anyBoolean());
    Flow flow = flowArgumentCaptor.getValue();
    Assert.assertEquals("1", flow.getId().getValue());
    Assert.assertEquals((short) 2, flow.getTableId().shortValue());
    final RemoveFlowsDsInputBuilder removeFlowsDsInputBuilder = new RemoveFlowsDsInputBuilder();
    removeFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
    final RemoveFlowsDsInput removeFlowsDsInput = removeFlowsDsInputBuilder.build();
    salBulkFlowService.removeFlowsDs(removeFlowsDsInput);
    verify(writeTransaction).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any());
    verify(writeTransaction, times(2)).submit();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) RemoveFlowsDsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInputBuilder) AddFlowsDsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput) BulkFlowDsItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItemBuilder) BulkFlowDsItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem) AddFlowsDsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder) RemoveFlowsDsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInput) Test(org.junit.Test)

Aggregations

BulkFlowDsItem (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem)2 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 AddFlowsDsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput)1 AddFlowsDsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder)1 RemoveFlowsDsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInput)1 RemoveFlowsDsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInputBuilder)1 BulkFlowDsItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItemBuilder)1 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)1 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)1 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1