use of org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem 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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem 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();
}
Aggregations