Search in sources :

Example 1 with FlowCapableNodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testUpdateTableFeatures.

@Test
public void testUpdateTableFeatures() throws Exception {
    Mockito.when(tableCommitter.update(Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.isNull(TableFeatures.class), tableFeaturesCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateTableOutputBuilder().build()).buildFuture());
    final FlowCapableNode operational = new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setId((short) 1).build())).setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setName("test table features").setTableId((short) 1).build())).build();
    final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.updateTableFeatures(NODE_IDENT, operational);
    Assert.assertTrue(result.isDone());
    Assert.assertTrue(result.get().isSuccessful());
    final List<TableFeatures> groupCaptorAllValues = tableFeaturesCaptor.getAllValues();
    // TODO: uncomment when enabled in impl
    // Assert.assertEquals(1, groupCaptorAllValues.size());
    // Assert.assertEquals("test table features", groupCaptorAllValues.get(0).getName());
    // Assert.assertEquals(1, groupCaptorAllValues.get(0).getTableId().intValue());
    Mockito.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Also used : TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) UpdateTableOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder) Test(org.junit.Test)

Example 2 with FlowCapableNodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder in project openflowplugin by opendaylight.

the class FRMTest method addFlowCapableNode.

public void addFlowCapableNode(NodeKey nodeKey) {
    Nodes nodes = new NodesBuilder().setNode(Collections.<Node>emptyList()).build();
    FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
    NodeBuilder nodeBuilder = new NodeBuilder();
    nodeBuilder.setKey(nodeKey);
    nodeBuilder.addAugmentation(FlowCapableNode.class, fcnBuilder.build());
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), nodes);
    InstanceIdentifier<Node> flowNodeIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
    writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, nodeBuilder.build());
    writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes);
    writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, nodeBuilder.build());
    assertCommit(writeTx.submit());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) NodesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 3 with FlowCapableNodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder in project openflowplugin by opendaylight.

the class DeviceFlowRegistryImplTest method testFill.

@Test
public void testFill() throws Exception {
    final InstanceIdentifier<FlowCapableNode> path = nodeInstanceIdentifier.augmentation(FlowCapableNode.class);
    final Flow flow = new FlowBuilder().setTableId((short) 1).setPriority(10).setCookie(new FlowCookie(BigInteger.TEN)).setId(new FlowId("HELLO")).build();
    final Table table = new TableBuilder().setFlow(Collections.singletonList(flow)).build();
    final FlowCapableNode flowCapableNode = new FlowCapableNodeBuilder().setTable(Collections.singletonList(table)).build();
    final Map<FlowRegistryKey, FlowDescriptor> allFlowDescriptors = fillRegistry(path, flowCapableNode);
    key = FlowRegistryKeyFactory.create(OFConstants.OFP_VERSION_1_3, flow);
    InOrder order = inOrder(dataBroker, readOnlyTransaction);
    order.verify(dataBroker).newReadOnlyTransaction();
    order.verify(readOnlyTransaction).read(LogicalDatastoreType.CONFIGURATION, path);
    order.verify(dataBroker).newReadOnlyTransaction();
    order.verify(readOnlyTransaction).read(LogicalDatastoreType.OPERATIONAL, path);
    assertTrue(allFlowDescriptors.containsKey(key));
    deviceFlowRegistry.addMark(key);
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) InOrder(org.mockito.InOrder) FlowRegistryKey(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey) FlowDescriptor(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) 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) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Test(org.junit.Test)

Example 4 with FlowCapableNodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder in project openflowplugin by opendaylight.

the class DeviceFlowRegistryImplTest method testFailedFill.

@Test
public void testFailedFill() throws Exception {
    final InstanceIdentifier<FlowCapableNode> path = nodeInstanceIdentifier.augmentation(FlowCapableNode.class);
    fillRegistry(path, null);
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(null).build());
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(null)).build());
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(null).build())).build());
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(null)).build())).build());
    fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(new FlowBuilder().setId(null).build())).build())).build());
    verify(dataBroker, times(12)).newReadOnlyTransaction();
    verify(readOnlyTransaction, times(6)).read(LogicalDatastoreType.CONFIGURATION, path);
    verify(readOnlyTransaction, times(6)).read(LogicalDatastoreType.OPERATIONAL, path);
    Assert.assertEquals(1, deviceFlowRegistry.getAllFlowDescriptors().size());
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) Test(org.junit.Test)

Example 5 with FlowCapableNodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder in project genius by opendaylight.

the class MdSalUtilTest method addFlowCapableNode.

public void addFlowCapableNode(NodeKey nodeKey) throws ExecutionException, InterruptedException {
    Nodes nodes = new NodesBuilder().setNode(Collections.emptyList()).build();
    final InstanceIdentifier<Node> flowNodeIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
    FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
    NodeBuilder nodeBuilder = new NodeBuilder();
    nodeBuilder.setKey(nodeKey);
    nodeBuilder.addAugmentation(FlowCapableNode.class, fcnBuilder.build());
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), nodes);
    writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, nodeBuilder.build());
    writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes);
    writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, nodeBuilder.build());
    assertCommit(writeTx.submit());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) NodesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Aggregations

FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)10 FlowCapableNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder)10 Test (org.junit.Test)7 TableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)7 Optional (com.google.common.base.Optional)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)4 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)3 InOrder (org.mockito.InOrder)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 FlowRegistryKey (org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey)2 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)2 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)2 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)2 NodesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder)2 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)2 NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)2 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags)2 MultipartReplyFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder)2 MultipartReplyFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder)2 FlowStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder)2