use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class FlowListenerTest method addTwoFlowsTest.
@Test
public void addTwoFlowsTest() throws Exception {
addFlowCapableNode(NODE_KEY);
FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
Flow flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
assertEquals(1, addFlowCalls.size());
assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
flowKey = new FlowKey(new FlowId("test_Flow2"));
flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
addFlowCalls = salFlowService.getAddFlowCalls();
assertEquals(2, addFlowCalls.size());
assertEquals("DOM-1", addFlowCalls.get(1).getTransactionUri().getValue());
assertEquals(2, addFlowCalls.get(1).getTableId().intValue());
assertEquals(flowII, addFlowCalls.get(1).getFlowRef().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class FlowReader method readFlowsX.
private void readFlowsX() {
readOpStatus.set(FlowCounter.OperationStatus.IN_PROGRESS.status());
for (int i = 1; i <= dpnCount; i++) {
String dpId = BulkOMaticUtils.DEVICE_TYPE_PREFIX + i;
for (int j = 0; j < flowsPerDpn; j++) {
short tableRollover = (short) (endTableId - startTableId + 1);
short tableId = (short) (j % tableRollover + startTableId);
Integer sourceIp = j + 1;
String flowId = "Flow-" + dpId + "." + tableId + "." + sourceIp;
InstanceIdentifier<Flow> flowIid = getFlowInstanceIdentifier(dpId, tableId, flowId);
ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction();
try {
Optional<Flow> flowOptional;
if (isConfigDs) {
flowOptional = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, flowIid).checkedGet();
} else {
flowOptional = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, flowIid).checkedGet();
}
if (flowOptional.isPresent()) {
flowCount.incrementAndGet();
if (verbose) {
LOG.info("Flow found: {}", flowOptional.get());
}
} else {
if (verbose) {
LOG.info("Flow: {} not found", flowIid);
}
}
} catch (ReadFailedException e) {
readOpStatus.set(FlowCounter.OperationStatus.FAILURE.status());
LOG.error(e.getMessage(), e);
}
}
}
if (readOpStatus.get() != FlowCounter.OperationStatus.FAILURE.status()) {
readOpStatus.set(FlowCounter.OperationStatus.SUCCESS.status());
}
LOG.info("Total Flows read: {}", flowCount);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class BulkOMaticUtils method buildFlow.
public static Flow buildFlow(Short tableId, String flowId, Match match) {
FlowBuilder flowBuilder = new FlowBuilder();
flowBuilder.setKey(new FlowKey(new FlowId(flowId)));
flowBuilder.setTableId(tableId);
flowBuilder.setMatch(match);
return flowBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class FlowNotificationSupplierImplTest method createTestFlow.
private static Flow createTestFlow() {
final FlowBuilder builder = new FlowBuilder();
builder.setId(new FlowId(FLOW_ID));
builder.setTableId(FLOW_TABLE_ID);
return builder.build();
}
Aggregations