Search in sources :

Example 31 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project openflowplugin by opendaylight.

the class TransactionChainManagerTest method testSubmitTransaction1.

/**
 * test of {@link TransactionChainManager#submitTransaction()}: no submit, never enabled.
 */
@Test
public void testSubmitTransaction1() throws Exception {
    final Node data = new NodeBuilder().setId(nodeId).build();
    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, Mockito.never()).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 32 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project openflowplugin by opendaylight.

the class TransactionChainManagerTest method testEnableCounter1.

/**
 * Test of {@link TransactionChainManager#enableSubmit()}: no submit - counter is not active.
 */
@Test
public void testEnableCounter1() throws Exception {
    final Node data = new NodeBuilder().setId(nodeId).build();
    txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
    txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
    Mockito.verify(txChain).newReadWriteTransaction();
    Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
    Mockito.verify(writeTx, Mockito.never()).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 33 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project openflowplugin by opendaylight.

the class NodeChangeListenerImpl method prepareTopologyNode.

private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node prepareTopologyNode(final NodeId nodeIdInTopology, final InstanceIdentifier<FlowCapableNode> iiToNodeInInventory) {
    final InventoryNode inventoryNode = new InventoryNodeBuilder().setInventoryNodeRef(new NodeRef(iiToNodeInInventory.firstIdentifierOf(Node.class))).build();
    final NodeBuilder topologyNodeBuilder = new NodeBuilder();
    topologyNodeBuilder.setNodeId(nodeIdInTopology);
    topologyNodeBuilder.addAugmentation(InventoryNode.class, inventoryNode);
    return topologyNodeBuilder.build();
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) InventoryNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNodeBuilder) InventoryNode(org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNode) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) InventoryNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNodeBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) InventoryNode(org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNode)

Example 34 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project openflowplugin by opendaylight.

the class TerminationPointChangeListenerImplTest method testOnNodeConnectorRemoved.

@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorRemoved() {
    NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
    TerminationPointKey terminationPointKey = new TerminationPointKey(new TpId("tp1"));
    final InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
    Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey(terminationPointKey.getTpId().getValue());
    final InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
    List<Link> linkList = Arrays.asList(newLink("link1", newSourceTp("tp1"), newDestTp("dest")), newLink("link2", newSourceTp("source"), newDestTp("tp1")), newLink("link3", newSourceTp("source2"), newDestTp("dest2")));
    final Topology topology = new TopologyBuilder().setLink(linkList).build();
    final InstanceIdentifier[] expDeletedIIDs = { topologyIID.child(Link.class, linkList.get(0).getKey()), topologyIID.child(Link.class, linkList.get(1).getKey()), topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1"))) };
    final SettableFuture<Optional<Topology>> readFuture = SettableFuture.create();
    readFuture.set(Optional.of(topology));
    ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class);
    doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
    SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
    readFutureNode.set(Optional.of(topoNode));
    doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
    final CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
    int expDeleteCalls = expDeletedIIDs.length;
    CountDownLatch deleteLatch = new CountDownLatch(expDeleteCalls);
    ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
    setupStubbedDeletes(mockTx1, deletedLinkIDs, deleteLatch);
    doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
    DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeConnID);
    terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
    waitForSubmit(submitLatch1);
    setReadFutureAsync(topology, readFuture);
    waitForDeletes(expDeleteCalls, deleteLatch);
    assertDeletedIDs(expDeletedIIDs, deletedLinkIDs);
    verifyMockTx(mockTx1);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TestUtils.newInvNodeKey(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Optional(com.google.common.base.Optional) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) CountDownLatch(java.util.concurrent.CountDownLatch) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) Mockito.doReturn(org.mockito.Mockito.doReturn) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TestUtils.newLink(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Test(org.junit.Test)

Example 35 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project genius by opendaylight.

the class OvsdbTestUtil method createNode.

public static CheckedFuture<Void, TransactionCommitFailedException> createNode(ConnectionInfo connectionInfo, String tepIp, String tzName, DataBroker dataBroker) throws Exception {
    final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
    // build Node using its builder class
    NodeBuilder nodeBuilder = new NodeBuilder();
    NodeId ovsdbNodeId = SouthboundUtils.createNodeId(connectionInfo.getRemoteIp(), connectionInfo.getRemotePort());
    nodeBuilder.setNodeId(ovsdbNodeId);
    // build OvsdbNodeAugmentation for Node
    OvsdbNodeAugmentationBuilder ovsdbNodeAugBuilder = new OvsdbNodeAugmentationBuilder();
    ovsdbNodeAugBuilder.setConnectionInfo(connectionInfo);
    // create map of key-val pairs
    Map<String, String> externalIds = new HashMap<>();
    Map<String, String> otherConfigs = new HashMap<>();
    if (tepIp != null && !tepIp.isEmpty()) {
        otherConfigs.put(ItmTestConstants.OTHER_CFG_TEP_IP_KEY, tepIp);
    }
    if (tzName != null) {
        externalIds.put(ItmTestConstants.EXTERNAL_ID_TZNAME_KEY, tzName);
    }
    // get map-keys into set.
    Set<String> externalIdKeys = externalIds.keySet();
    Set<String> otherConfigKeys = otherConfigs.keySet();
    List<OpenvswitchExternalIds> externalIdsList = new ArrayList<>();
    String externalIdValue = null;
    for (String externalIdKey : externalIdKeys) {
        externalIdValue = externalIds.get(externalIdKey);
        if (externalIdKey != null && externalIdValue != null) {
            externalIdsList.add(new OpenvswitchExternalIdsBuilder().setExternalIdKey(externalIdKey).setExternalIdValue(externalIdValue).build());
        }
    }
    List<OpenvswitchOtherConfigs> otherConfigsList = new ArrayList<>();
    String otherConfigValue = null;
    for (String otherConfigKey : otherConfigKeys) {
        otherConfigValue = otherConfigs.get(otherConfigKey);
        if (otherConfigKey != null && otherConfigValue != null) {
            otherConfigsList.add(new OpenvswitchOtherConfigsBuilder().setOtherConfigKey(otherConfigKey).setOtherConfigValue(otherConfigValue).build());
        }
    }
    // set ExternalIds list into Node
    ovsdbNodeAugBuilder.setOpenvswitchExternalIds(externalIdsList);
    // set OtherConfig list into Node
    ovsdbNodeAugBuilder.setOpenvswitchOtherConfigs(otherConfigsList);
    // add OvsdbNodeAugmentation into Node
    nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, ovsdbNodeAugBuilder.build());
    Node ovsdbNode = nodeBuilder.build();
    WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    transaction.put(LogicalDatastoreType.OPERATIONAL, iid, ovsdbNode, true);
    return transaction.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) HashMap(java.util.HashMap) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) OvsdbNodeAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) OpenvswitchExternalIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds) OpenvswitchOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs) OpenvswitchExternalIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIdsBuilder) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) OpenvswitchOtherConfigsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigsBuilder)

Aggregations

NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)35 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)30 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)21 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)21 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)18 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)17 Test (org.junit.Test)11 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)11 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)11 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)11 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)11 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)11 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)10 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)8 ArrayList (java.util.ArrayList)7 Optional (com.google.common.base.Optional)6 BigInteger (java.math.BigInteger)6 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)6 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)5