Search in sources :

Example 36 with Node

use of Nodes.Node 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 37 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class OF13DeviceInitializerTest method setUp.

@Before
public void setUp() throws Exception {
    final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier = DeviceStateUtil.createNodeInstanceIdentifier(new NodeId("openflow:1"));
    deviceInitializer = new OF13DeviceInitializer();
    when(multipartWriterProvider.lookup(any())).thenReturn(Optional.of(abstractMultipartWriter));
    when(featuresReply.getCapabilities()).thenReturn(capabilities);
    when(connectionContext.getFeatures()).thenReturn(featuresReply);
    when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
    when(deviceContext.getDeviceState()).thenReturn(deviceState);
    when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
    when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
    when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
    when(translatorLibrary.lookupTranslator(any())).thenReturn(messageTranslator);
    when(deviceContext.oook()).thenReturn(translatorLibrary);
    when(requestContext.getXid()).thenReturn(new Xid(42L));
    when(deviceContext.createRequestContext()).thenReturn(requestContext);
    when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Before(org.junit.Before)

Example 38 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class TransactionChainManagerTest method testSubmitTransaction.

/**
 * Tests transaction submit {@link TransactionChainManager#submitTransaction()}.
 */
@Test
public void testSubmitTransaction() throws Exception {
    final Node data = new NodeBuilder().setId(nodeId).build();
    txChainManager.initialSubmitWriteTransaction();
    txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
    txChainManager.submitTransaction();
    Mockito.verify(txChain).newReadWriteTransaction();
    Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
    Mockito.verify(writeTx).submit();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) Test(org.junit.Test)

Example 39 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class TransactionChainManagerTest method setUp.

@Before
public void setUp() throws Exception {
    final ReadOnlyTransaction readOnlyTx = Mockito.mock(ReadOnlyTransaction.class);
    final CheckedFuture<Optional<Node>, ReadFailedException> noExistNodeFuture = Futures.immediateCheckedFuture(Optional.<Node>absent());
    Mockito.when(readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)).thenReturn(noExistNodeFuture);
    Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTx);
    Mockito.when(dataBroker.createTransactionChain(Matchers.any(TransactionChainListener.class))).thenReturn(txChain);
    nodeId = new NodeId("h2g2:42");
    nodeKeyIdent = DeviceStateUtil.createNodeInstanceIdentifier(nodeId);
    Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
    Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
    txChainManager = new TransactionChainManager(dataBroker, nodeId.getValue());
    Mockito.when(txChain.newReadWriteTransaction()).thenReturn(writeTx);
    path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
    Mockito.when(writeTx.submit()).thenReturn(Futures.<Void, TransactionCommitFailedException>immediateCheckedFuture(null));
    txChainManager.activateTransactionManager();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) TransactionChainListener(org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Before(org.junit.Before)

Example 40 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class TransactionChainManagerTest method testShuttingDown.

@Test
public void testShuttingDown() throws Exception {
    final Node data = new NodeBuilder().setId(nodeId).build();
    txChainManager.initialSubmitWriteTransaction();
    txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
    txChainManager.shuttingDown();
    Mockito.verify(txChain).newReadWriteTransaction();
    Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
    Mockito.verify(writeTx).submit();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) Test(org.junit.Test)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)112 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)58 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)56 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)54 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)43 Test (org.junit.Test)21 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)20 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)19 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)19 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)19 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)17 BigInteger (java.math.BigInteger)16 ArrayList (java.util.ArrayList)16 NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)16 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)15 Before (org.junit.Before)11 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)8 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)7 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)7 Optional (com.google.common.base.Optional)6